diff --git a/repos/libports/run/fs_rom_update_fat.run b/repos/libports/run/fs_rom_update_fat.run
index 8519cff34d..a009d2863e 100644
--- a/repos/libports/run/fs_rom_update_fat.run
+++ b/repos/libports/run/fs_rom_update_fat.run
@@ -93,7 +93,9 @@ append config {
-
+
+
+
diff --git a/repos/os/recipes/pkg/test-fs_rom_update/runtime b/repos/os/recipes/pkg/test-fs_rom_update/runtime
index 8166ab66d4..51249f1691 100644
--- a/repos/os/recipes/pkg/test-fs_rom_update/runtime
+++ b/repos/os/recipes/pkg/test-fs_rom_update/runtime
@@ -69,7 +69,9 @@
-
+
+
+
diff --git a/repos/os/recipes/pkg/test-fs_rom_update_fs/runtime b/repos/os/recipes/pkg/test-fs_rom_update_fs/runtime
index c9aba97838..7ba3242bb6 100644
--- a/repos/os/recipes/pkg/test-fs_rom_update_fs/runtime
+++ b/repos/os/recipes/pkg/test-fs_rom_update_fs/runtime
@@ -4,7 +4,7 @@
- <config iteration="4" />
+ <config iteration="4"/>
@@ -63,27 +63,29 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
diff --git a/repos/os/recipes/pkg/test-fs_rom_update_ram/runtime b/repos/os/recipes/pkg/test-fs_rom_update_ram/runtime
index e31eccc1f6..f4046e0bd0 100644
--- a/repos/os/recipes/pkg/test-fs_rom_update_ram/runtime
+++ b/repos/os/recipes/pkg/test-fs_rom_update_ram/runtime
@@ -4,7 +4,7 @@
- <config iteration="4" />
+ <config iteration="4"/>
@@ -48,27 +48,29 @@
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
+
+
diff --git a/repos/os/recipes/src/rom_to_file/used_apis b/repos/os/recipes/src/rom_to_file/used_apis
index cc10b0d2a5..983ea1d731 100644
--- a/repos/os/recipes/src/rom_to_file/used_apis
+++ b/repos/os/recipes/src/rom_to_file/used_apis
@@ -1,4 +1,3 @@
base
os
-file_system
-file_system_session
+vfs
diff --git a/repos/os/run/rom_to_file.run b/repos/os/run/rom_to_file.run
index 9d844e7948..c67487a2b5 100644
--- a/repos/os/run/rom_to_file.run
+++ b/repos/os/run/rom_to_file.run
@@ -28,6 +28,7 @@ install_config {
+
@@ -53,7 +54,9 @@ install_config {
-
+
+
+
@@ -73,6 +76,7 @@ build_boot_image { core ld.lib.so init timer
rom_to_file
lx_fs
fs_test
+ vfs.lib.so
}
append qemu_args " -nographic "
diff --git a/repos/os/src/app/rom_to_file/README b/repos/os/src/app/rom_to_file/README
index 0907d24cd9..c30c82cb24 100644
--- a/repos/os/src/app/rom_to_file/README
+++ b/repos/os/src/app/rom_to_file/README
@@ -5,6 +5,8 @@ updates.
The name of the ROM module must be specified via the 'rom' attribute of the
components '' node
-!
+!
+!
+!
See run/rom_to_file.run for an example.
diff --git a/repos/os/src/app/rom_to_file/main.cc b/repos/os/src/app/rom_to_file/main.cc
index d077300ca9..8a08cee63f 100644
--- a/repos/os/src/app/rom_to_file/main.cc
+++ b/repos/os/src/app/rom_to_file/main.cc
@@ -14,17 +14,9 @@
/* Genode includes */
#include
#include
-#include
-#include
#include
-#include
-#include
-
#include
-#include
-
-#include
-#include
+#include
namespace Rom_to_file {
@@ -32,29 +24,21 @@ namespace Rom_to_file {
using namespace Genode;
struct Main;
-
- enum {
- BLOCK_SIZE = 512,
- QUEUE_SIZE = File_system::Session::TX_QUEUE_SIZE,
- TX_BUF_SIZE = BLOCK_SIZE * (QUEUE_SIZE*2 + 1)
- };
}
struct Rom_to_file::Main
{
- Genode::Env &_env;
- Genode::Heap _heap { _env.ram(), _env.rm() };
+ Env &_env;
+ Heap _heap { _env.ram(), _env.rm() };
- Genode::Attached_rom_dataspace _config_rom { _env, "config" };
+ Attached_rom_dataspace _config_rom { _env, "config" };
- Allocator_avl _alloc { &_heap };
-
- File_system::Connection _fs { _env, _alloc, "", "/", true, TX_BUF_SIZE };
+ Root_directory _root_dir { _env, _heap, _config_rom.xml().sub_node("vfs") };
Constructible _rom_ds { };
- typedef Genode::String<100> Rom_name;
+ typedef String<100> Rom_name;
/**
* Name of currently requested ROM module
@@ -72,7 +56,7 @@ struct Rom_to_file::Main
Signal_handler _update_dispatcher {
_env.ep(), *this, &Main::_handle_update };
- Main(Genode::Env &env) : _env(env)
+ Main(Env &env) : _env(env)
{
_config_rom.sigh(_update_dispatcher);
_handle_update();
@@ -84,7 +68,7 @@ void Rom_to_file::Main::_handle_update()
{
_config_rom.update();
- Genode::Xml_node config = _config_rom.xml();
+ Xml_node config = _config_rom.xml();
/*
* Query name of ROM module from config
@@ -114,53 +98,17 @@ void Rom_to_file::Main::_handle_update()
_rom_ds->update();
if (_rom_ds->valid()) {
- using namespace File_system;
-
- char dir_path[] = "/";
- const char *file_name = _rom_name.string();
try {
- Dir_handle dir_handle = ensure_dir(_fs, dir_path);
- Handle_guard dir_guard(_fs, dir_handle);
- Constructible handle;
+ New_file new_file { _root_dir, _rom_name };
- try {
- handle.construct(_fs.file(dir_handle, file_name, File_system::WRITE_ONLY, true));
- } catch (Node_already_exists) {
- handle.construct(_fs.file(dir_handle, file_name, File_system::WRITE_ONLY, false));
- }
+ size_t const len = max(strlen(_rom_ds->local_addr()),
+ _rom_ds->size());
- _fs.truncate(*handle, 0);
-
- size_t len = max(strlen(_rom_ds->local_addr()), _rom_ds->size());
- size_t written = write(_fs, *handle, _rom_ds->local_addr(), len, 0);
-
- if (written < len) {
- warning(written, " of ", len, " bytes have been written");
- }
-
- _fs.close(*handle);
-
- } catch (Permission_denied) {
- error(Cstring(dir_path), file_name, ": permission denied");
-
- } catch (No_space) {
- error("file system out of space");
-
- } catch (Out_of_ram) {
- error("server ran out of RAM");
-
- } catch (Out_of_caps) {
- error("server ran out of caps");
-
- } catch (Invalid_name) {
- error(Cstring(dir_path), file_name, ": invalid path");
-
- } catch (Name_too_long) {
- error(Cstring(dir_path), file_name, ": name too long");
+ new_file.append(_rom_ds->local_addr(), len);
} catch (...) {
- error("cannot open file ", Cstring(dir_path), file_name);
+ error("cannot create file ", _rom_name);
throw;
}
} else {
diff --git a/repos/os/src/app/rom_to_file/target.mk b/repos/os/src/app/rom_to_file/target.mk
index f77134037e..18fd7fcff1 100644
--- a/repos/os/src/app/rom_to_file/target.mk
+++ b/repos/os/src/app/rom_to_file/target.mk
@@ -1,3 +1,3 @@
TARGET = rom_to_file
SRC_CC = main.cc
-LIBS = base
+LIBS = base vfs