mirror of
https://github.com/genodelabs/genode.git
synced 2025-06-19 07:38:28 +00:00
remove 'filename' from ROM sesion args
Conveying the ROM filename as the final label element simplifies routing policy and session construction. Annotations by nfeske: This commit also changes the ROM session to use base/log.h instead of base/printf.h, which produced build error of VirtualBox because the vbox headers have a '#define Log', which collides with the content of base/log.h. Hence, this commit has to take precautions to resolve this conflict. The commit alse refines the previous session-label change by adding a new 'Session_label::prefix' method and removing the use of 'char const *' from this part of the API. Fixes #1787
This commit is contained in:
committed by
Norman Feske
parent
f8337b511b
commit
2b8c1af9e0
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2014 Genode Labs GmbH
|
||||
* Copyright (C) 2014-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -23,6 +23,8 @@
|
||||
#include <os/server.h>
|
||||
#include <rom_session/rom_session.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <base/session_label.h>
|
||||
#include <base/log.h>
|
||||
|
||||
|
||||
namespace Dynamic_rom {
|
||||
@ -202,13 +204,13 @@ class Dynamic_rom::Root : public Genode::Root_component<Session_component>
|
||||
|
||||
class Nonexistent_rom_module { };
|
||||
|
||||
Xml_node _lookup_rom_node_in_config(char const *name)
|
||||
Xml_node _lookup_rom_node_in_config(Genode::Session_label const &name)
|
||||
{
|
||||
/* lookup ROM module in config */
|
||||
for (unsigned i = 0; i < _config_node.num_sub_nodes(); i++) {
|
||||
Xml_node node = _config_node.sub_node(i);
|
||||
if (node.has_attribute("name")
|
||||
&& node.attribute("name").has_value(name))
|
||||
&& node.attribute("name").has_value(name.string()))
|
||||
return node;
|
||||
}
|
||||
throw Nonexistent_rom_module();
|
||||
@ -218,18 +220,20 @@ class Dynamic_rom::Root : public Genode::Root_component<Session_component>
|
||||
|
||||
Session_component *_create_session(const char *args)
|
||||
{
|
||||
using namespace Genode;
|
||||
|
||||
/* read name of ROM module from args */
|
||||
char name[200];
|
||||
Arg_string::find_arg(args, "filename").string(name, sizeof(name), "");
|
||||
Session_label const label = label_from_args(args);
|
||||
Session_label const module_name = label.last_element();
|
||||
|
||||
try {
|
||||
return new (md_alloc())
|
||||
Session_component(_ep,
|
||||
_lookup_rom_node_in_config(name),
|
||||
_lookup_rom_node_in_config(module_name),
|
||||
_verbose);
|
||||
|
||||
} catch (Nonexistent_rom_module) {
|
||||
PERR("ROM module lookup for \"%s\" failed.", name);
|
||||
error("ROM module lookup of '", label.string(), "' failed");
|
||||
throw Root::Invalid_args();
|
||||
}
|
||||
}
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2013 Genode Labs GmbH
|
||||
* Copyright (C) 2013-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -20,8 +20,9 @@
|
||||
#include <util/arg_string.h>
|
||||
#include <base/rpc_server.h>
|
||||
#include <base/env.h>
|
||||
#include <base/printf.h>
|
||||
#include <os/path.h>
|
||||
#include <base/session_label.h>
|
||||
#include <base/log.h>
|
||||
|
||||
|
||||
using namespace Genode;
|
||||
@ -99,7 +100,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
|
||||
{
|
||||
Genode::Lock::Guard guard(_sigh_lock);
|
||||
|
||||
PINF("detected directory change");
|
||||
Genode::log("detected directory change");
|
||||
if (_sigh.valid())
|
||||
Genode::Signal_transmitter(_sigh).submit();
|
||||
}
|
||||
@ -182,7 +183,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
|
||||
if (_compound_dir_handle.valid())
|
||||
_fs.sigh(_compound_dir_handle, _dir_change_dispatcher);
|
||||
else
|
||||
PWRN("could not track compound dir, giving up");
|
||||
Genode::warning("could not track compound dir, giving up");
|
||||
}
|
||||
|
||||
/**
|
||||
@ -243,7 +244,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
|
||||
_file_size = file_size;
|
||||
}
|
||||
} catch (...) {
|
||||
PERR("couldn't allocate memory for file, empty result\n");
|
||||
Genode::error("couldn't allocate memory for file, empty result");
|
||||
_file_ds = Ram_dataspace_capability();
|
||||
return;
|
||||
}
|
||||
@ -331,16 +332,14 @@ class Rom_root : public Genode::Root_component<Rom_session_component>
|
||||
|
||||
Rom_session_component *_create_session(const char *args)
|
||||
{
|
||||
enum { FILENAME_MAX_LEN = 128 };
|
||||
char filename[FILENAME_MAX_LEN];
|
||||
Genode::Arg_string::find_arg(args, "filename")
|
||||
.string(filename, sizeof(filename), "");
|
||||
Genode::Session_label const label = label_from_args(args);
|
||||
Genode::Session_label const module_name = label.last_element();
|
||||
|
||||
PINF("connection for file '%s' requested\n", filename);
|
||||
Genode::log(label.string(), " requests '", module_name.string(), "'");
|
||||
|
||||
/* create new session for the requested file */
|
||||
return new (md_alloc())
|
||||
Rom_session_component(_fs, filename, _sig_rec);
|
||||
Rom_session_component(_fs, module_name.string(), _sig_rec);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2010-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -23,7 +23,7 @@
|
||||
#include <util/avl_string.h>
|
||||
#include <util/misc_math.h>
|
||||
#include <os/attached_ram_dataspace.h>
|
||||
#inlcude <base/session_label.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
/* local includes */
|
||||
#include "iso9660.h"
|
||||
@ -136,9 +136,8 @@ namespace Iso {
|
||||
if (ram_quota < session_size)
|
||||
throw Root::Quota_exceeded();
|
||||
|
||||
Arg_string::find_arg(args,
|
||||
"filename").string(_path,
|
||||
sizeof(_path), "");
|
||||
Session_label const label = label_from_args(args);
|
||||
strncpy(_path, label.last_element().string(), sizeof(_path));
|
||||
|
||||
if (verbose)
|
||||
PDBG("Request for file %s lrn %zu", _path, strlen(_path));
|
||||
|
@ -95,7 +95,7 @@ namespace Loader {
|
||||
{
|
||||
try {
|
||||
char args[Session::Name::MAX_SIZE];
|
||||
snprintf(args, sizeof(args), "ram_quota=4K, filename=\"%s\"", name);
|
||||
snprintf(args, sizeof(args), "ram_quota=4K, label=\"%s\"", name);
|
||||
return static_cap_cast<Rom_session>(_local_rom_service.session(args, Affinity()));
|
||||
} catch (Genode::Parent::Service_denied) {
|
||||
PERR("Lookup for ROM module \"%s\" failed", name);
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2010-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -84,13 +84,10 @@ class Loader::Session_component : public Rpc_object<Session>
|
||||
try {
|
||||
Lock::Guard guard(_lock);
|
||||
|
||||
char name[Session::Name::MAX_SIZE];
|
||||
|
||||
/* extract filename from session arguments */
|
||||
Arg_string::find_arg(args, "filename")
|
||||
.string(name, sizeof(name), "");
|
||||
Session_label const label = label_from_args(args);
|
||||
Session_label name = label.last_element();
|
||||
|
||||
Rom_module &module = _rom_modules.lookup_and_lock(name);
|
||||
Rom_module &module = _rom_modules.lookup_and_lock(name.string());
|
||||
|
||||
Rom_session_component *rom = new (&_md_alloc)
|
||||
Rom_session_component(module);
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include <util/arg_string.h>
|
||||
#include <base/heap.h>
|
||||
#include <base/env.h>
|
||||
#include <base/session_label.h>
|
||||
#include <root/component.h>
|
||||
#include <os/server.h>
|
||||
#include <os/attached_ram_dataspace.h>
|
||||
@ -32,19 +33,15 @@ namespace Report {
|
||||
|
||||
class Report::Session_component : public Genode::Rpc_object<Session>
|
||||
{
|
||||
public:
|
||||
|
||||
typedef Genode::String<200> Label;
|
||||
|
||||
private:
|
||||
|
||||
Label _label;
|
||||
Genode::Session_label _label;
|
||||
|
||||
Genode::Attached_ram_dataspace _ds;
|
||||
|
||||
public:
|
||||
|
||||
Session_component(Label const &label, size_t buffer_size)
|
||||
Session_component(Genode::Session_label const &label, size_t buffer_size)
|
||||
:
|
||||
_label(label), _ds(env()->ram_session(), buffer_size)
|
||||
{ }
|
||||
@ -80,15 +77,14 @@ class Report::Root : public Genode::Root_component<Session_component>
|
||||
using namespace Genode;
|
||||
|
||||
/* read label from session arguments */
|
||||
char label[200];
|
||||
Arg_string::find_arg(args, "label").string(label, sizeof(label), "");
|
||||
Session_label label = label_from_args(args);
|
||||
|
||||
/* read report buffer size from session arguments */
|
||||
size_t const buffer_size =
|
||||
Arg_string::find_arg(args, "buffer_size").ulong_value(0);
|
||||
|
||||
return new (md_alloc())
|
||||
Session_component(Session_component::Label(label), buffer_size);
|
||||
Session_component(label, buffer_size);
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2011-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2011-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -22,6 +22,7 @@
|
||||
#include <base/sleep.h>
|
||||
#include <os/config.h>
|
||||
#include <timer_session/connection.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
volatile int dummy;
|
||||
|
||||
@ -78,12 +79,12 @@ class Rom_root : public Genode::Root_component<Rom_session_component>
|
||||
|
||||
Rom_session_component *_create_session(const char *args)
|
||||
{
|
||||
enum { FILENAME_MAX_LEN = 128 };
|
||||
char filename[FILENAME_MAX_LEN];
|
||||
Genode::Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), "");
|
||||
Genode::Session_label const label = Genode::label_from_args(args);
|
||||
Genode::Session_label const name = label.last_element();
|
||||
|
||||
/* create new session for the requested file */
|
||||
return new (md_alloc()) Rom_session_component(filename);
|
||||
return new (md_alloc())
|
||||
Rom_session_component(name.string());
|
||||
}
|
||||
|
||||
public:
|
||||
|
@ -6,7 +6,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copyright (C) 2010-2013 Genode Labs GmbH
|
||||
* Copyright (C) 2010-2016 Genode Labs GmbH
|
||||
*
|
||||
* This file is part of the Genode OS framework, which is distributed
|
||||
* under the terms of the GNU General Public License version 2.
|
||||
@ -22,6 +22,7 @@
|
||||
#include <base/env.h>
|
||||
#include <base/printf.h>
|
||||
#include <os/config.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
|
||||
/**
|
||||
@ -180,14 +181,16 @@ class Rom_root : public Genode::Root_component<Rom_session_component>
|
||||
|
||||
Rom_session_component *_create_session(const char *args)
|
||||
{
|
||||
enum { FILENAME_MAX_LEN = 128 };
|
||||
char filename[FILENAME_MAX_LEN];
|
||||
Genode::Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), "");
|
||||
using namespace Genode;
|
||||
|
||||
PINF("connection for file '%s' requested\n", filename);
|
||||
Session_label const label = label_from_args(args);
|
||||
Session_label const module_name = label.last_element();
|
||||
|
||||
PINF("connection for module '%s' requested", module_name.string());
|
||||
|
||||
/* create new session for the requested file */
|
||||
return new (md_alloc()) Rom_session_component(_tar_addr, _tar_size, filename);
|
||||
return new (md_alloc()) Rom_session_component(_tar_addr, _tar_size,
|
||||
module_name.string());
|
||||
}
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user