noux: remove use of deprecated APIs

Issue #1987
This commit is contained in:
Norman Feske 2019-01-21 09:27:19 +01:00
parent d7e552a169
commit 98a75b1a78
7 changed files with 73 additions and 71 deletions

View File

@ -31,16 +31,6 @@ struct Noux::Connection : Genode::Connection<Session>, Session_client
Session_client(cap())
{ }
/**
* Constructor
*
* \noapi
* \deprecated Use the constructor with 'Env &' as first
* argument instead
*/
Connection() __attribute__((deprecated))
: Genode::Connection<Session>(session("")), Session_client(cap()) { }
/**
* Remove session ID of the noux session from the ID space.
*

View File

@ -564,7 +564,7 @@ static void * in_stack_area;
static jmp_buf fork_jmp_buf;
static Genode::Capability<Genode::Parent>::Raw new_parent;
extern "C" void stdout_reconnect(); /* provided by 'log_console.cc' */
extern "C" void stdout_reconnect(Genode::Parent &); /* provided by 'default_log.cc' */
/*
@ -577,7 +577,7 @@ extern "C" void fork_trampoline()
_env_ptr->reinit(new_parent);
/* reinitialize standard-output connection */
stdout_reconnect();
stdout_reconnect(_env_ptr->parent());
/* reinitialize noux connection */
noux_connection()->reconnect();

View File

@ -90,7 +90,7 @@ class Noux::Child_env
char const *args,
Vfs::File_system &root_dir,
Vfs_io_waiter_registry &vfs_io_waiter_registry,
Ram_session &ram,
Ram_allocator &ram,
Region_map &rm,
Allocator &alloc)
{
@ -212,7 +212,7 @@ class Noux::Child_env
char const *args, Sysio::Env env,
Vfs::File_system &root_dir,
Vfs_io_waiter_registry &vfs_io_waiter_registry,
Ram_session &ram,
Ram_allocator &ram,
Region_map &rm,
Allocator &alloc)
{

View File

@ -78,6 +78,45 @@ class Noux::Child_policy : public Genode::Child_policy
return service;
}
/**
* Find suitable service for a given session request
*
* \throw Service_denied
*/
Service &_matching_service(Service::Name const &service_name,
Session_label const &label)
{
/*
* Route initial ROM requests (binary and linker) of a forked child
* to the empty ROM service, since the ROMs are already attached in
* the replayed region map.
*/
if (_forked && (service_name == Genode::Rom_session::service_name())) {
if (label.last_element() == name()) return _empty_rom_service;
if (label.last_element() == linker_name()) return _empty_rom_service;
}
Genode::Service *service = nullptr;
/* check for local ROM requests */
if ((service = _args_policy .resolve_session_request_with_label(service_name, label))
|| (service = _env_policy .resolve_session_request_with_label(service_name, label))
|| (service = _config_policy.resolve_session_request_with_label(service_name, label)))
return *service;
/* check for local services */
if (service_name == Genode::Cpu_session::service_name()) return _cpu_service;
if (service_name == Genode::Rom_session::service_name()) return _rom_service;
if (service_name == Genode::Pd_session::service_name()) return _pd_service;
if (service_name == Noux::Session::service_name()) return _noux_service;
/* check for parent services */
if ((service = _find_service(_parent_services, service_name)))
return *service;
throw Service_denied();
}
public:
Child_policy(Name const &name,
@ -135,40 +174,12 @@ class Noux::Child_policy : public Genode::Child_policy
session.ref_account(_ref_pd_cap);
}
Service &resolve_session_request(Service::Name const &service_name,
Session_state::Args const &args) override
Route resolve_session_request(Service::Name const &service_name,
Session_label const &label) override
{
Session_label const label(Genode::label_from_args(args.string()));
/*
* Route initial ROM requests (binary and linker) of a forked child
* to the empty ROM service, since the ROMs are already attached in
* the replayed region map.
*/
if (_forked && (service_name == Genode::Rom_session::service_name())) {
if (label.last_element() == name()) return _empty_rom_service;
if (label.last_element() == linker_name()) return _empty_rom_service;
}
Genode::Service *service = nullptr;
/* check for local ROM requests */
if ((service = _args_policy .resolve_session_request(service_name.string(), args.string()))
|| (service = _env_policy .resolve_session_request(service_name.string(), args.string()))
|| (service = _config_policy.resolve_session_request(service_name.string(), args.string())))
return *service;
/* check for local services */
if (service_name == Genode::Cpu_session::service_name()) return _cpu_service;
if (service_name == Genode::Rom_session::service_name()) return _rom_service;
if (service_name == Genode::Pd_session::service_name()) return _pd_service;
if (service_name == Noux::Session::service_name()) return _noux_service;
/* check for parent services */
if ((service = _find_service(_parent_services, service_name)))
return *service;
throw Service_denied();
return Route { .service = _matching_service(service_name, label),
.label = label,
.diag = Session::Diag() };
}
void exit(int exit_value) override

