From 2b8c1af9e01d75b972d51cdf070a4315e0e4d385 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Thu, 12 May 2016 14:58:51 +0200 Subject: [PATCH] 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 --- .../src/core/dataspace_component.cc | 13 ++-- repos/base/include/base/session_label.h | 69 +++++++++++++------ repos/base/include/rom_session/connection.h | 25 +++---- .../src/core/include/rom_session_component.h | 15 ++-- repos/demo/src/lib/launchpad/launchpad.cc | 3 +- repos/libports/run/ldso.run | 2 +- repos/os/include/cli_monitor/child.h | 10 +-- repos/os/include/init/child.h | 2 +- repos/os/include/init/child_policy.h | 63 ++++++++--------- .../os/include/os/child_policy_dynamic_rom.h | 21 +++--- repos/os/include/os/slave.h | 5 +- repos/os/src/server/dynamic_rom/main.cc | 18 +++-- repos/os/src/server/fs_rom/main.cc | 21 +++--- repos/os/src/server/iso9660/main.cc | 9 ++- repos/os/src/server/loader/child.h | 2 +- repos/os/src/server/loader/main.cc | 11 ++- repos/os/src/server/log_report/main.cc | 14 ++-- repos/os/src/server/rom_prefetcher/main.cc | 11 +-- repos/os/src/server/tar_rom/main.cc | 15 ++-- repos/os/src/test/bomb/main.cc | 9 ++- .../spec/hw_x86_64_muen/virtualbox-hwaccl.mk | 6 ++ .../lib/mk/spec/nova/virtualbox-hwaccl.mk | 6 ++ repos/ports/lib/mk/virtualbox-main.mk | 6 ++ .../app/gdb_monitor/gdbserver/genode-low.cc | 3 +- repos/ports/src/app/gdb_monitor/rom.h | 7 +- repos/ports/src/noux/local_rom_service.h | 9 ++- .../ports/src/virtualbox/frontend/console.cc | 1 + .../frontend/dummy/virtualboxbase.cc | 1 + 28 files changed, 209 insertions(+), 168 deletions(-) diff --git a/repos/base-linux/src/core/dataspace_component.cc b/repos/base-linux/src/core/dataspace_component.cc index b03390c86..c6e54ea22 100644 --- a/repos/base-linux/src/core/dataspace_component.cc +++ b/repos/base-linux/src/core/dataspace_component.cc @@ -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 * under the terms of the GNU General Public License version 2. @@ -23,6 +23,7 @@ #include #include #include +#include /* local includes */ #include "dataspace_component.h" @@ -32,12 +33,12 @@ using namespace Genode; Linux_dataspace::Filename Dataspace_component::_file_name(const char *args) { - Filename fname; - Arg_string::find_arg(args, "filename").string(fname.buf, - sizeof(fname.buf), ""); - + Session_label const label = label_from_args(args); + Linux_dataspace::Filename fname; + strncpy(fname.buf, label.last_element().string(), sizeof(fname.buf)); + /* 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(); return fname; diff --git a/repos/base/include/base/session_label.h b/repos/base/include/base/session_label.h index 8fa638424..5389661cd 100644 --- a/repos/base/include/base/session_label.h +++ b/repos/base/include/base/session_label.h @@ -1,6 +1,7 @@ /* * \brief Session label utility class * \author Emery Hemingway + * \author Norman Feske * \date 2016-07-01 */ @@ -22,27 +23,51 @@ namespace Genode { struct Session_label; } struct Genode::Session_label : String<160> { - typedef String String; + private: - using String::String; + typedef String String; - char const *last_element() const - { - char const * const full = string(); - char const * const separator = " -> "; + static char const *_separator() { return " -> "; } + static size_t _separator_len() { return 4; } - size_t const full_len = strlen(full); - size_t const separator_len = strlen(separator); + public: - if (full_len < separator_len) - return full; + using String::String; - for (unsigned i = full_len - separator_len; i > 0; --i) - if (!strcmp(separator, full + i, separator_len)) - return full + i + separator_len; + Session_label last_element() const + { + 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' */ - inline Session_label prefixed_label(char const *prefix, char const *label) + template + inline Session_label prefixed_label(String const &prefix, + String const &label) { - if (!*prefix) - return Session_label(label); + if (!prefix.valid()) + return Session_label(label.string()); - if (!*label) - return Session_label(prefix); + if (!label.valid()) + return Session_label(prefix.string()); 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); } diff --git a/repos/base/include/rom_session/connection.h b/repos/base/include/rom_session/connection.h index 1fdc82682..db796ef37 100644 --- a/repos/base/include/rom_session/connection.h +++ b/repos/base/include/rom_session/connection.h @@ -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 * under the terms of the GNU General Public License version 2. @@ -16,7 +16,7 @@ #include #include -#include +#include namespace Genode { class Rom_connection; } @@ -30,15 +30,11 @@ class Genode::Rom_connection : public Connection, private: - Rom_session_capability _session(Parent &parent, - char const *module_name, - char const *label) + Rom_session_capability _session(Parent &parent, char const *label) { - try { - return session(parent, "ram_quota=4K, filename=\"%s\", label=\"%s\"", - module_name, label ? label: module_name); } + try { return session("ram_quota=4K, label=\"%s\"", label); } catch (...) { - PERR("Could not open ROM session for module \"%s\"", module_name); + error("Could not open ROM session for \"", label, "\""); throw Rom_connection_failed(); } } @@ -48,14 +44,13 @@ class Genode::Rom_connection : public Connection, /** * Constructor * - * \param module_name name of ROM module - * \param label initial session label + * \param label request label and name of ROM module * * \throw Rom_connection_failed */ - Rom_connection(Env &env, const char *module_name, const char *label = 0) + Rom_connection(Env &env, const char *label) : - Connection(env, _session(env.parent(), module_name, label)), + Connection(env, _session(env.parent(), label)), Rom_session_client(cap()) { } @@ -66,9 +61,9 @@ class Genode::Rom_connection : public Connection, * \deprecated Use the constructor with 'Env &' as first * argument instead */ - Rom_connection(const char *module_name, const char *label = 0) + Rom_connection(const char *label) : - Connection(_session(*env()->parent(), module_name, label)), + Connection(_session(*env()->parent(), label)), Rom_session_client(cap()) { } }; diff --git a/repos/base/src/core/include/rom_session_component.h b/repos/base/src/core/include/rom_session_component.h index bd66d5f51..b16c9b1ba 100644 --- a/repos/base/src/core/include/rom_session_component.h +++ b/repos/base/src/core/include/rom_session_component.h @@ -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 * under the terms of the GNU General Public License version 2. @@ -18,6 +18,7 @@ #include #include #include +#include namespace Genode { @@ -26,18 +27,17 @@ namespace Genode { private: Rom_module *_rom_module; - char _fname[40]; Dataspace_component _ds; Rpc_entrypoint *_ds_ep; Rom_dataspace_capability _ds_cap; Rom_module * _find_rom(Rom_fs *rom_fs, const char *args) { - /* extract filename from session arguments */ - Arg_string::find_arg(args, "filename").string(_fname, sizeof(_fname), ""); + /* extract label */ + Session_label const label = label_from_args(args); - /* find ROM module for file name */ - return rom_fs->find(_fname); + /* find ROM module for trailing label element */ + return rom_fs->find(label.last_element().string()); } public: @@ -48,8 +48,7 @@ namespace Genode { * \param rom_fs ROM filesystem * \param ds_ep entry point to manage the dataspace * corresponding the rom session - * \param args session-construction arguments, in - * particular the filename + * \param args session-construction arguments */ Rom_session_component(Rom_fs *rom_fs, Rpc_entrypoint *ds_ep, diff --git a/repos/demo/src/lib/launchpad/launchpad.cc b/repos/demo/src/lib/launchpad/launchpad.cc index dcba0f274..d0246f5b3 100644 --- a/repos/demo/src/lib/launchpad/launchpad.cc +++ b/repos/demo/src/lib/launchpad/launchpad.cc @@ -217,7 +217,8 @@ Launchpad_child *Launchpad::start_child(const char *filename, * constructor of 'Rom_connection' throws a 'Parent::Service_denied' * 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_cap = rom.cap(); file_cap = rom.dataspace(); diff --git a/repos/libports/run/ldso.run b/repos/libports/run/ldso.run index fe9154816..fac963a2f 100644 --- a/repos/libports/run/ldso.run +++ b/repos/libports/run/ldso.run @@ -80,7 +80,7 @@ compare_output_to { [init -> test-ldso] Catch exceptions in program [init -> test-ldso] --------------------------- [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] exception in program: caught [init -> test-ldso] exception in shared lib: caught diff --git a/repos/os/include/cli_monitor/child.h b/repos/os/include/cli_monitor/child.h index f9dad23f4..531051a00 100644 --- a/repos/os/include/cli_monitor/child.h +++ b/repos/os/include/cli_monitor/child.h @@ -21,6 +21,7 @@ #include #include #include +#include /* CLI-monitor includes */ #include @@ -38,15 +39,13 @@ class Child_base : public Genode::Child_policy class Quota_exceeded : public Genode::Exception { }; - typedef Genode::String<128> Label; - typedef Genode::size_t size_t; private: Ram &_ram; - Label const _label; + Genode::Session_label const _label; size_t _ram_quota; size_t _ram_limit; @@ -119,7 +118,8 @@ class Child_base : public Genode::Child_policy _ram_quota(ram_quota), _ram_limit(ram_limit), _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), _labeling_policy(_label.string()), _binary_policy("binary", _binary_rom.dataspace(), &_entrypoint), @@ -132,7 +132,7 @@ class Child_base : public Genode::Child_policy _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) { diff --git a/repos/os/include/init/child.h b/repos/os/include/init/child.h index 08c1e66f3..12109653d 100644 --- a/repos/os/include/init/child.h +++ b/repos/os/include/init/child.h @@ -561,7 +561,7 @@ class Init::Child : Genode::Child_policy affinity_space), _entrypoint(&cap_session, ENTRYPOINT_STACK_SIZE, _name.unique, false, _resources.affinity.location()), - _binary_rom(_name.file, _name.file), + _binary_rom(_name.file), _binary_rom_ds(_binary_rom.dataspace()), _config(_resources.ram.cap(), start_node), _server(_resources.ram.cap()), diff --git a/repos/os/include/init/child_policy.h b/repos/os/include/init/child_policy.h index 1c41e0f9e..ad5d662fe 100644 --- a/repos/os/include/init/child_policy.h +++ b/repos/os/include/init/child_policy.h @@ -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. @@ -21,6 +21,7 @@ #include #include #include +#include namespace Init { @@ -98,7 +99,8 @@ class Init::Child_policy_enforce_labeling if (old_label == "") { Arg_string::set_arg_string(args, args_len, "label", _name); } 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()); } } @@ -175,8 +177,7 @@ class Init::Child_policy_provide_rom_file Genode::Rpc_entrypoint *_ep; Genode::Rom_session_capability _rom_session_cap; - enum { FILENAME_MAX_LEN = 32 }; - char _filename[FILENAME_MAX_LEN]; + Genode::Session_label _module_name; struct Local_rom_service : public Genode::Service { @@ -212,16 +213,15 @@ class Init::Child_policy_provide_rom_file /** * Constructor */ - Child_policy_provide_rom_file(const char *filename, + Child_policy_provide_rom_file(const char *module_name, Genode::Dataspace_capability ds_cap, Genode::Rpc_entrypoint *ep) : _local_rom_session(ds_cap), _ep(ep), _rom_session_cap(_ep->manage(&_local_rom_session)), + _module_name(module_name), _local_rom_service(_rom_session_cap, ds_cap.valid()) - { - Genode::strncpy(_filename, filename, sizeof(_filename)); - } + { } /** * Destructor @@ -235,9 +235,11 @@ class Init::Child_policy_provide_rom_file if (Genode::strcmp(service_name, "ROM")) return 0; /* 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), ""); - return !Genode::strcmp(buf, _filename) ? &_local_rom_service : 0; + { + Genode::Session_label const label = Genode::label_from_args(args); + 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, char *args, Genode::size_t args_len) { + using namespace Genode; + if (!_from || !_to) return; /* ignore session requests for non-ROM services */ if (Genode::strcmp(service, "ROM")) return; - /* drop out if request refers to another file name */ - { - enum { FILENAME_MAX_LEN = 32 }; - char buf[FILENAME_MAX_LEN]; - Genode::Arg_string::find_arg(args, "filename").string(buf, sizeof(buf), ""); - if (Genode::strcmp(_from, buf) != 0) return; + /* drop out if request refers to another module name */ + Session_label const label = label_from_args(args); + Session_label const from(_from); + if (from != label.last_element()) return; - /* replace filename argument */ - Genode::snprintf(buf, sizeof(buf), "\"%s\"", _to); - Genode::Arg_string::set_arg(args, args_len, "filename", buf); - } + /* + * The module name corresponds to the last part of the label. + * 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 */ - enum { LABEL_MAX_LEN = 200 }; - 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; + Session_label const prefixed_to = + prefixed_label(prefix.valid() ? prefix : nullptr, to); - char buf[LABEL_MAX_LEN]; - Genode::snprintf(buf, sizeof(buf), "\"%s%s\"", label, _to); - Genode::Arg_string::set_arg(args, args_len, "label", buf); + Arg_string::set_arg_string(args, args_len, "label", prefixed_to.string()); } }; diff --git a/repos/os/include/os/child_policy_dynamic_rom.h b/repos/os/include/os/child_policy_dynamic_rom.h index 580107580..1e6ebc2d0 100644 --- a/repos/os/include/os/child_policy_dynamic_rom.h +++ b/repos/os/include/os/child_policy_dynamic_rom.h @@ -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 * 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, Rpc_entrypoint &_ep; Rom_session_capability _rom_session_cap; - enum { FILENAME_MAX_LEN = 32 }; - char _filename[FILENAME_MAX_LEN]; + Session_label _module_name; public: @@ -70,7 +69,7 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, * * 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, Ram_session *ram) : @@ -79,10 +78,9 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, _fg(0, 0), _bg(0, 0), _bg_has_pending_data(false), _ep(ep), - _rom_session_cap(_ep.manage(this)) - { - strncpy(_filename, filename, sizeof(_filename)); - } + _rom_session_cap(_ep.manage(this)), + _module_name(module_name) + { } /** * Destructor @@ -168,10 +166,9 @@ class Genode::Child_policy_dynamic_rom_file : public Rpc_object, /* ignore session requests for non-ROM services */ if (strcmp(service_name, "ROM")) return 0; - /* drop out if request refers to another file name */ - char buf[FILENAME_MAX_LEN]; - Arg_string::find_arg(args, "filename").string(buf, sizeof(buf), ""); - return !strcmp(buf, _filename) ? this : 0; + /* drop out if request refers to another module name */ + Session_label const label = label_from_args(args); + return _module_name == label.last_element() ? this : 0; } }; diff --git a/repos/os/include/os/slave.h b/repos/os/include/os/slave.h index c75940074..77c437f2a 100644 --- a/repos/os/include/os/slave.h +++ b/repos/os/include/os/slave.h @@ -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 * 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), _entrypoint(entrypoint), - _binary_rom(binary ? binary : _label, _label), + _binary_rom(binary ? prefixed_label(Session_label(label), + Session_label(binary)).string() : label), _labeling_policy(_label), _binary_policy("binary", _binary_rom.dataspace(), &_entrypoint), _config_policy("config", _entrypoint, ram) diff --git a/repos/os/src/server/dynamic_rom/main.cc b/repos/os/src/server/dynamic_rom/main.cc index 509ecf7ac..0ae9161ae 100644 --- a/repos/os/src/server/dynamic_rom/main.cc +++ b/repos/os/src/server/dynamic_rom/main.cc @@ -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 #include #include +#include +#include namespace Dynamic_rom { @@ -202,13 +204,13 @@ class Dynamic_rom::Root : public Genode::Root_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 *_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(); } } diff --git a/repos/os/src/server/fs_rom/main.cc b/repos/os/src/server/fs_rom/main.cc index 7a634cd8a..b03b9254d 100755 --- a/repos/os/src/server/fs_rom/main.cc +++ b/repos/os/src/server/fs_rom/main.cc @@ -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 #include #include -#include #include +#include +#include using namespace Genode; @@ -99,7 +100,7 @@ class Rom_session_component : public Genode::Rpc_object { 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 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 _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 *_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: diff --git a/repos/os/src/server/iso9660/main.cc b/repos/os/src/server/iso9660/main.cc index 6d8d387e1..847585001 100644 --- a/repos/os/src/server/iso9660/main.cc +++ b/repos/os/src/server/iso9660/main.cc @@ -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 #include #include -#inlcude +#include /* 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)); diff --git a/repos/os/src/server/loader/child.h b/repos/os/src/server/loader/child.h index 17ca98dfb..d1cde55dd 100644 --- a/repos/os/src/server/loader/child.h +++ b/repos/os/src/server/loader/child.h @@ -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(_local_rom_service.session(args, Affinity())); } catch (Genode::Parent::Service_denied) { PERR("Lookup for ROM module \"%s\" failed", name); diff --git a/repos/os/src/server/loader/main.cc b/repos/os/src/server/loader/main.cc index 5d9fa6687..8a9329874 100644 --- a/repos/os/src/server/loader/main.cc +++ b/repos/os/src/server/loader/main.cc @@ -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 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); diff --git a/repos/os/src/server/log_report/main.cc b/repos/os/src/server/log_report/main.cc index 4200859e7..15b32d3b9 100644 --- a/repos/os/src/server/log_report/main.cc +++ b/repos/os/src/server/log_report/main.cc @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -32,19 +33,15 @@ namespace Report { class Report::Session_component : public Genode::Rpc_object { - 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 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: diff --git a/repos/os/src/server/rom_prefetcher/main.cc b/repos/os/src/server/rom_prefetcher/main.cc index 9fecf2baf..00ba310a0 100644 --- a/repos/os/src/server/rom_prefetcher/main.cc +++ b/repos/os/src/server/rom_prefetcher/main.cc @@ -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 #include #include +#include volatile int dummy; @@ -78,12 +79,12 @@ class Rom_root : public Genode::Root_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: diff --git a/repos/os/src/server/tar_rom/main.cc b/repos/os/src/server/tar_rom/main.cc index 61e9468d7..646b2fa02 100755 --- a/repos/os/src/server/tar_rom/main.cc +++ b/repos/os/src/server/tar_rom/main.cc @@ -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 #include #include +#include /** @@ -180,14 +181,16 @@ class Rom_root : public Genode::Root_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: diff --git a/repos/os/src/test/bomb/main.cc b/repos/os/src/test/bomb/main.cc index a8da82b68..35b4e606d 100644 --- a/repos/os/src/test/bomb/main.cc +++ b/repos/os/src/test/bomb/main.cc @@ -38,6 +38,8 @@ class Bomb_child_resources { protected: + Genode::Session_label _rom_label; + Genode::Pd_connection _pd; Genode::Rom_connection _rom; Genode::Ram_connection _ram; @@ -48,10 +50,13 @@ class Bomb_child_resources 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) : - _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()); Genode::env()->ram_session()->transfer_quota(_ram.cap(), ram_quota); diff --git a/repos/ports/lib/mk/spec/hw_x86_64_muen/virtualbox-hwaccl.mk b/repos/ports/lib/mk/spec/hw_x86_64_muen/virtualbox-hwaccl.mk index 15717bfad..31a2df9d1 100644 --- a/repos/ports/lib/mk/spec/hw_x86_64_muen/virtualbox-hwaccl.mk +++ b/repos/ports/lib/mk/spec/hw_x86_64_muen/virtualbox-hwaccl.mk @@ -1,5 +1,11 @@ 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 SRC_CC = pgm.cc sup.cc diff --git a/repos/ports/lib/mk/spec/nova/virtualbox-hwaccl.mk b/repos/ports/lib/mk/spec/nova/virtualbox-hwaccl.mk index a924bc8f7..743188eb1 100644 --- a/repos/ports/lib/mk/spec/nova/virtualbox-hwaccl.mk +++ b/repos/ports/lib/mk/spec/nova/virtualbox-hwaccl.mk @@ -1,5 +1,11 @@ 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 SRC_CC = sup.cc pgm.cc diff --git a/repos/ports/lib/mk/virtualbox-main.mk b/repos/ports/lib/mk/virtualbox-main.mk index b67f27fd6..32d297698 100644 --- a/repos/ports/lib/mk/virtualbox-main.mk +++ b/repos/ports/lib/mk/virtualbox-main.mk @@ -2,6 +2,12 @@ include $(REP_DIR)/lib/mk/virtualbox-common.inc 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 SRC_CC += Main/xml/Settings.cpp diff --git a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc index 2b6f9a3b5..fb42fe828 100644 --- a/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc +++ b/repos/ports/src/app/gdb_monitor/gdbserver/genode-low.cc @@ -321,7 +321,8 @@ extern "C" int fork() char *unique_name = filename; Capability file_cap; 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(); } catch (Rom_connection::Rom_connection_failed) { Genode::printf("Error: Could not access file \"%s\" from ROM service.\n", filename); diff --git a/repos/ports/src/app/gdb_monitor/rom.h b/repos/ports/src/app/gdb_monitor/rom.h index 1a489aada..c47b316df 100644 --- a/repos/ports/src/app/gdb_monitor/rom.h +++ b/repos/ports/src/app/gdb_monitor/rom.h @@ -93,11 +93,10 @@ class Gdb_monitor::Rom_root : public Root_component Rom_session_component *_create_session(char const *args) { - enum { FILENAME_MAX_LEN = 128 }; - char filename[FILENAME_MAX_LEN]; - Arg_string::find_arg(args, "filename").string(filename, sizeof(filename), ""); + Session_label const label = label_from_args(args); - return new (md_alloc()) Rom_session_component(filename); + return new (md_alloc()) + Rom_session_component(label.last_element().string()); } public: diff --git a/repos/ports/src/noux/local_rom_service.h b/repos/ports/src/noux/local_rom_service.h index 4a1836724..45efcc91a 100644 --- a/repos/ports/src/noux/local_rom_service.h +++ b/repos/ports/src/noux/local_rom_service.h @@ -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 * 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 &) { - enum { NAME_MAX_LEN = 128 }; - char name[NAME_MAX_LEN]; - Arg_string::find_arg(args, "filename").string(name, sizeof(name), ""); + Session_label const label = label_from_args(args); try { + Genode::Session_label const module_name = label.last_element(); 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); } catch (Rom_connection::Rom_connection_failed) { diff --git a/repos/ports/src/virtualbox/frontend/console.cc b/repos/ports/src/virtualbox/frontend/console.cc index 429e9e457..ff37eb910 100644 --- a/repos/ports/src/virtualbox/frontend/console.cc +++ b/repos/ports/src/virtualbox/frontend/console.cc @@ -12,6 +12,7 @@ */ #include +#include #include #include diff --git a/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc b/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc index b0f90a81c..6e4e7d726 100644 --- a/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc +++ b/repos/ports/src/virtualbox/frontend/dummy/virtualboxbase.cc @@ -1,4 +1,5 @@ #include +#include #include "VirtualBoxImpl.h" #include "VBox/com/MultiResult.h"