New session arguments at File_system connection

Session root and writeablity may be specified at the session
convenience constructor.

Issue #1648
This commit is contained in:
Emery Hemingway 2015-10-07 18:31:52 +02:00 committed by Christian Helmuth
parent 2da239d0c8
commit 48fd034cfe
2 changed files with 33 additions and 22 deletions

View File

@ -18,7 +18,14 @@
#include <base/connection.h> #include <base/connection.h>
#include <base/allocator.h> #include <base/allocator.h>
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>, Session_client struct File_system::Connection : Genode::Connection<Session>, Session_client
@ -31,13 +38,22 @@ struct File_system::Connection : Genode::Connection<Session>, Session_client
* \param tx_buf_size size of transmission buffer in bytes * \param tx_buf_size size of transmission buffer in bytes
*/ */
Connection(Range_allocator &tx_block_alloc, Connection(Range_allocator &tx_block_alloc,
size_t tx_buf_size = 128*1024, size_t tx_buf_size = DEFAULT_TX_BUF_SIZE,
const char *label = "") char const *label = "",
char const *root = "/",
bool writeable = true)
: :
Genode::Connection<Session>( Genode::Connection<Session>(
session("ram_quota=%zd, tx_buf_size=%zd, label=\"%s\"", session("ram_quota=%zd, "
4*1024*sizeof(long) + tx_buf_size, tx_buf_size, label)), "tx_buf_size=%zd, "
Session_client(cap(), tx_block_alloc) { } "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_ */ #endif /* _INCLUDE__FILE_SYSTEM_SESSION__CONNECTION_H_ */

View File

@ -17,6 +17,7 @@
/* Genode includes */ /* Genode includes */
#include <base/allocator_avl.h> #include <base/allocator_avl.h>
#include <file_system_session/connection.h> #include <file_system_session/connection.h>
#include <util/string.h>
namespace Vfs { class Fs_file_system; } namespace Vfs { class Fs_file_system; }
@ -38,18 +39,11 @@ class Vfs::Fs_file_system : public File_system
Genode::Allocator_avl _fs_packet_alloc; Genode::Allocator_avl _fs_packet_alloc;
struct Label typedef Genode::String<64> Label_string;
{ Label_string _label;
enum { LABEL_MAX_LEN = 64 };
char string[LABEL_MAX_LEN];
Label(Xml_node config) typedef Genode::String<::File_system::MAX_NAME_LEN> Root_string;
{ Root_string _root;
string[0] = 0;
try { config.attribute("label").value(string, sizeof(string)); }
catch (...) { }
}
} _label;
::File_system::Connection _fs; ::File_system::Connection _fs;
@ -159,14 +153,15 @@ class Vfs::Fs_file_system : public File_system
public: public:
/*
* XXX read label from config
*/
Fs_file_system(Xml_node config) Fs_file_system(Xml_node config)
: :
_fs_packet_alloc(env()->heap()), _fs_packet_alloc(env()->heap()),
_label(config), _label(config.attribute_value("label", Label_string())),
_fs(_fs_packet_alloc, 128*1024, _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))
{ } { }