vfs: dynamic configuration support

This commit is contained in:
Sebastian Sumpf 2017-02-07 19:03:23 +01:00 committed by Norman Feske
parent 8025f5f570
commit aa602032dd
18 changed files with 70 additions and 26 deletions

View File

@ -97,7 +97,7 @@ install_config $config
# generic modules
set boot_modules {
core ld.lib.so init timer
libc.lib.so lxip.lib.so test-lxip_http_srv libc_resolv.lib.so
libc.lib.so libm.lib.so lxip.lib.so test-lxip_http_srv libc_resolv.lib.so
}
# platform-specific modules

View File

@ -172,7 +172,8 @@ class Vfs::Rump_file_system : public File_system
** File_system interface **
***************************/
static char const *name() { return "rump"; }
static char const *name() { return "rump"; }
char const *type() override { return "rump"; }
/*********************************

View File

@ -65,7 +65,8 @@ class Jitterentropy_file_system : public Vfs::Single_file_system
jent_entropy_collector_free(_ec_stir);
}
static char const *name() { return "jitterentropy"; }
static char const *name() { return "jitterentropy"; }
char const *type() override { return "jitterentropy"; }
/********************************

View File

@ -562,7 +562,8 @@ class Vfs::Dir_file_system : public File_system
** File_system interface **
***************************/
char const *name() const { return "dir"; }
char const *name() const { return "dir"; }
char const *type() override { return "dir"; }
/**
* Synchronize all file systems
@ -583,6 +584,25 @@ class Vfs::Dir_file_system : public File_system
fs->sync(path);
}
void apply_config(Genode::Xml_node const &node) override
{
using namespace Genode;
File_system *curr = _first_file_system;
for (unsigned i = 0; i < node.num_sub_nodes(); i++, curr = curr->next) {
Xml_node const &sub_node = node.sub_node(i);
/* check if type of XML node matches current file-system type */
if (sub_node.has_type(curr->type()) == false) {
Genode::error("VFS config update failed (node type '",
sub_node.type(), "' != fs type '", curr->type(),"')");
return;
}
curr->apply_config(node.sub_node(i));
}
}
/********************************
** File I/O service interface **

View File

@ -35,6 +35,16 @@ struct Vfs::File_system : Directory_service, File_io_service
* This method flushes any delayed operations from the file system.
*/
virtual void sync(char const *path) { }
/**
* Adjust to configuration changes
*/
virtual void apply_config(Genode::Xml_node const &node) { }
/**
* Return the file-system type
*/
virtual char const *type() = 0;
};
#endif /* _INCLUDE__VFS__FILE_SYSTEM_H_ */

View File

@ -148,8 +148,8 @@ class Vfs::Block_file_system : public Single_file_system
destroy(_alloc, _block_buffer);
}
static char const *name() { return "block"; }
static char const *name() { return "block"; }
char const *type() override { return "block"; }
/*********************************
** Directory service interface **

View File

@ -581,7 +581,8 @@ class Vfs::Fs_file_system : public File_system
** File_system interface **
***************************/
static char const *name() { return "fs"; }
static char const *name() { return "fs"; }
char const *type() override { return "fs"; }
void sync(char const *path) override
{

View File

@ -41,8 +41,8 @@ class Vfs::Inline_file_system : public Single_file_system
_size(config.content_size())
{ }
static char const *name() { return "inline"; }
static char const *name() { return "inline"; }
char const *type() override { return "inline"; }
/********************************
** Directory service interface **

View File

@ -58,8 +58,8 @@ class Vfs::Log_file_system : public Single_file_system
_log(_log_session(env))
{ }
static const char *name() { return "log"; }
static const char *name() { return "log"; }
char const *type() override { return "log"; }
/********************************
** File I/O service interface **

View File

@ -30,8 +30,8 @@ struct Vfs::Null_file_system : Single_file_system
Single_file_system(NODE_TYPE_CHAR_DEVICE, name(), config)
{ }
static char const *name() { return "null"; }
static char const *name() { return "null"; }
char const *type() override { return "null"; }
/********************************
** File I/O service interface **

View File

@ -786,7 +786,8 @@ class Vfs::Ram_file_system : public Vfs::File_system
** File_system interface **
***************************/
static char const *name() { return "ram"; }
static char const *name() { return "ram"; }
char const *type() override { return "ram"; }
};
#endif /* _INCLUDE__VFS__RAM_FILE_SYSTEM_H_ */

View File

@ -58,8 +58,8 @@ class Vfs::Rom_file_system : public Single_file_system
_rom(env, _label.string)
{ }
static char const *name() { return "rom"; }
static char const *name() { return "rom"; }
char const *type() override { return "rom"; }
/*********************************
** Directory-service interface **

View File

@ -39,8 +39,8 @@ class Vfs::Rtc_file_system : public Single_file_system
_rtc(env)
{ }
static char const *name() { return "rtc"; }
static char const *name() { return "rtc"; }
char const *type() override { return "rtc"; }
/*********************************
** Directory-service interface **

View File

@ -40,8 +40,8 @@ class Vfs::Symlink_file_system : public Single_file_system
_target(config.attribute_value("target", Target()))
{ }
static char const *name() { return "symlink"; }
static char const *name() { return "symlink"; }
char const *type() override { return "symlink"; }
/*********************************
** Directory-service interface **

View File

@ -358,7 +358,6 @@ class Vfs::Tar_file_system : public File_system
_for_each_tar_record_do(Add_node_action(_alloc, _root_node));
}
/*********************************
** Directory-service interface **
*********************************/
@ -574,7 +573,8 @@ class Vfs::Tar_file_system : public File_system
** File_system interface **
***************************/
static char const *name() { return "tar"; }
static char const *name() { return "tar"; }
char const *type() override { return "tar"; }
/********************************

View File

@ -67,8 +67,8 @@ class Vfs::Terminal_file_system : public Single_file_system
_terminal.read_avail_sigh(_read_avail_handler);
}
static const char *name() { return "terminal"; }
static const char *name() { return "terminal"; }
char const *type() override { return "terminal"; }
/********************************
** File I/O service interface **

View File

@ -30,8 +30,8 @@ struct Vfs::Zero_file_system : Single_file_system
Single_file_system(NODE_TYPE_CHAR_DEVICE, name(), config)
{ }
static char const *name() { return "zero"; }
static char const *name() { return "zero"; }
char const *type() override { return "zero"; }
/********************************
** File I/O service interface **

View File

@ -500,6 +500,15 @@ class Vfs_server::Root :
_env, _heap, vfs_config(), _io_response_handler,
Vfs::global_file_system_factory() };
Genode::Signal_handler<Root> _config_dispatcher {
_env.ep(), *this, &Root::_config_update };
void _config_update()
{
_config_rom.update();
_vfs.apply_config(vfs_config());
}
protected:
Session_component *_create_session(const char *args) override
@ -603,6 +612,7 @@ class Vfs_server::Root :
Root_component<Session_component>(&env.ep().rpc_ep(), &md_alloc),
_env(env)
{
_config_rom.sigh(_config_dispatcher);
env.parent().announce(env.ep().manage(*this));
}
};