mirror of
https://github.com/genodelabs/genode.git
synced 2025-03-06 06:02:13 +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:
parent
f8337b511b
commit
2b8c1af9e0
@ -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 <linux_dataspace/linux_dataspace.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <root/root.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
/* 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;
|
||||
|
@ -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<capacity()> String;
|
||||
private:
|
||||
|
||||
using String::String;
|
||||
typedef String<capacity()> 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 <size_t N1, size_t N2>
|
||||
inline Session_label prefixed_label(String<N1> const &prefix,
|
||||
String<N2> 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);
|
||||
}
|
||||
|
@ -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 <rom_session/client.h>
|
||||
#include <base/connection.h>
|
||||
#include <base/printf.h>
|
||||
#include <base/log.h>
|
||||
|
||||
namespace Genode { class Rom_connection; }
|
||||
|
||||
@ -30,15 +30,11 @@ class Genode::Rom_connection : public Connection<Rom_session>,
|
||||
|
||||
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<Rom_session>,
|
||||
/**
|
||||
* 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<Rom_session>(env, _session(env.parent(), module_name, label)),
|
||||
Connection<Rom_session>(env, _session(env.parent(), label)),
|
||||
Rom_session_client(cap())
|
||||
{ }
|
||||
|
||||
@ -66,9 +61,9 @@ class Genode::Rom_connection : public Connection<Rom_session>,
|
||||
* \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<Rom_session>(_session(*env()->parent(), module_name, label)),
|
||||
Connection<Rom_session>(_session(*env()->parent(), label)),
|
||||
Rom_session_client(cap())
|
||||
{ }
|
||||
};
|
||||
|
@ -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 <base/rpc_server.h>
|
||||
#include <dataspace_component.h>
|
||||
#include <rom_session/rom_session.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
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,
|
||||
|
@ -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();
|
||||
|
@ -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
|
||||
|
@ -21,6 +21,7 @@
|
||||
#include <os/child_policy_dynamic_rom.h>
|
||||
#include <cpu_session/connection.h>
|
||||
#include <pd_session/connection.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
/* CLI-monitor includes */
|
||||
#include <cli_monitor/ram.h>
|
||||
@ -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)
|
||||
{
|
||||
|
@ -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()),
|
||||
|
@ -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 <base/session_label.h>
|
||||
#include <util/arg_string.h>
|
||||
#include <rom_session/connection.h>
|
||||
#include <base/session_label.h>
|
||||
|
||||
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());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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<Rom_session>,
|
||||
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<Rom_session>,
|
||||
*
|
||||
* 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<Rom_session>,
|
||||
_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<Rom_session>,
|
||||
/* 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;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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:
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
@ -321,7 +321,8 @@ extern "C" int fork()
|
||||
char *unique_name = filename;
|
||||
Capability<Rom_dataspace> 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);
|
||||
|
@ -93,11 +93,10 @@ class Gdb_monitor::Rom_root : public Root_component<Rom_session_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:
|
||||
|
@ -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), "<noname>");
|
||||
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) {
|
||||
|
@ -12,6 +12,7 @@
|
||||
*/
|
||||
|
||||
#include <base/printf.h>
|
||||
#include <base/log.h>
|
||||
#include <util/xml_node.h>
|
||||
|
||||
#include <VBox/settings.h>
|
||||
|
@ -1,4 +1,5 @@
|
||||
#include <base/printf.h>
|
||||
#include <base/log.h>
|
||||
|
||||
#include "VirtualBoxImpl.h"
|
||||
#include "VBox/com/MultiResult.h"
|
||||
|
Loading…
x
Reference in New Issue
Block a user