From 9ec553474e81b7cbbdcedae8bf016dadc35e8b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josef=20S=C3=B6ntgen?= Date: Wed, 22 Feb 2017 14:42:20 +0100 Subject: [PATCH] libc: remove global config accessor Issue #2280. --- repos/libports/include/libc/component.h | 5 +++++ repos/libports/src/lib/libc/libc_init.h | 6 ++++++ repos/libports/src/lib/libc/task.cc | 13 +++++++++++++ repos/libports/src/lib/libc/vfs_plugin.cc | 12 ++++++++++-- 4 files changed, 34 insertions(+), 2 deletions(-) diff --git a/repos/libports/include/libc/component.h b/repos/libports/include/libc/component.h index 82e5377555..774e3efd17 100644 --- a/repos/libports/include/libc/component.h +++ b/repos/libports/include/libc/component.h @@ -51,6 +51,11 @@ class Libc::Env : public Genode::Env * Virtual File System configured for this component */ virtual Vfs::File_system &vfs() = 0; + + /** + * Libc configuration for this component + */ + virtual Genode::Xml_node libc_config() = 0; }; diff --git a/repos/libports/src/lib/libc/libc_init.h b/repos/libports/src/lib/libc/libc_init.h index 3265fbbe25..f514ccbbac 100644 --- a/repos/libports/src/lib/libc/libc_init.h +++ b/repos/libports/src/lib/libc/libc_init.h @@ -16,6 +16,7 @@ /* Genode includes */ #include +#include namespace Libc { @@ -33,6 +34,11 @@ namespace Libc { * Support for querying available RAM quota in sysctl functions */ void sysctl_init(Genode::Env &env); + + /** + * Set libc config node + */ + void libc_config_init(Genode::Xml_node node); } #endif /* _LIBC_INIT_H_ */ diff --git a/repos/libports/src/lib/libc/task.cc b/repos/libports/src/lib/libc/task.cc index 33be2a7acb..71e4e5715c 100644 --- a/repos/libports/src/lib/libc/task.cc +++ b/repos/libports/src/lib/libc/task.cc @@ -76,6 +76,14 @@ class Libc::Env_implementation : public Libc::Env return Genode::Xml_node(""); } + Genode::Xml_node _libc_config() + { + try { return _config.xml().sub_node("libc"); } + catch (Genode::Xml_node::Nonexistent_sub_node) { } + + return Genode::Xml_node(""); + } + Vfs::Global_file_system_factory _file_system_factory; Vfs::Dir_file_system _vfs; @@ -100,6 +108,9 @@ class Libc::Env_implementation : public Libc::Env Vfs::File_system &vfs() override { return _vfs; } + Genode::Xml_node libc_config() override { + return _libc_config(); } + /*************************** ** Genode::Env interface ** @@ -846,6 +857,8 @@ void Component::construct(Genode::Env &env) kernel = unmanaged_singleton(env); + Libc::libc_config_init(kernel->libc_env().libc_config()); + /* construct libc component on kernel stack */ Libc::Component::construct(kernel->libc_env()); } diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index ca582a6d43..a6936bc760 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -17,7 +17,6 @@ #include #include #include -#include /* libc includes */ #include @@ -78,12 +77,21 @@ static void vfs_stat_to_libc_stat_struct(Vfs::Directory_service::Stat const &src } +static Genode::Xml_node *_config_node; + + namespace Libc { + void libc_config_init(Genode::Xml_node node) + { + static Genode::Xml_node config = node; + _config_node = &config; + } + Genode::Xml_node config() __attribute__((weak)); Genode::Xml_node config() { - return Genode::config()->xml_node().sub_node("libc"); + return _config_node->sub_node("libc"); } class Config_attr