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:
Emery Hemingway 2016-05-12 14:58:51 +02:00 committed by Norman Feske
parent f8337b511b
commit 2b8c1af9e0
28 changed files with 209 additions and 168 deletions

View File

@ -9,7 +9,7 @@
*/ */
/* /*
* Copyright (C) 2015 Genode Labs GmbH * Copyright (C) 2015-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -23,6 +23,7 @@
#include <linux_dataspace/linux_dataspace.h> #include <linux_dataspace/linux_dataspace.h>
#include <util/arg_string.h> #include <util/arg_string.h>
#include <root/root.h> #include <root/root.h>
#include <base/session_label.h>
/* local includes */ /* local includes */
#include "dataspace_component.h" #include "dataspace_component.h"
@ -32,12 +33,12 @@ using namespace Genode;
Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) Linux_dataspace::Filename Dataspace_component::_file_name(const char *args)
{ {
Filename fname; Session_label const label = label_from_args(args);
Arg_string::find_arg(args, "filename").string(fname.buf, Linux_dataspace::Filename fname;
sizeof(fname.buf), ""); strncpy(fname.buf, label.last_element().string(), sizeof(fname.buf));
/* only files inside the current working directory are allowed */ /* only files inside the current working directory are allowed */
for (const char *c = fname.buf; *c; c++) for (const char *c = fname.buf; *c; ++c)
if (*c == '/') throw Root::Invalid_args(); if (*c == '/') throw Root::Invalid_args();
return fname; return fname;

View File

@ -1,6 +1,7 @@
/* /*
* \brief Session label utility class * \brief Session label utility class
* \author Emery Hemingway * \author Emery Hemingway
* \author Norman Feske
* \date 2016-07-01 * \date 2016-07-01
*/ */
@ -22,27 +23,51 @@ namespace Genode { struct Session_label; }
struct Genode::Session_label : String<160> struct Genode::Session_label : String<160>
{ {
typedef String<capacity()> String; private:
using String::String; typedef String<capacity()> String;
char const *last_element() const static char const *_separator() { return " -> "; }
{ static size_t _separator_len() { return 4; }
char const * const full = string();
char const * const separator = " -> ";
size_t const full_len = strlen(full); public:
size_t const separator_len = strlen(separator);
if (full_len < separator_len) using String::String;
return full;
for (unsigned i = full_len - separator_len; i > 0; --i) Session_label last_element() const
if (!strcmp(separator, full + i, separator_len)) {
return full + i + separator_len; char const * const full = string();
size_t const full_len = strlen(full);
return full; if (full_len < _separator_len())
} return full;
for (unsigned i = full_len - _separator_len(); i > 0; --i)
if (!strcmp(_separator(), full + i, _separator_len()))
return full + i + _separator_len();
return Session_label(full);
}
/**
* Return part of the label without the last element
*/
inline Session_label prefix() const
{
if (length() < _separator_len() + 1)
return Session_label();
/* search for last occurrence of the separator */
unsigned prefix_len = length() - _separator_len() - 1;
char const * const full = string();
for (; prefix_len > 0; prefix_len--)
if (strcmp(full + prefix_len, _separator(), _separator_len()) == 0)
break;
/* construct new label with only the prefix part */
return Session_label(full, prefix_len);
}
}; };
@ -62,16 +87,18 @@ namespace Genode {
/** /**
* Create a compound label in the form of 'prefix -> label' * Create a compound label in the form of 'prefix -> label'
*/ */
inline Session_label prefixed_label(char const *prefix, char const *label) template <size_t N1, size_t N2>
inline Session_label prefixed_label(String<N1> const &prefix,
String<N2> const &label)
{ {
if (!*prefix) if (!prefix.valid())
return Session_label(label); return Session_label(label.string());
if (!*label) if (!label.valid())
return Session_label(prefix); return Session_label(prefix.string());
char buf[Session_label::capacity()]; char buf[Session_label::capacity()];
snprintf(buf, sizeof(buf), "%s -> %s", prefix, label); snprintf(buf, sizeof(buf), "%s -> %s", prefix.string(), label.string());
return Session_label(buf); return Session_label(buf);
} }

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (C) 2008-2013 Genode Labs GmbH * Copyright (C) 2008-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -16,7 +16,7 @@
#include <rom_session/client.h> #include <rom_session/client.h>
#include <base/connection.h> #include <base/connection.h>
#include <base/printf.h> #include <base/log.h>
namespace Genode { class Rom_connection; } namespace Genode { class Rom_connection; }
@ -30,15 +30,11 @@ class Genode::Rom_connection : public Connection<Rom_session>,
private: private:
Rom_session_capability _session(Parent &parent, Rom_session_capability _session(Parent &parent, char const *label)
char const *module_name,
char const *label)
{ {
try { try { return session("ram_quota=4K, label=\"%s\"", label); }
return session(parent, "ram_quota=4K, filename=\"%s\", label=\"%s\"",
module_name, label ? label: module_name); }
catch (...) { catch (...) {
PERR("Could not open ROM session for module \"%s\"", module_name); error("Could not open ROM session for \"", label, "\"");
throw Rom_connection_failed(); throw Rom_connection_failed();
} }
} }
@ -48,14 +44,13 @@ class Genode::Rom_connection : public Connection<Rom_session>,
/** /**
* Constructor * Constructor
* *
* \param module_name name of ROM module * \param label request label and name of ROM module
* \param label initial session label
* *
* \throw Rom_connection_failed * \throw Rom_connection_failed
*/ */
Rom_connection(Env &env, const char *module_name, const char *label = 0) Rom_connection(Env &env, const char *label)
: :
Connection<Rom_session>(env, _session(env.parent(), module_name, label)), Connection<Rom_session>(env, _session(env.parent(), label)),
Rom_session_client(cap()) Rom_session_client(cap())
{ } { }
@ -66,9 +61,9 @@ class Genode::Rom_connection : public Connection<Rom_session>,
* \deprecated Use the constructor with 'Env &' as first * \deprecated Use the constructor with 'Env &' as first
* argument instead * argument instead
*/ */
Rom_connection(const char *module_name, const char *label = 0) Rom_connection(const char *label)
: :
Connection<Rom_session>(_session(*env()->parent(), module_name, label)), Connection<Rom_session>(_session(*env()->parent(), label)),
Rom_session_client(cap()) Rom_session_client(cap())
{ } { }
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (C) 2006-2013 Genode Labs GmbH * Copyright (C) 2006-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -18,6 +18,7 @@
#include <base/rpc_server.h> #include <base/rpc_server.h>
#include <dataspace_component.h> #include <dataspace_component.h>
#include <rom_session/rom_session.h> #include <rom_session/rom_session.h>
#include <base/session_label.h>
namespace Genode { namespace Genode {
@ -26,18 +27,17 @@ namespace Genode {
private: private:
Rom_module *_rom_module; Rom_module *_rom_module;
char _fname[40];
Dataspace_component _ds; Dataspace_component _ds;
Rpc_entrypoint *_ds_ep; Rpc_entrypoint *_ds_ep;
Rom_dataspace_capability _ds_cap; Rom_dataspace_capability _ds_cap;
Rom_module * _find_rom(Rom_fs *rom_fs, const char *args) Rom_module * _find_rom(Rom_fs *rom_fs, const char *args)
{ {
/* extract filename from session arguments */ /* extract label */
Arg_string::find_arg(args, "filename").string(_fname, sizeof(_fname), ""); Session_label const label = label_from_args(args);
/* find ROM module for file name */ /* find ROM module for trailing label element */
return rom_fs->find(_fname); return rom_fs->find(label.last_element().string());
} }
public: public:
@ -48,8 +48,7 @@ namespace Genode {
* \param rom_fs ROM filesystem * \param rom_fs ROM filesystem
* \param ds_ep entry point to manage the dataspace * \param ds_ep entry point to manage the dataspace
* corresponding the rom session * corresponding the rom session
* \param args session-construction arguments, in * \param args session-construction arguments
* particular the filename
*/ */
Rom_session_component(Rom_fs *rom_fs, Rom_session_component(Rom_fs *rom_fs,
Rpc_entrypoint *ds_ep, Rpc_entrypoint *ds_ep,

View File

@ -217,7 +217,8 @@ Launchpad_child *Launchpad::start_child(const char *filename,
* constructor of 'Rom_connection' throws a 'Parent::Service_denied' * constructor of 'Rom_connection' throws a 'Parent::Service_denied'
* exception. * exception.
*/ */
Rom_connection rom(filename, unique_name); Rom_connection rom(prefixed_label(Session_label(unique_name),
Session_label(filename)).string());
rom.on_destruction(Rom_connection::KEEP_OPEN); rom.on_destruction(Rom_connection::KEEP_OPEN);
rom_cap = rom.cap(); rom_cap = rom.cap();
file_cap = rom.dataspace(); file_cap = rom.dataspace();

View File

@ -80,7 +80,7 @@ compare_output_to {
[init -> test-ldso] Catch exceptions in program [init -> test-ldso] Catch exceptions in program
[init -> test-ldso] --------------------------- [init -> test-ldso] ---------------------------
[init -> test-ldso] exception in remote procedure call: [init -> test-ldso] exception in remote procedure call:
[init -> test-ldso] Could not open ROM session for module "unknown_file" [init -> test-ldso] Error: Could not open ROM session for "unknown_file"
[init -> test-ldso] caught [init -> test-ldso] caught
[init -> test-ldso] exception in program: caught [init -> test-ldso] exception in program: caught
[init -> test-ldso] exception in shared lib: caught [init -> test-ldso] exception in shared lib: caught

View File

@ -21,6 +21,7 @@
#include <os/child_policy_dynamic_rom.h> #include <os/child_policy_dynamic_rom.h>
#include <cpu_session/connection.h> #include <cpu_session/connection.h>
#include <pd_session/connection.h> #include <pd_session/connection.h>
#include <base/session_label.h>
/* CLI-monitor includes */ /* CLI-monitor includes */
#include <cli_monitor/ram.h> #include <cli_monitor/ram.h>
@ -38,15 +39,13 @@ class Child_base : public Genode::Child_policy
class Quota_exceeded : public Genode::Exception { }; class Quota_exceeded : public Genode::Exception { };
typedef Genode::String<128> Label;
typedef Genode::size_t size_t; typedef Genode::size_t size_t;
private: private:
Ram &_ram; Ram &_ram;
Label const _label; Genode::Session_label const _label;
size_t _ram_quota; size_t _ram_quota;
size_t _ram_limit; size_t _ram_limit;
@ -119,7 +118,8 @@ class Child_base : public Genode::Child_policy
_ram_quota(ram_quota), _ram_quota(ram_quota),
_ram_limit(ram_limit), _ram_limit(ram_limit),
_resources(_label.string(), _ram_quota), _resources(_label.string(), _ram_quota),
_binary_rom(binary, _label.string()), _binary_rom(Genode::prefixed_label(Genode::Session_label(label),
Genode::Session_label(binary)).string()),
_entrypoint(&cap_session, ENTRYPOINT_STACK_SIZE, _label.string(), false), _entrypoint(&cap_session, ENTRYPOINT_STACK_SIZE, _label.string(), false),
_labeling_policy(_label.string()), _labeling_policy(_label.string()),
_binary_policy("binary", _binary_rom.dataspace(), &_entrypoint), _binary_policy("binary", _binary_rom.dataspace(), &_entrypoint),
@ -132,7 +132,7 @@ class Child_base : public Genode::Child_policy
_exit_sig_cap(exit_sig_cap) _exit_sig_cap(exit_sig_cap)
{ } { }
Label label() const { return _label; } Genode::Session_label label() const { return _label; }
void configure(char const *config, size_t config_len) void configure(char const *config, size_t config_len)
{ {

View File

@ -561,7 +561,7 @@ class Init::Child : Genode::Child_policy
affinity_space), affinity_space),
_entrypoint(&cap_session, ENTRYPOINT_STACK_SIZE, _name.unique, false, _entrypoint(&cap_session, ENTRYPOINT_STACK_SIZE, _name.unique, false,
_resources.affinity.location()), _resources.affinity.location()),
_binary_rom(_name.file, _name.file), _binary_rom(_name.file),
_binary_rom_ds(_binary_rom.dataspace()), _binary_rom_ds(_binary_rom.dataspace()),
_config(_resources.ram.cap(), start_node), _config(_resources.ram.cap(), start_node),
_server(_resources.ram.cap()), _server(_resources.ram.cap()),

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -21,6 +21,7 @@
#include <base/session_label.h> #include <base/session_label.h>
#include <util/arg_string.h> #include <util/arg_string.h>
#include <rom_session/connection.h> #include <rom_session/connection.h>
#include <base/session_label.h>
namespace Init { namespace Init {
@ -98,7 +99,8 @@ class Init::Child_policy_enforce_labeling
if (old_label == "") { if (old_label == "") {
Arg_string::set_arg_string(args, args_len, "label", _name); Arg_string::set_arg_string(args, args_len, "label", _name);
} else { } else {
Session_label const new_label = prefixed_label(_name, old_label.string()); Session_label const name(_name);
Session_label const new_label = prefixed_label(name, old_label);
Arg_string::set_arg_string(args, args_len, "label", new_label.string()); Arg_string::set_arg_string(args, args_len, "label", new_label.string());
} }
} }
@ -175,8 +177,7 @@ class Init::Child_policy_provide_rom_file
Genode::Rpc_entrypoint *_ep; Genode::Rpc_entrypoint *_ep;
Genode::Rom_session_capability _rom_session_cap; Genode::Rom_session_capability _rom_session_cap;
enum { FILENAME_MAX_LEN = 32 }; Genode::Session_label _module_name;
char _filename[FILENAME_MAX_LEN];
struct Local_rom_service : public Genode::Service struct Local_rom_service : public Genode::Service
{ {
@ -212,16 +213,15 @@ class Init::Child_policy_provide_rom_file
/** /**
* Constructor * Constructor
*/ */
Child_policy_provide_rom_file(const char *filename, Child_policy_provide_rom_file(const char *module_name,
Genode::Dataspace_capability ds_cap, Genode::Dataspace_capability ds_cap,
Genode::Rpc_entrypoint *ep) Genode::Rpc_entrypoint *ep)
: :
_local_rom_session(ds_cap), _ep(ep), _local_rom_session(ds_cap), _ep(ep),
_rom_session_cap(_ep->manage(&_local_rom_session)), _rom_session_cap(_ep->manage(&_local_rom_session)),
_module_name(module_name),
_local_rom_service(_rom_session_cap, ds_cap.valid()) _local_rom_service(_rom_session_cap, ds_cap.valid())
{ { }
Genode::strncpy(_filename, filename, sizeof(_filename));
}
/** /**
* Destructor * Destructor
@ -235,9 +235,11 @@ class Init::Child_policy_provide_rom_file
if (Genode::strcmp(service_name, "ROM")) return 0; if (Genode::strcmp(service_name, "ROM")) return 0;
/* drop out if request refers to another file name */ /* drop out if request refers to another file name */
char buf[FILENAME_MAX_LEN]; {
Genode::Arg_string::find_arg(args, "filename").string(buf, sizeof(buf), ""); Genode::Session_label const label = Genode::label_from_args(args);
return !Genode::strcmp(buf, _filename) ? &_local_rom_service : 0; return label.last_element() == _module_name
? &_local_rom_service : nullptr;
}
} }
}; };
@ -257,36 +259,31 @@ class Init::Child_policy_redirect_rom_file
void filter_session_args(const char *service, void filter_session_args(const char *service,
char *args, Genode::size_t args_len) char *args, Genode::size_t args_len)
{ {
using namespace Genode;
if (!_from || !_to) return; if (!_from || !_to) return;
/* ignore session requests for non-ROM services */ /* ignore session requests for non-ROM services */
if (Genode::strcmp(service, "ROM")) return; if (Genode::strcmp(service, "ROM")) return;
/* drop out if request refers to another file name */ /* drop out if request refers to another module name */
{ Session_label const label = label_from_args(args);
enum { FILENAME_MAX_LEN = 32 }; Session_label const from(_from);
char buf[FILENAME_MAX_LEN]; if (from != label.last_element()) return;
Genode::Arg_string::find_arg(args, "filename").string(buf, sizeof(buf), "");
if (Genode::strcmp(_from, buf) != 0) return;
/* replace filename argument */ /*
Genode::snprintf(buf, sizeof(buf), "\"%s\"", _to); * The module name corresponds to the last part of the label.
Genode::Arg_string::set_arg(args, args_len, "filename", buf); * We have to replace this part with the 'to' module name.
} * If the label consists of only the module name but no prefix,
* we replace the entire label with the 'to' module name.
*/
Session_label const prefix = label.prefix();
Session_label const to(_to);
/* replace characters after last label delimiter by filename */ Session_label const prefixed_to =
enum { LABEL_MAX_LEN = 200 }; prefixed_label(prefix.valid() ? prefix : nullptr, to);
char label[LABEL_MAX_LEN];
Genode::Arg_string::find_arg(args, "label").string(label, sizeof(label), "");
unsigned last_elem = 0;
for (unsigned i = 0; i < sizeof(label) - 3 && label[i]; i++)
if (Genode::strcmp("-> ", label + i, 3) == 0)
last_elem = i + 3;
label[last_elem] = 0;
char buf[LABEL_MAX_LEN]; Arg_string::set_arg_string(args, args_len, "label", prefixed_to.string());
Genode::snprintf(buf, sizeof(buf), "\"%s%s\"", label, _to);
Genode::Arg_string::set_arg(args, args_len, "label", buf);
} }
}; };

View File

@ -5,7 +5,7 @@
*/ */
/* /*
* Copyright (C) 2012-2013 Genode Labs GmbH * Copyright (C) 2012-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -57,8 +57,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
Rpc_entrypoint &_ep; Rpc_entrypoint &_ep;
Rom_session_capability _rom_session_cap; Rom_session_capability _rom_session_cap;
enum { FILENAME_MAX_LEN = 32 }; Session_label _module_name;
char _filename[FILENAME_MAX_LEN];
public: public:
@ -70,7 +69,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
* *
* If 'ram' is 0, the child policy is ineffective. * If 'ram' is 0, the child policy is ineffective.
*/ */
Child_policy_dynamic_rom_file(const char *filename, Child_policy_dynamic_rom_file(const char *module_name,
Rpc_entrypoint &ep, Rpc_entrypoint &ep,
Ram_session *ram) Ram_session *ram)
: :
@ -79,10 +78,9 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
_fg(0, 0), _bg(0, 0), _fg(0, 0), _bg(0, 0),
_bg_has_pending_data(false), _bg_has_pending_data(false),
_ep(ep), _ep(ep),
_rom_session_cap(_ep.manage(this)) _rom_session_cap(_ep.manage(this)),
{ _module_name(module_name)
strncpy(_filename, filename, sizeof(_filename)); { }
}
/** /**
* Destructor * Destructor
@ -168,10 +166,9 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object<Rom_session>,
/* ignore session requests for non-ROM services */ /* ignore session requests for non-ROM services */
if (strcmp(service_name, "ROM")) return 0; if (strcmp(service_name, "ROM")) return 0;
/* drop out if request refers to another file name */ /* drop out if request refers to another module name */
char buf[FILENAME_MAX_LEN]; Session_label const label = label_from_args(args);
Arg_string::find_arg(args, "filename").string(buf, sizeof(buf), ""); return _module_name == label.last_element() ? this : 0;
return !strcmp(buf, _filename) ? this : 0;
} }
}; };

View File

@ -6,7 +6,7 @@
*/ */
/* /*
* Copyright (C) 2012-2013 Genode Labs GmbH * Copyright (C) 2012-2016 Genode Labs GmbH
* *
* This file is part of the Genode OS framework, which is distributed * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -88,7 +88,8 @@ class Genode::Slave_policy : public Genode::Child_policy
: :
_label(label), _label(label),
_entrypoint(entrypoint), _entrypoint(entrypoint),
_binary_rom(binary ? binary : _label, _label), _binary_rom(binary ? prefixed_label(Session_label(label),
Session_label(binary)).string() : label),
_labeling_policy(_label), _labeling_policy(_label),
_binary_policy("binary", _binary_rom.dataspace(), &_entrypoint), _binary_policy("binary", _binary_rom.dataspace(), &_entrypoint),
_config_policy("config", _entrypoint, ram) _config_policy("config", _entrypoint, ram)

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -23,6 +23,8 @@
#include <os/server.h> #include <os/server.h>
#include <rom_session/rom_session.h> #include <rom_session/rom_session.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
#include <base/session_label.h>
#include <base/log.h>
namespace Dynamic_rom { namespace Dynamic_rom {
@ -202,13 +204,13 @@ class Dynamic_rom::Root : public Genode::Root_component<Session_component>
class Nonexistent_rom_module { }; 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 */ /* lookup ROM module in config */
for (unsigned i = 0; i < _config_node.num_sub_nodes(); i++) { for (unsigned i = 0; i < _config_node.num_sub_nodes(); i++) {
Xml_node node = _config_node.sub_node(i); Xml_node node = _config_node.sub_node(i);
if (node.has_attribute("name") if (node.has_attribute("name")
&& node.attribute("name").has_value(name)) && node.attribute("name").has_value(name.string()))
return node; return node;
} }
throw Nonexistent_rom_module(); 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) Session_component *_create_session(const char *args)
{ {
using namespace Genode;
/* read name of ROM module from args */ /* read name of ROM module from args */
char name[200]; Session_label const label = label_from_args(args);
Arg_string::find_arg(args, "filename").string(name, sizeof(name), ""); Session_label const module_name = label.last_element();
try { try {
return new (md_alloc()) return new (md_alloc())
Session_component(_ep, Session_component(_ep,
_lookup_rom_node_in_config(name), _lookup_rom_node_in_config(module_name),
_verbose); _verbose);
} catch (Nonexistent_rom_module) { } catch (Nonexistent_rom_module) {
PERR("ROM module lookup for \"%s\" failed.", name); error("ROM module lookup of '", label.string(), "' failed");
throw Root::Invalid_args(); throw Root::Invalid_args();
} }
} }

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -20,8 +20,9 @@
#include <util/arg_string.h> #include <util/arg_string.h>
#include <base/rpc_server.h> #include <base/rpc_server.h>
#include <base/env.h> #include <base/env.h>
#include <base/printf.h>
#include <os/path.h> #include <os/path.h>
#include <base/session_label.h>
#include <base/log.h>
using namespace Genode; using namespace Genode;
@ -99,7 +100,7 @@ class Rom_session_component : public Genode::Rpc_object<Genode::Rom_session>
{ {
Genode::Lock::Guard guard(_sigh_lock); Genode::Lock::Guard guard(_sigh_lock);
PINF("detected directory change"); Genode::log("detected directory change");
if (_sigh.valid()) if (_sigh.valid())
Genode::Signal_transmitter(_sigh).submit(); 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()) if (_compound_dir_handle.valid())
_fs.sigh(_compound_dir_handle, _dir_change_dispatcher); _fs.sigh(_compound_dir_handle, _dir_change_dispatcher);
else 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; _file_size = file_size;
} }
} catch (...) { } 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(); _file_ds = Ram_dataspace_capability();
return; return;
} }
@ -331,16 +332,14 @@ class Rom_root : public Genode::Root_component<Rom_session_component>
Rom_session_component *_create_session(const char *args) Rom_session_component *_create_session(const char *args)
{ {
enum { FILENAME_MAX_LEN = 128 }; Genode::Session_label const label = label_from_args(args);
char filename[FILENAME_MAX_LEN]; Genode::Session_label const module_name = label.last_element();
Genode::Arg_string::find_arg(args, "filename")
.string(filename, sizeof(filename), "");
PINF("connection for file '%s' requested\n", filename); Genode::log(label.string(), " requests '", module_name.string(), "'");
/* create new session for the requested file */ /* create new session for the requested file */
return new (md_alloc()) return new (md_alloc())
Rom_session_component(_fs, filename, _sig_rec); Rom_session_component(_fs, module_name.string(), _sig_rec);
} }
public: public:

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -23,7 +23,7 @@
#include <util/avl_string.h> #include <util/avl_string.h>
#include <util/misc_math.h> #include <util/misc_math.h>
#include <os/attached_ram_dataspace.h> #include <os/attached_ram_dataspace.h>
#inlcude <base/session_label.h> #include <base/session_label.h>
/* local includes */ /* local includes */
#include "iso9660.h" #include "iso9660.h"
@ -136,9 +136,8 @@ namespace Iso {
if (ram_quota < session_size) if (ram_quota < session_size)
throw Root::Quota_exceeded(); throw Root::Quota_exceeded();
Arg_string::find_arg(args, Session_label const label = label_from_args(args);
"filename").string(_path, strncpy(_path, label.last_element().string(), sizeof(_path));
sizeof(_path), "");
if (verbose) if (verbose)
PDBG("Request for file %s lrn %zu", _path, strlen(_path)); PDBG("Request for file %s lrn %zu", _path, strlen(_path));

View File

@ -95,7 +95,7 @@ namespace Loader {
{ {
try { try {
char args[Session::Name::MAX_SIZE]; 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())); return static_cap_cast<Rom_session>(_local_rom_service.session(args, Affinity()));
} catch (Genode::Parent::Service_denied) { } catch (Genode::Parent::Service_denied) {
PERR("Lookup for ROM module \"%s\" failed", name); PERR("Lookup for ROM module \"%s\" failed", name);

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -84,13 +84,10 @@ class Loader::Session_component : public Rpc_object<Session>
try { try {
Lock::Guard guard(_lock); Lock::Guard guard(_lock);
char name[Session::Name::MAX_SIZE]; Session_label const label = label_from_args(args);
Session_label name = label.last_element();
/* extract filename from session arguments */
Arg_string::find_arg(args, "filename")
.string(name, sizeof(name), "");
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 *rom = new (&_md_alloc)
Rom_session_component(module); Rom_session_component(module);

View File

@ -15,6 +15,7 @@
#include <util/arg_string.h> #include <util/arg_string.h>
#include <base/heap.h> #include <base/heap.h>
#include <base/env.h> #include <base/env.h>
#include <base/session_label.h>
#include <root/component.h> #include <root/component.h>
#include <os/server.h> #include <os/server.h>
#include <os/attached_ram_dataspace.h> #include <os/attached_ram_dataspace.h>
@ -32,19 +33,15 @@ namespace Report {
class Report::Session_component : public Genode::Rpc_object<Session> class Report::Session_component : public Genode::Rpc_object<Session>
{ {
public:
typedef Genode::String<200> Label;
private: private:
Label _label; Genode::Session_label _label;
Genode::Attached_ram_dataspace _ds; Genode::Attached_ram_dataspace _ds;
public: 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) _label(label), _ds(env()->ram_session(), buffer_size)
{ } { }
@ -80,15 +77,14 @@ class Report::Root : public Genode::Root_component<Session_component>
using namespace Genode; using namespace Genode;
/* read label from session arguments */ /* read label from session arguments */
char label[200]; Session_label label = label_from_args(args);
Arg_string::find_arg(args, "label").string(label, sizeof(label), "");
/* read report buffer size from session arguments */ /* read report buffer size from session arguments */
size_t const buffer_size = size_t const buffer_size =
Arg_string::find_arg(args, "buffer_size").ulong_value(0); Arg_string::find_arg(args, "buffer_size").ulong_value(0);
return new (md_alloc()) return new (md_alloc())
Session_component(Session_component::Label(label), buffer_size); Session_component(label, buffer_size);
} }
public: public:

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -22,6 +22,7 @@
#include <base/sleep.h> #include <base/sleep.h>
#include <os/config.h> #include <os/config.h>
#include <timer_session/connection.h> #include <timer_session/connection.h>
#include <base/session_label.h>
volatile int dummy; 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) Rom_session_component *_create_session(const char *args)
{ {
enum { FILENAME_MAX_LEN = 128 }; Genode::Session_label const label = Genode::label_from_args(args);
char filename[FILENAME_MAX_LEN]; Genode::Session_label const name = label.last_element();
Genode::Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), "");
/* create new session for the requested file */ /* 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: public:

View File

@ -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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -22,6 +22,7 @@
#include <base/env.h> #include <base/env.h>
#include <base/printf.h> #include <base/printf.h>
#include <os/config.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) Rom_session_component *_create_session(const char *args)
{ {
enum { FILENAME_MAX_LEN = 128 }; using namespace Genode;
char filename[FILENAME_MAX_LEN];
Genode::Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), "");
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 */ /* 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: public:

View File

@ -38,6 +38,8 @@ class Bomb_child_resources
{ {
protected: protected:
Genode::Session_label _rom_label;
Genode::Pd_connection _pd; Genode::Pd_connection _pd;
Genode::Rom_connection _rom; Genode::Rom_connection _rom;
Genode::Ram_connection _ram; Genode::Ram_connection _ram;
@ -48,10 +50,13 @@ class Bomb_child_resources
Genode::Region_map_client _address_space { _pd.address_space() }; Genode::Region_map_client _address_space { _pd.address_space() };
Bomb_child_resources(const char *file_name, const char *name, Bomb_child_resources(const char *elf_name, const char *name,
Genode::size_t ram_quota) Genode::size_t ram_quota)
: :
_pd(name), _rom(file_name, name), _ram(name), _cpu(name), _name(name) _rom_label(Genode::prefixed_label(Genode::Session_label(name),
Genode::Session_label(elf_name))),
_pd(name), _rom(_rom_label.string()),
_ram(name), _cpu(name), _name(name)
{ {
_ram.ref_account(env()->ram_session_cap()); _ram.ref_account(env()->ram_session_cap());
Genode::env()->ram_session()->transfer_quota(_ram.cap(), ram_quota); Genode::env()->ram_session()->transfer_quota(_ram.cap(), ram_quota);

View File

@ -1,5 +1,11 @@
include $(REP_DIR)/lib/mk/virtualbox-common.inc include $(REP_DIR)/lib/mk/virtualbox-common.inc
#
# Prevent inclusion of the Genode::Log definition after the vbox #define
# of 'Log'. Otherwise, the attemt to compile base/log.h will fail.
#
VBOX_CC_OPT += -include base/log.h
LIBS += stdcxx LIBS += stdcxx
SRC_CC = pgm.cc sup.cc SRC_CC = pgm.cc sup.cc

View File

@ -1,5 +1,11 @@
include $(REP_DIR)/lib/mk/virtualbox-common.inc include $(REP_DIR)/lib/mk/virtualbox-common.inc
#
# Prevent inclusion of the Genode::Log definition after the vbox #define
# of 'Log'. Otherwise, the attemt to compile base/log.h will fail.
#
VBOX_CC_OPT += -include base/log.h
LIBS += stdcxx LIBS += stdcxx
SRC_CC = sup.cc pgm.cc SRC_CC = sup.cc pgm.cc

View File

@ -2,6 +2,12 @@ include $(REP_DIR)/lib/mk/virtualbox-common.inc
VBOX_CC_OPT += -DVBOX_WITH_GENERIC_SESSION_WATCHER VBOX_CC_OPT += -DVBOX_WITH_GENERIC_SESSION_WATCHER
#
# Prevent inclusion of the Genode::Log definition after the vbox #define
# of 'Log'. Otherwise, the attemt to compile base/log.h will fail.
#
VBOX_CC_OPT += -include base/log.h
LIBS += stdcxx LIBS += stdcxx
SRC_CC += Main/xml/Settings.cpp SRC_CC += Main/xml/Settings.cpp

View File

@ -321,7 +321,8 @@ extern "C" int fork()
char *unique_name = filename; char *unique_name = filename;
Capability<Rom_dataspace> file_cap; Capability<Rom_dataspace> file_cap;
try { try {
static Rom_connection rom(filename, unique_name); static Rom_connection rom(prefixed_label(Session_label(unique_name),
Session_label(filename)).string());
file_cap = rom.dataspace(); file_cap = rom.dataspace();
} catch (Rom_connection::Rom_connection_failed) { } catch (Rom_connection::Rom_connection_failed) {
Genode::printf("Error: Could not access file \"%s\" from ROM service.\n", filename); Genode::printf("Error: Could not access file \"%s\" from ROM service.\n", filename);

View File

@ -93,11 +93,10 @@ class Gdb_monitor::Rom_root : public Root_component<Rom_session_component>
Rom_session_component *_create_session(char const *args) Rom_session_component *_create_session(char const *args)
{ {
enum { FILENAME_MAX_LEN = 128 }; Session_label const label = label_from_args(args);
char filename[FILENAME_MAX_LEN];
Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), "");
return new (md_alloc()) Rom_session_component(filename); return new (md_alloc())
Rom_session_component(label.last_element().string());
} }
public: public:

View File

@ -9,7 +9,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 * This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU General Public License version 2. * under the terms of the GNU General Public License version 2.
@ -44,13 +44,12 @@ namespace Noux {
Genode::Session_capability session(const char *args, Affinity const &) Genode::Session_capability session(const char *args, Affinity const &)
{ {
enum { NAME_MAX_LEN = 128 }; Session_label const label = label_from_args(args);
char name[NAME_MAX_LEN];
Arg_string::find_arg(args, "filename").string(name, sizeof(name), "<noname>");
try { try {
Genode::Session_label const module_name = label.last_element();
Rom_session_component *rom = new (env()->heap()) Rom_session_component *rom = new (env()->heap())
Rom_session_component(_ds_registry, name); Rom_session_component(_ds_registry, module_name.string());
return _ep.manage(rom); return _ep.manage(rom);
} catch (Rom_connection::Rom_connection_failed) { } catch (Rom_connection::Rom_connection_failed) {

View File

@ -12,6 +12,7 @@
*/ */
#include <base/printf.h> #include <base/printf.h>
#include <base/log.h>
#include <util/xml_node.h> #include <util/xml_node.h>
#include <VBox/settings.h> #include <VBox/settings.h>

View File

@ -1,4 +1,5 @@
#include <base/printf.h> #include <base/printf.h>
#include <base/log.h>
#include "VirtualBoxImpl.h" #include "VirtualBoxImpl.h"
#include "VBox/com/MultiResult.h" #include "VBox/com/MultiResult.h"