From fcf25c22d1cb1a8e6b829360ffcf3367e3b88b6a Mon Sep 17 00:00:00 2001 From: Norman Feske Date: Thu, 2 Mar 2017 13:19:14 +0100 Subject: [PATCH] init: respond to binary-name changes This patch covers the resolution of the ROM route for child binaries via the generic label-rewriting mechanics. Now, the node has become merely sytactic sugar for a route like the following: ... ... A change of the binary name has an effect on the child's ROM route to the binary and thereby implicitly triggers a child restart due to the existing re-validation of the routing. --- repos/os/include/init/child.h | 25 +++++++++++- repos/os/run/init.run | 76 +++++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+), 2 deletions(-) diff --git a/repos/os/include/init/child.h b/repos/os/include/init/child.h index d10d599df..418b0e415 100644 --- a/repos/os/include/init/child.h +++ b/repos/os/include/init/child.h @@ -478,7 +478,8 @@ class Init::Child : Child_policy, Child_service::Wakeup return start_node.sub_node("binary").attribute_value("name", Name()); } - Binary_name const _binary_name; + /* updated on configuration update */ + Binary_name _binary_name; struct Read_quota { @@ -840,6 +841,13 @@ class Init::Child : Child_policy, Child_service::Wakeup config_update = CONFIG_CHANGED; } + /* + * Import new binary name. A change may affect the route for + * the binary's ROM session, triggering the restart of the + * child. + */ + _binary_name = _binary_name_from_xml(start_node, _unique_name); + /* import new start node */ _start_node.construct(_alloc, start_node); } @@ -924,7 +932,7 @@ class Init::Child : Child_policy, Child_service::Wakeup Child_policy::Name name() const override { return _unique_name; } - Binary_name binary_name() const override { return _binary_name; } + Binary_name binary_name() const override { return _unique_name; } Ram_session &ref_ram() override { return _env.ram(); } Ram_session_capability ref_ram_cap() const override { return _env.ram_session_cap(); } @@ -1002,6 +1010,19 @@ class Init::Child : Child_policy, Child_service::Wakeup */ } + /* + * Check for the binary's ROM request + * + * The binary is requested as a ROM with the child's unique + * name ('Child_policy::binary_name' equals 'Child_policy::name'). + * If the binary name differs from the child's unique name, + * we resolve the session request with the binary name as label. + * Otherwise the regular routing is applied. + */ + if (service_name == Rom_session::service_name() && + label == _unique_name && _unique_name != _binary_name) + return resolve_session_request(service_name, _binary_name); + /* check for "session_requests" ROM request */ if (service_name == Rom_session::service_name() && label.last_element() == Session_requester::rom_name()) diff --git a/repos/os/run/init.run b/repos/os/run/init.run index 7fe3e0696..5a8d2b93d 100644 --- a/repos/os/run/init.run +++ b/repos/os/run/init.run @@ -235,7 +235,78 @@ append config { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -286,6 +357,11 @@ append config { + + + + +