libc: remove global config accessor

Issue #2280.
This commit is contained in:
Josef Söntgen 2017-02-22 14:42:20 +01:00 committed by Christian Helmuth
parent b3af297058
commit 9ec553474e
4 changed files with 34 additions and 2 deletions

View File

@ -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;
};

View File

@ -16,6 +16,7 @@
/* Genode includes */
#include <base/env.h>
#include <util/xml_node.h>
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_ */

View File

@ -76,6 +76,14 @@ class Libc::Env_implementation : public Libc::Env
return Genode::Xml_node("<vfs/>");
}
Genode::Xml_node _libc_config()
{
try { return _config.xml().sub_node("libc"); }
catch (Genode::Xml_node::Nonexistent_sub_node) { }
return Genode::Xml_node("<libc/>");
}
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<Libc::Kernel>(env);
Libc::libc_config_init(kernel->libc_env().libc_config());
/* construct libc component on kernel stack */
Libc::Component::construct(kernel->libc_env());
}

View File

@ -17,7 +17,6 @@
#include <base/env.h>
#include <base/log.h>
#include <vfs/dir_file_system.h>
#include <os/config.h>
/* libc includes */
#include <errno.h>
@ -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