~ehmry/sigil

7e1bb6425f1a8e4f707cf1a362f891f779752802 — Emery Hemingway 1 year, 9 months ago 9c23c59
vfs: patch for loading plugins by label, long tar names
1 files changed, 100 insertions(+), 2 deletions(-)

M packages/genodelabs/patches/vfs.patch
M packages/genodelabs/patches/vfs.patch => packages/genodelabs/patches/vfs.patch +100 -2
@@ 1,7 1,8 @@
From a3063497d9aaf6bf06a3797804135105ad5f3bad Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Thu, 3 Dec 2020 12:19:10 +0100
Subject: [PATCH] vfs: create missing root directories for writeable sessions
Subject: [PATCH 1/3] vfs: create missing root directories for writeable
 sessions

This is the expected behavior.
---


@@ 74,5 75,102 @@ index b780b1fdd7..358afd28a9 100644
 
 			Session_component *session = new (md_alloc())
-- 
2.29.2
2.30.0


From 0c91101db93422a4ff0aa2407b0ac7610abcf14f Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 15:20:39 +0100
Subject: [PATCH 2/3] vfs: support for loading plugins by label
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Make the VFS plugin recognize <plugin label="…"/> nodes.
---
 repos/os/src/lib/vfs/file_system_factory.cc | 33 ++++++++++++++++-----
 1 file changed, 26 insertions(+), 7 deletions(-)

diff --git a/repos/os/src/lib/vfs/file_system_factory.cc b/repos/os/src/lib/vfs/file_system_factory.cc
index 5cdf20e8e3..1cf5d587ea 100644
--- a/repos/os/src/lib/vfs/file_system_factory.cc
+++ b/repos/os/src/lib/vfs/file_system_factory.cc
@@ -56,8 +56,16 @@ struct Vfs::Global_file_system_factory::Entry_base : Vfs::File_system_factory,
 
 	Entry_base(Fs_type_name const &name) : name(name) { }
 
-	bool matches(Genode::Xml_node node) const {
-		return node.has_type(name.string()); }
+	bool matches(Genode::Xml_node node) const
+	{
+		if (node.has_type(name.string()))
+			return true;
+
+		if (node.has_type("plugin") && node.has_attribute("load"))
+			return node.attribute("load").has_value(name.string());
+
+		return false;
+	}
 };
 
 
@@ -165,14 +173,25 @@ Vfs::File_system_factory &Vfs::Global_file_system_factory::_load_factory(Vfs::En
 bool Vfs::Global_file_system_factory::_probe_external_factory(Vfs::Env &env,
                                                               Genode::Xml_node node)
 {
-	Library_name const lib_name = _library_name(node.type());
-
 	try {
-		_list.insert(new (env.alloc())
-			External_entry(node.type().string(), _load_factory(env, lib_name)));
-		return true;
+		if (node.has_type("plugin")) {
+			Library_name const lib_name = node.attribute_value("load", Library_name(""));
+
+			if (lib_name == "") {
+				error("missing \"load\" attribute at ", node);
+				return false;
+			}
 
+			_list.insert(new (env.alloc())
+				External_entry(lib_name.string(), _load_factory(env, lib_name)));
+		} else {
+			Library_name const lib_name = _library_name(node.type());
+
+			_list.insert(new (env.alloc())
+				External_entry(node.type().string(), _load_factory(env, lib_name)));
+		}
 	} catch (Factory_not_available) { return false; }
+	return true;
 }
 
 
-- 
2.30.0


From d2b15cb52415d18b9611862d9d184effc596bba6 Mon Sep 17 00:00:00 2001
From: Emery Hemingway <ehmry@posteo.net>
Date: Wed, 3 Feb 2021 17:33:24 +0100
Subject: [PATCH 3/3] vfs: increase the capacity of tar ROM labels to 128

---
 repos/os/src/lib/vfs/tar_file_system.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/repos/os/src/lib/vfs/tar_file_system.h b/repos/os/src/lib/vfs/tar_file_system.h
index d9941deb5f..fcb06a1459 100644
--- a/repos/os/src/lib/vfs/tar_file_system.h
+++ b/repos/os/src/lib/vfs/tar_file_system.h
@@ -27,7 +27,7 @@ class Vfs::Tar_file_system : public File_system
 	Genode::Env       &_env;
 	Genode::Allocator &_alloc;
 
-	typedef Genode::String<64> Rom_name;
+	typedef Genode::String<128> Rom_name;
 	Rom_name _rom_name;
 
 	Genode::Attached_rom_dataspace _tar_ds { _env, _rom_name.string() };
-- 
2.30.0