mirror of
https://github.com/genodelabs/genode.git
synced 2025-01-03 04:26:45 +00:00
libc: late intialization of plugins
- for-each plugin iterator * Call 'init(Genode::env &)' for each plugin bofore 'Libc::construct' or 'main' is called
This commit is contained in:
parent
549c6db064
commit
643a09b518
@ -23,12 +23,15 @@
|
|||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/mount.h> /* for 'struct statfs' */
|
#include <sys/mount.h> /* for 'struct statfs' */
|
||||||
|
|
||||||
|
namespace Genode { class Env; }
|
||||||
|
|
||||||
namespace Libc {
|
namespace Libc {
|
||||||
|
|
||||||
using namespace Genode;
|
using namespace Genode;
|
||||||
|
|
||||||
class File_descriptor;
|
class File_descriptor;
|
||||||
|
|
||||||
|
|
||||||
typedef Genode::Path<PATH_MAX> Absolute_path;
|
typedef Genode::Path<PATH_MAX> Absolute_path;
|
||||||
|
|
||||||
class Plugin : public List<Plugin>::Element
|
class Plugin : public List<Plugin>::Element
|
||||||
@ -70,6 +73,11 @@ namespace Libc {
|
|||||||
virtual bool supports_unlink(const char *path);
|
virtual bool supports_unlink(const char *path);
|
||||||
virtual bool supports_mmap();
|
virtual bool supports_mmap();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Should be overwritten for plugins that require the Genode environment
|
||||||
|
*/
|
||||||
|
virtual void init(Genode::Env &env) { }
|
||||||
|
|
||||||
virtual File_descriptor *accept(File_descriptor *,
|
virtual File_descriptor *accept(File_descriptor *,
|
||||||
struct ::sockaddr *addr,
|
struct ::sockaddr *addr,
|
||||||
socklen_t *addrlen);
|
socklen_t *addrlen);
|
||||||
|
@ -46,6 +46,15 @@ struct Libc::Plugin_registry : List<Plugin>
|
|||||||
Plugin *get_plugin_for_stat(const char *path, struct stat *);
|
Plugin *get_plugin_for_stat(const char *path, struct stat *);
|
||||||
Plugin *get_plugin_for_symlink(const char *oldpath, const char *newpath);
|
Plugin *get_plugin_for_symlink(const char *oldpath, const char *newpath);
|
||||||
Plugin *get_plugin_for_unlink(const char *path);
|
Plugin *get_plugin_for_unlink(const char *path);
|
||||||
|
|
||||||
|
template <typename FUNC>
|
||||||
|
void for_each_plugin(FUNC const &fn) const
|
||||||
|
{
|
||||||
|
for (Plugin *plugin = plugin_registry()->first(); plugin;
|
||||||
|
plugin = plugin->next()) {
|
||||||
|
fn(*plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* _LIBC_PLUGIN__PLUGIN_REGISTRY_H_ */
|
#endif /* _LIBC_PLUGIN__PLUGIN_REGISTRY_H_ */
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
|
|
||||||
/* libc includes */
|
/* libc includes */
|
||||||
#include <libc/component.h>
|
#include <libc/component.h>
|
||||||
|
#include <libc-plugin/plugin_registry.h>
|
||||||
|
|
||||||
/* libc-internal includes */
|
/* libc-internal includes */
|
||||||
#include <internal/call_func.h>
|
#include <internal/call_func.h>
|
||||||
@ -656,6 +657,12 @@ void Component::construct(Genode::Env &env)
|
|||||||
Libc::init_mem_alloc(env);
|
Libc::init_mem_alloc(env);
|
||||||
Libc::init_dl(env);
|
Libc::init_dl(env);
|
||||||
|
|
||||||
|
/* initialize plugins that require Genode::Env */
|
||||||
|
auto init_plugin = [&] (Libc::Plugin &plugin) {
|
||||||
|
plugin.init(env);
|
||||||
|
};
|
||||||
|
Libc::plugin_registry()->for_each_plugin(init_plugin);
|
||||||
|
|
||||||
kernel = unmanaged_singleton<Libc::Kernel>(env);
|
kernel = unmanaged_singleton<Libc::Kernel>(env);
|
||||||
kernel->run();
|
kernel->run();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user