diff --git a/nixos-modules/store-wrapper.dhall b/nixos-modules/store-wrapper.dhall index 6b5cb2d..02391cd 100644 --- a/nixos-modules/store-wrapper.dhall +++ b/nixos-modules/store-wrapper.dhall @@ -12,44 +12,6 @@ let TextMapType = Prelude.Map.Type Text let Manifest/Type = TextMapType (TextMapType Text) -let storeServiceRoute = - { service = - { name = "ROM", label = Init.LabelSelector.prefix "/nix/store/" } - , route = - Init.Route.Type.Parent - { prefix = Some "", suffix = None Text, diag = Some True } - } - -let withStoreRoute = - λ(attrs : Child.Attributes.Type) → - attrs - with routes = attrs.routes # [ storeServiceRoute ] - -let Child/withStoreRoutes - : Child.Type → Child.Type - = λ(child : Child.Type) → - child - Child.Type - { flat = - λ(attrs : Child.Attributes.Type) → - Child.flat (withStoreRoute attrs) - , nested = - λ(children : Prelude.Map.Type Text Child.Type) → - λ(attrs : Child.Attributes.Type) → - Child.nested children (withStoreRoute attrs) - } - -let Init/withStoreRoutes = - λ(init : Init.Type) → - init - with children = - Prelude.Map.map - Text - Child.Type - Child.Type - Child/withStoreRoutes - init.children - in λ(subinit : Init.Type) → λ(storeName : Text) → λ(storeSize : Natural) → @@ -168,7 +130,7 @@ in λ(subinit : Init.Type) → , child "nixos" ( Init.toChild - (Init/withStoreRoutes subinit) + subinit Init.Attributes::{ , exitPropagate = True , resources = Init.Resources::{ diff --git a/packages/genodelabs/cached_fs_rom.patch b/packages/genodelabs/cached_fs_rom.patch index 4461bec..959f14b 100644 --- a/packages/genodelabs/cached_fs_rom.patch +++ b/packages/genodelabs/cached_fs_rom.patch @@ -1,7 +1,7 @@ -From 3ff27b172afd3ee436f9cce754c15d5913f0cb86 Mon Sep 17 00:00:00 2001 +From e65583c3e9cf0e9c326bb2d414d40fa32f64f9c6 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 3 Nov 2020 15:28:56 +0100 -Subject: [PATCH 1/2] cached_fs_rom: resolve symlinks +Subject: [PATCH 1/3] cached_fs_rom: resolve symlinks Follow symlinks from ROM requests to files. This complicates the implementation but allows ROM requests to be redirected at both the @@ -9,11 +9,11 @@ label routing and the file-system layers. Redirecting ROMs with symlinks is useful for retrieving ROMs from deeply nested or otherwise excessively long file-system paths. --- - repos/os/src/server/cached_fs_rom/main.cc | 469 +++++++++++++--------- - 1 file changed, 278 insertions(+), 191 deletions(-) + repos/os/src/server/cached_fs_rom/main.cc | 472 +++++++++++++--------- + 1 file changed, 281 insertions(+), 191 deletions(-) diff --git a/repos/os/src/server/cached_fs_rom/main.cc b/repos/os/src/server/cached_fs_rom/main.cc -index 9e4e4d0eee..5f2aea63f5 100755 +index 9e4e4d0eee..bac2c075a9 100755 --- a/repos/os/src/server/cached_fs_rom/main.cc +++ b/repos/os/src/server/cached_fs_rom/main.cc @@ -5,7 +5,7 @@ @@ -534,7 +534,7 @@ index 9e4e4d0eee..5f2aea63f5 100755 catch (Permission_denied) { error(file_path, ": permission denied"); } catch (...) { error(file_path, ": unhandled error"); } throw Service_denied(); -@@ -364,55 +444,55 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler +@@ -364,55 +444,58 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler ** Find ROM in cache ** ***********************/ @@ -592,6 +592,9 @@ index 9e4e4d0eee..5f2aea63f5 100755 + + if (pending) /* wait until transfer completes */ + return; ++ ++ if (diag) ++ log("lookup \"", path, "\" for \"", label, "\""); + /* initiate new transfer or throw Service_denied */ + try_transfer(path, [&] () { @@ -619,7 +622,7 @@ index 9e4e4d0eee..5f2aea63f5 100755 void handle_session_close(Parent::Server::Id pid) override { Session_space::Id id { pid.value }; -@@ -425,6 +505,9 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler +@@ -425,6 +508,9 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler }); } @@ -629,7 +632,7 @@ index 9e4e4d0eee..5f2aea63f5 100755 void handle_packets() { Tx_source &source = *fs.tx(); -@@ -439,12 +522,16 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler +@@ -439,12 +525,16 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler transfers.apply( Transfer_space::Id{pkt.handle().value}, [&] (Transfer &transfer) { @@ -654,10 +657,10 @@ index 9e4e4d0eee..5f2aea63f5 100755 2.28.0 -From 4bff3638684e807a79a24e81bf59913849c9c100 Mon Sep 17 00:00:00 2001 +From 8e994fdb882071d224b1bb2b6efc711571b523f0 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Tue, 3 Nov 2020 17:37:50 +0100 -Subject: [PATCH 2/2] cached_fs_rom: add directory session policy +Subject: [PATCH 2/3] cached_fs_rom: add directory session policy Support for directing ROM requests into directories by policy. --- @@ -686,7 +689,7 @@ index 0000000000..855c20ba7c +! +! diff --git a/repos/os/src/server/cached_fs_rom/main.cc b/repos/os/src/server/cached_fs_rom/main.cc -index 5f2aea63f5..59dc2c7d98 100755 +index bac2c075a9..8df3001111 100755 --- a/repos/os/src/server/cached_fs_rom/main.cc +++ b/repos/os/src/server/cached_fs_rom/main.cc @@ -13,6 +13,7 @@ @@ -734,3 +737,47 @@ index 5f2aea63f5..59dc2c7d98 100755 -- 2.28.0 + +From c98ba6fd70938804833e5c65a18d01c60f5be17f Mon Sep 17 00:00:00 2001 +From: Emery Hemingway +Date: Thu, 5 Nov 2020 21:22:31 +0100 +Subject: [PATCH 3/3] cached_fs_rom: do not apply directory for absolute ROMs + +If the ROM name starts with / then do not apply a directory policy. +--- + repos/os/src/server/cached_fs_rom/main.cc | 15 ++++++++------- + 1 file changed, 8 insertions(+), 7 deletions(-) + +diff --git a/repos/os/src/server/cached_fs_rom/main.cc b/repos/os/src/server/cached_fs_rom/main.cc +index 8df3001111..4479b41e87 100755 +--- a/repos/os/src/server/cached_fs_rom/main.cc ++++ b/repos/os/src/server/cached_fs_rom/main.cc +@@ -450,17 +450,18 @@ struct Cached_fs_rom::Main final : Genode::Session_request_handler + ** Find ROM in cache ** + ***********************/ + ++ Path path; + +- Path path("/"); +- Session_label const label = label_from_args(args.string()); ++ auto const label = label_from_args(args.string()); ++ auto const rom_name = label.last_element(); + + try { + Session_policy policy(label, config_rom.xml()); +- path.append(policy.attribute_value( +- "directory", String("/")).string()); +- } catch (Service_denied) { } +- +- path.append_element(label.last_element().string()); ++ auto dir = policy.attribute_value("directory", String("/")); ++ path = Path(rom_name.string(), dir.string()); ++ } catch (Service_denied) { ++ path = Path(rom_name.string()); ++ } + + bool diag = session_diag_from_args(args.string()).enabled; + +-- +2.28.0 +