From 48fd034cfeb4648b975d4f7dbec50c9e42032c11 Mon Sep 17 00:00:00 2001 From: Emery Hemingway Date: Wed, 7 Oct 2015 18:31:52 +0200 Subject: [PATCH] New session arguments at File_system connection Session root and writeablity may be specified at the session convenience constructor. Issue #1648 --- .../include/file_system_session/connection.h | 28 +++++++++++++++---- repos/os/include/vfs/fs_file_system.h | 27 ++++++++---------- 2 files changed, 33 insertions(+), 22 deletions(-) diff --git a/repos/os/include/file_system_session/connection.h b/repos/os/include/file_system_session/connection.h index 1eefd4579..e4e5489a3 100644 --- a/repos/os/include/file_system_session/connection.h +++ b/repos/os/include/file_system_session/connection.h @@ -18,7 +18,14 @@ #include #include -namespace File_system { struct Connection; } +namespace File_system { + + struct Connection; + + /* recommended packet transmission buffer size */ + enum { DEFAULT_TX_BUF_SIZE = 128*1024 }; + +} struct File_system::Connection : Genode::Connection, Session_client @@ -31,13 +38,22 @@ struct File_system::Connection : Genode::Connection, Session_client * \param tx_buf_size size of transmission buffer in bytes */ Connection(Range_allocator &tx_block_alloc, - size_t tx_buf_size = 128*1024, - const char *label = "") + size_t tx_buf_size = DEFAULT_TX_BUF_SIZE, + char const *label = "", + char const *root = "/", + bool writeable = true) : Genode::Connection( - session("ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", - 4*1024*sizeof(long) + tx_buf_size, tx_buf_size, label)), - Session_client(cap(), tx_block_alloc) { } + session("ram_quota=%zd, " + "tx_buf_size=%zd, " + "label=\"%s\", " + "root=\"%s\", " + "writeable=%d", + 4*1024*sizeof(long) + tx_buf_size, + tx_buf_size, + label, root, writeable)), + Session_client(cap(), tx_block_alloc) + { } }; #endif /* _INCLUDE__FILE_SYSTEM_SESSION__CONNECTION_H_ */ diff --git a/repos/os/include/vfs/fs_file_system.h b/repos/os/include/vfs/fs_file_system.h index 3284b6d2f..20ab4c1e8 100644 --- a/repos/os/include/vfs/fs_file_system.h +++ b/repos/os/include/vfs/fs_file_system.h @@ -17,6 +17,7 @@ /* Genode includes */ #include #include +#include namespace Vfs { class Fs_file_system; } @@ -38,18 +39,11 @@ class Vfs::Fs_file_system : public File_system Genode::Allocator_avl _fs_packet_alloc; - struct Label - { - enum { LABEL_MAX_LEN = 64 }; - char string[LABEL_MAX_LEN]; + typedef Genode::String<64> Label_string; + Label_string _label; - Label(Xml_node config) - { - string[0] = 0; - try { config.attribute("label").value(string, sizeof(string)); } - catch (...) { } - } - } _label; + typedef Genode::String<::File_system::MAX_NAME_LEN> Root_string; + Root_string _root; ::File_system::Connection _fs; @@ -159,14 +153,15 @@ class Vfs::Fs_file_system : public File_system public: - /* - * XXX read label from config - */ Fs_file_system(Xml_node config) : _fs_packet_alloc(env()->heap()), - _label(config), - _fs(_fs_packet_alloc, 128*1024, _label.string) + _label(config.attribute_value("label", Label_string())), + _root( config.attribute_value("root", Root_string())), + _fs(_fs_packet_alloc, + ::File_system::DEFAULT_TX_BUF_SIZE, + _label.string(), _root.string(), + config.attribute_value("writeable", true)) { }