View File

@ -59,23 +59,24 @@ static Noux::Sysio::Env &env_string_of_init_process(Genode::Xml_node config)
/* read environment variables for init process from config */
Genode::Xml_node start_node = config.sub_node("start");
try {
Genode::Xml_node arg_node = start_node.sub_node("env");
for (; ; arg_node = arg_node.next("env")) {
static char name_buf[256], value_buf[256];
Genode::Xml_node node = start_node.sub_node("env");
for (; ; node = node.next("env")) {
arg_node.attribute("name").value(name_buf, sizeof(name_buf));
arg_node.attribute("value").value(value_buf, sizeof(value_buf));
typedef Genode::String<256> Var;
Var const var(node.attribute_value("name", Var()), "=",
node.attribute_value("value", Var()));
Genode::size_t env_var_size = Genode::strlen(name_buf) +
Genode::strlen("=") +
Genode::strlen(value_buf) + 1;
if (index + env_var_size < sizeof(env)) {
Genode::snprintf(&env[index], env_var_size, "%s=%s", name_buf, value_buf);
index += env_var_size;
} else {
bool const env_exeeded = index + var.length() >= sizeof(env);
bool const var_exeeded = (var.length() == var.capacity());
if (env_exeeded || var_exeeded) {
warning("truncated environment variable: ", node);
env[index] = 0;
break;
}
Genode::strncpy(&env[index], var.string(), var.length());
index += var.length();
}
}
catch (Genode::Xml_node::Nonexistent_sub_node) { }
@ -171,8 +172,8 @@ struct Noux::Main
/* whitelist of service requests to be routed to the parent */
Noux::Parent_services _parent_services { };
Noux::Parent_service _log_parent_service { _parent_services, "LOG" };
Noux::Parent_service _timer_parent_service { _parent_services, "Timer" };
Noux::Parent_service _log_parent_service { _parent_services, _env, "LOG" };
Noux::Parent_service _timer_parent_service { _parent_services, _env, "Timer" };
Attached_rom_dataspace _config { _env, "config" };

View File

@ -124,7 +124,7 @@ class Noux::Pd_session_component : public Rpc_object<Pd_session>
enum { NUM_ATTEMPTS = 3 };
return retry<Out_of_caps>(
[&] () { return func(); },
[&] () { _ref_pd.transfer_quota(_pd, upgrade); },
[&] () { _ref_pd.transfer_quota(_pd.rpc_cap(), upgrade); },
NUM_ATTEMPTS);
}
@ -151,7 +151,7 @@ class Noux::Pd_session_component : public Rpc_object<Pd_session>
* via '_with_automatic_cap_upgrade'.
*/
_pd.ref_account(env.pd_session_cap());
_ref_pd.transfer_quota(_pd, Cap_quota{10});
_ref_pd.transfer_quota(_pd.rpc_cap(), Cap_quota{10});
}
~Pd_session_component()

View File

@ -35,14 +35,13 @@ namespace Noux {
struct Noux::Vfs_dataspace
{
typedef Child_policy::Name Name;
Name const name;
Vfs::File_system &root_dir;
Vfs_io_waiter_registry &vfs_io_waiter_registry;
Name const name;
Genode::Ram_session &ram;
Genode::Region_map &rm;
Genode::Allocator &alloc;
Genode::Ram_allocator &ram;
Genode::Region_map &rm;
Genode::Allocator &alloc;
Dataspace_capability ds { };
bool got_ds_from_vfs { true };
@ -50,11 +49,12 @@ struct Noux::Vfs_dataspace
Vfs_dataspace(Vfs::File_system &root_dir,
Vfs_io_waiter_registry &vfs_io_waiter_registry,
Name const &name,
Genode::Ram_session &ram, Genode::Region_map &rm,
Genode::Allocator &alloc)
Genode::Ram_allocator &ram, Genode::Region_map &rm,
Genode::Allocator &alloc)
:
name(name),
root_dir(root_dir), vfs_io_waiter_registry(vfs_io_waiter_registry),
name(name), ram(ram), rm(rm), alloc(alloc)
ram(ram), rm(rm), alloc(alloc)
{
ds = root_dir.dataspace(name.string());