diff --git a/repos/libports/src/lib/libc/fd_alloc.cc b/repos/libports/src/lib/libc/fd_alloc.cc index 3eff157911..be1a2d1362 100644 --- a/repos/libports/src/lib/libc/fd_alloc.cc +++ b/repos/libports/src/lib/libc/fd_alloc.cc @@ -17,9 +17,6 @@ #include #include -/* Genode-internal includes */ -#include - /* libc includes */ #include #include @@ -37,16 +34,6 @@ static Allocator *_alloc_ptr; void Libc::init_fd_alloc(Allocator &alloc) { _alloc_ptr = &alloc; } -File_descriptor_allocator *Libc::file_descriptor_allocator() -{ - if (_alloc_ptr) - return unmanaged_singleton(*_alloc_ptr); - - error("missing call of 'init_fd_alloc'"); - return nullptr; -} - - File_descriptor_allocator::File_descriptor_allocator(Allocator &alloc) : _alloc(alloc) { } diff --git a/repos/libports/src/lib/libc/file_operations.cc b/repos/libports/src/lib/libc/file_operations.cc index 246dd2dad7..e0e19dd8e7 100644 --- a/repos/libports/src/lib/libc/file_operations.cc +++ b/repos/libports/src/lib/libc/file_operations.cc @@ -68,10 +68,11 @@ Libc::Mmap_registry *Libc::mmap_registry() static Cwd *_cwd_ptr; static unsigned int _mmap_align_log2 { PAGE_SHIFT }; -void Libc::init_file_operations(Cwd &cwd, +void Libc::init_file_operations(Cwd &cwd, File_descriptor_allocator &fd_alloc, Config_accessor const &config_accessor) { - _cwd_ptr = &cwd; + _fd_alloc_ptr = &fd_alloc; + _cwd_ptr = &cwd; config_accessor.config().with_optional_sub_node("libc", [&] (Xml_node libc) { libc.with_optional_sub_node("mmap", [&] (Xml_node mmap) { diff --git a/repos/libports/src/lib/libc/fork.cc b/repos/libports/src/lib/libc/fork.cc index 9941e6fdfb..4c9c0c98b8 100644 --- a/repos/libports/src/lib/libc/fork.cc +++ b/repos/libports/src/lib/libc/fork.cc @@ -60,18 +60,19 @@ namespace { using Fn = Monitor::Function_result; } static pid_t fork_result; -static Env *_env_ptr; -static Allocator *_alloc_ptr; -static Monitor *_monitor_ptr; -static Libc::Signal *_signal_ptr; -static Heap *_malloc_heap_ptr; -static void *_user_stack_base_ptr; -static size_t _user_stack_size; -static int _pid; -static int _pid_cnt; -static Config_accessor const *_config_accessor_ptr; -static Binary_name const *_binary_name_ptr; -static Forked_children *_forked_children_ptr; +static Env *_env_ptr; +static File_descriptor_allocator *_fd_alloc_ptr; +static Allocator *_alloc_ptr; +static Monitor *_monitor_ptr; +static Libc::Signal *_signal_ptr; +static Heap *_malloc_heap_ptr; +static void *_user_stack_base_ptr; +static size_t _user_stack_size; +static int _pid; +static int _pid_cnt; +static Config_accessor const *_config_accessor_ptr; +static Binary_name const *_binary_name_ptr; +static Forked_children *_forked_children_ptr; static Libc::Monitor & monitor() @@ -91,9 +92,11 @@ struct Libc::Child_config pid_t const _pid; - void _generate(Xml_generator &xml, Xml_node config); + void _generate(Xml_generator &xml, Xml_node const &config, + File_descriptor_allocator &); - Child_config(Env &env, Config_accessor const &config_accessor, pid_t pid) + Child_config(Env &env, Config_accessor const &config_accessor, + File_descriptor_allocator &fd_alloc, pid_t pid) : _env(env), _pid(pid) { @@ -108,7 +111,7 @@ struct Libc::Child_config Xml_generator xml(_ds->local_addr(), buffer_size, "config", [&] () { - _generate(xml, config); }); + _generate(xml, config, fd_alloc); }); }, [&] () { buffer_size += 4096; } @@ -123,7 +126,8 @@ struct Libc::Child_config }; -void Libc::Child_config::_generate(Xml_generator &xml, Xml_node config) +void Libc::Child_config::_generate(Xml_generator &xml, Xml_node const &config, + File_descriptor_allocator &fd_alloc) { using Addr = String<30>; @@ -155,7 +159,7 @@ void Libc::Child_config::_generate(Xml_generator &xml, Xml_node config) xml.attribute("cwd", Path(Cstring(buf))); } - file_descriptor_allocator()->generate_info(xml); + fd_alloc.generate_info(xml); auto gen_range_attr = [&] (auto at, auto size) { @@ -547,19 +551,20 @@ struct Libc::Forked_child : Child_policy, Child_ready Child _child; - Forked_child(Env &env, - Entrypoint &fork_ep, - Allocator &alloc, - Binary_name const &binary_name, - Signal &signal, - pid_t pid, - Config_accessor const &config_accessor, - Parent_services &parent_services, - Local_rom_services &local_rom_services) + Forked_child(Env &env, + File_descriptor_allocator &fd_alloc, + Entrypoint &fork_ep, + Allocator &alloc, + Binary_name const &binary_name, + Signal &signal, + pid_t pid, + Config_accessor const &config_accessor, + Parent_services &parent_services, + Local_rom_services &local_rom_services) : _env(env), _binary_name(binary_name), _signal(signal), _pid(pid), - _child_config(env, config_accessor, pid), + _child_config(env, config_accessor, fd_alloc, pid), _parent_services(parent_services), _local_rom_services(local_rom_services), _local_clone_service(env, fork_ep, *this), @@ -594,8 +599,8 @@ static Forked_child * fork_kernel_routine() static Local_rom_services local_rom_services(env, fork_ep, alloc); Registered *child = new (alloc) - Registered(*_forked_children_ptr, env, fork_ep, alloc, - *_binary_name_ptr, + Registered(*_forked_children_ptr, env, *_fd_alloc_ptr, + fork_ep, alloc, *_binary_name_ptr, signal, child_pid, *_config_accessor_ptr, parent_services, local_rom_services); @@ -727,7 +732,10 @@ extern "C" pid_t __sys_wait4(pid_t pid, int *status, int options, rusage *rusage return Fn::INCOMPLETE; }); - file_descriptor_allocator()->update_append_libc_fds(); + if (_fd_alloc_ptr) + _fd_alloc_ptr->update_append_libc_fds(); + else + error("__sys_wait4: missing call of 'init_fork'"); /* * The libc expects status information in bits 0..6 and the exit value @@ -744,12 +752,14 @@ extern "C" pid_t __sys_wait4(pid_t pid, int *status, int options, rusage *rusage extern "C" pid_t wait4(pid_t, int *, int, rusage *) __attribute__((weak, alias("__sys_wait4"))); -void Libc::init_fork(Env &env, Config_accessor const &config_accessor, +void Libc::init_fork(Env &env, File_descriptor_allocator &fd_alloc, + Config_accessor const &config_accessor, Allocator &alloc, Heap &malloc_heap, pid_t pid, Monitor &monitor, Signal &signal, Binary_name const &binary_name) { _env_ptr = &env; + _fd_alloc_ptr = &fd_alloc; _alloc_ptr = &alloc; _monitor_ptr = &monitor; _signal_ptr = &signal; diff --git a/repos/libports/src/lib/libc/internal/fd_alloc.h b/repos/libports/src/lib/libc/internal/fd_alloc.h index fe9c3b2ed9..5fdf9c451a 100644 --- a/repos/libports/src/lib/libc/internal/fd_alloc.h +++ b/repos/libports/src/lib/libc/internal/fd_alloc.h @@ -41,97 +41,96 @@ namespace Libc { enum { ANY_FD = -1 }; - struct File_descriptor - { - Genode::Mutex mutex { }; + struct File_descriptor; - using Id_space = Genode::Id_space; - Id_space::Element _elem; - - int const libc_fd = _elem.id().value; - - char const *fd_path = nullptr; /* for 'fchdir', 'fstat' */ - - Plugin *plugin; - Plugin_context *context; - - int flags = 0; /* for 'fcntl' */ - bool cloexec = 0; /* for 'fcntl' */ - bool modified = false; - - File_descriptor(Id_space &id_space, Plugin &plugin, Plugin_context &context, - Id_space::Id id) - : _elem(*this, id_space, id), plugin(&plugin), context(&context) { } - - void path(char const *newpath); - }; - - - class File_descriptor_allocator - { - private: - - Genode::Mutex _mutex; - - Genode::Allocator &_alloc; - - using Id_space = File_descriptor::Id_space; - - Id_space _id_space; - - Genode::Bit_allocator _id_allocator; - - public: - - /** - * Constructor - */ - File_descriptor_allocator(Genode::Allocator &_alloc); - - /** - * Allocate file descriptor - */ - File_descriptor *alloc(Plugin *plugin, Plugin_context *context, int libc_fd = -1); - - /** - * Release file descriptor - */ - void free(File_descriptor *fdo); - - /** - * Prevent the use of the specified file descriptor - */ - void preserve(int libc_fd); - - File_descriptor *find_by_libc_fd(int libc_fd); - - /** - * Return any file descriptor with close-on-execve flag set - * - * \return pointer to file descriptor, or - * nullptr is no such file descriptor exists - */ - File_descriptor *any_cloexec_libc_fd(); - - /** - * Update seek state of file descriptor with append flag set. - */ - void update_append_libc_fds(); - - /** - * Return file-descriptor ID of any open file, or -1 if no file is - * open - */ - int any_open_fd(); - - void generate_info(Genode::Xml_generator &); - }; - - - /** - * Return singleton instance of file-descriptor allocator - */ - extern File_descriptor_allocator *file_descriptor_allocator(); + class File_descriptor_allocator; } + +struct Libc::File_descriptor +{ + Genode::Mutex mutex { }; + + using Id_space = Genode::Id_space; + Id_space::Element _elem; + + int const libc_fd = _elem.id().value; + + char const *fd_path = nullptr; /* for 'fchdir', 'fstat' */ + + Plugin *plugin; + Plugin_context *context; + + int flags = 0; /* for 'fcntl' */ + bool cloexec = 0; /* for 'fcntl' */ + bool modified = false; + + File_descriptor(Id_space &id_space, Plugin &plugin, Plugin_context &context, + Id_space::Id id) + : _elem(*this, id_space, id), plugin(&plugin), context(&context) { } + + void path(char const *newpath); +}; + + +class Libc::File_descriptor_allocator +{ + private: + + Genode::Mutex _mutex; + + Genode::Allocator &_alloc; + + using Id_space = File_descriptor::Id_space; + + Id_space _id_space; + + Genode::Bit_allocator _id_allocator; + + public: + + /** + * Constructor + */ + File_descriptor_allocator(Genode::Allocator &_alloc); + + /** + * Allocate file descriptor + */ + File_descriptor *alloc(Plugin *plugin, Plugin_context *context, int libc_fd = -1); + + /** + * Release file descriptor + */ + void free(File_descriptor *fdo); + + /** + * Prevent the use of the specified file descriptor + */ + void preserve(int libc_fd); + + File_descriptor *find_by_libc_fd(int libc_fd); + + /** + * Return any file descriptor with close-on-execve flag set + * + * \return pointer to file descriptor, or + * nullptr is no such file descriptor exists + */ + File_descriptor *any_cloexec_libc_fd(); + + /** + * Update seek state of file descriptor with append flag set. + */ + void update_append_libc_fds(); + + /** + * Return file-descriptor ID of any open file, or -1 if no file is + * open + */ + int any_open_fd(); + + void generate_info(Genode::Xml_generator &); +}; + #endif /* _LIBC_PLUGIN__FD_ALLOC_H_ */ diff --git a/repos/libports/src/lib/libc/internal/file.h b/repos/libports/src/lib/libc/internal/file.h index 4f336ee875..1d24ac17b1 100644 --- a/repos/libports/src/lib/libc/internal/file.h +++ b/repos/libports/src/lib/libc/internal/file.h @@ -25,6 +25,20 @@ enum { INVALID_FD = -1 }; + +static Libc::File_descriptor_allocator *_fd_alloc_ptr; + + +static Libc::File_descriptor_allocator *file_descriptor_allocator() +{ + if (!_fd_alloc_ptr) { + Genode::error("missing initialization of _fd_alloc_ptr"); + for (;;); + } + return _fd_alloc_ptr; +} + + /** * Find plugin responsible for the specified libc file descriptor * @@ -32,8 +46,7 @@ enum { INVALID_FD = -1 }; */ static inline Libc::File_descriptor *libc_fd_to_fd(int libc_fd, const char *func_name) { - Libc::File_descriptor *fd = - Libc::file_descriptor_allocator()->find_by_libc_fd(libc_fd); + Libc::File_descriptor *fd = file_descriptor_allocator()->find_by_libc_fd(libc_fd); if (!fd) Genode::error("no plugin found for ", func_name, "(", libc_fd, ")"); return fd; diff --git a/repos/libports/src/lib/libc/internal/init.h b/repos/libports/src/lib/libc/internal/init.h index 405472a347..e2ad25097b 100644 --- a/repos/libports/src/lib/libc/internal/init.h +++ b/repos/libports/src/lib/libc/internal/init.h @@ -67,12 +67,13 @@ namespace Libc { * Virtual file system */ void init_vfs_plugin(Monitor &, Genode::Region_map &); - void init_file_operations(Cwd &, Config_accessor const &); + void init_file_operations(Cwd &, File_descriptor_allocator &, Config_accessor const &); + void init_pread_pwrite(File_descriptor_allocator &); /** * Poll support */ - void init_poll(Signal &, Monitor &); + void init_poll(Signal &, Monitor &, File_descriptor_allocator &); /** * Select support @@ -113,7 +114,8 @@ namespace Libc { /** * Socket fs */ - void init_socket_fs(Suspend &, Monitor &); + void init_socket_fs(Suspend &, Monitor &, File_descriptor_allocator &); + void init_socket_operations(File_descriptor_allocator &); /** * Pthread/semaphore support @@ -131,9 +133,10 @@ namespace Libc { /** * Fork mechanism */ - void init_fork(Genode::Env &, Config_accessor const &, - Genode::Allocator &heap, Heap &malloc_heap, int pid, - Monitor &, Signal &, Binary_name const &); + void init_fork(Genode::Env &, File_descriptor_allocator &, + Config_accessor const &, Genode::Allocator &heap, + Heap &malloc_heap, int pid, Monitor &, Signal &, + Binary_name const &); struct Reset_malloc_heap : Interface { @@ -160,7 +163,7 @@ namespace Libc { /** * Kqueue support */ - void init_kqueue(Genode::Allocator &, Monitor &); + void init_kqueue(Genode::Allocator &, Monitor &, File_descriptor_allocator &); } #endif /* _LIBC__INTERNAL__INIT_H_ */ diff --git a/repos/libports/src/lib/libc/internal/kernel.h b/repos/libports/src/lib/libc/internal/kernel.h index 1261736495..41a5aca118 100644 --- a/repos/libports/src/lib/libc/internal/kernel.h +++ b/repos/libports/src/lib/libc/internal/kernel.h @@ -136,6 +136,8 @@ struct Libc::Kernel final : Vfs::Read_ready_response_handler, */ Binary_name _binary_name { "binary" }; + File_descriptor_allocator _fd_alloc { _heap }; + /** * Allocator for application-owned data * @@ -173,7 +175,7 @@ struct Libc::Kernel final : Vfs::Read_ready_response_handler, bool const _update_mtime = _libc_env.libc_config().attribute_value("update_mtime", true); - Vfs_plugin _vfs { _libc_env, _libc_env.vfs_env(), _heap, *this, + Vfs_plugin _vfs { _libc_env, _fd_alloc, _libc_env.vfs_env(), _heap, *this, _update_mtime ? Vfs_plugin::Update_mtime::YES : Vfs_plugin::Update_mtime::NO, *this /* current_real_time */, diff --git a/repos/libports/src/lib/libc/internal/vfs_plugin.h b/repos/libports/src/lib/libc/internal/vfs_plugin.h index 17f314b29b..1837a06eda 100644 --- a/repos/libports/src/lib/libc/internal/vfs_plugin.h +++ b/repos/libports/src/lib/libc/internal/vfs_plugin.h @@ -81,6 +81,7 @@ class Libc::Vfs_plugin final : public Plugin reference_handle(reference_handle) { } }; + File_descriptor_allocator &_fd_alloc; Genode::Allocator &_alloc; Vfs::File_system &_root_fs; Constructible _root_dir { }; @@ -181,6 +182,7 @@ class Libc::Vfs_plugin final : public Plugin public: Vfs_plugin(Libc::Env &env, + Libc::File_descriptor_allocator &fd_alloc, Vfs::Env &vfs_env, Genode::Allocator &alloc, Vfs::Read_ready_response_handler &handler, @@ -188,6 +190,7 @@ class Libc::Vfs_plugin final : public Plugin Current_real_time ¤t_real_time, Xml_node config) : + _fd_alloc(fd_alloc), _alloc(alloc), _root_fs(env.vfs_env().root_dir()), _response_handler(handler), diff --git a/repos/libports/src/lib/libc/kernel.cc b/repos/libports/src/lib/libc/kernel.cc index 4b1e236059..25870f1ee1 100644 --- a/repos/libports/src/lib/libc/kernel.cc +++ b/repos/libports/src/lib/libc/kernel.cc @@ -282,7 +282,7 @@ void Libc::Kernel::_init_file_descriptors() /* prevent use of IDs of stdin, stdout, and stderr for other files */ for (unsigned fd = 0; fd <= 2; fd++) - file_descriptor_allocator()->preserve(fd); + _fd_alloc.preserve(fd); } /** @@ -308,7 +308,7 @@ void Libc::Kernel::_init_file_descriptors() * Watch stdout's 'info' pseudo file to detect terminal-resize events */ File_descriptor const * const stdout_fd = - file_descriptor_allocator()->find_by_libc_fd(STDOUT_FILENO); + _fd_alloc.find_by_libc_fd(STDOUT_FILENO); with_ioctl_path(stdout_fd, "info", [&] (Directory &root_dir, char const *path) { _terminal_resize_handler.construct(root_dir, path, *this, @@ -318,7 +318,7 @@ void Libc::Kernel::_init_file_descriptors() * Watch stdin's 'interrupts' pseudo file to detect control-c events */ File_descriptor const * const stdin_fd = - file_descriptor_allocator()->find_by_libc_fd(STDIN_FILENO); + _fd_alloc.find_by_libc_fd(STDIN_FILENO); with_ioctl_path(stdin_fd, "interrupts", [&] (Directory &root_dir, char const *path) { _user_interrupt_handler.construct(root_dir, path, @@ -466,10 +466,13 @@ void Libc::execute_in_application_context(Application_code &app_code) } +static Libc::File_descriptor_allocator *_atexit_fd_alloc_ptr; + + static void close_file_descriptors_on_exit() { for (;;) { - int const fd = Libc::file_descriptor_allocator()->any_open_fd(); + int const fd = _atexit_fd_alloc_ptr->any_open_fd(); if (fd == -1) break; close(fd); @@ -483,6 +486,7 @@ Libc::Kernel::Kernel(Genode::Env &env, Genode::Allocator &heap) { init_atexit(_atexit); + _atexit_fd_alloc_ptr = &_fd_alloc; atexit(close_file_descriptors_on_exit); init_semaphore_support(_timer_accessor); @@ -499,22 +503,23 @@ Libc::Kernel::Kernel(Genode::Env &env, Genode::Allocator &heap) init_malloc(*_malloc_heap); } - init_fork(_env, _libc_env, _heap, *_malloc_heap, _pid, *this, _signal, - _binary_name); - init_execve(_env, _heap, _user_stack, *this, _binary_name, - *file_descriptor_allocator()); + init_fork(_env, _fd_alloc, _libc_env, _heap, *_malloc_heap, _pid, *this, + _signal, _binary_name); + init_execve(_env, _heap, _user_stack, *this, _binary_name, _fd_alloc); init_plugin(*this); init_sleep(*this); init_vfs_plugin(*this, _env.rm()); - init_file_operations(*this, _libc_env); + init_file_operations(*this, _fd_alloc, _libc_env); + init_pread_pwrite(_fd_alloc); init_time(*this, *this); init_alarm(_timer_accessor, _signal); - init_poll(_signal, *this); + init_poll(_signal, *this, _fd_alloc); init_select(*this); - init_socket_fs(*this, *this); + init_socket_fs(*this, *this, _fd_alloc); + init_socket_operations(_fd_alloc); init_passwd(_passwd_config()); init_signal(_signal); - init_kqueue(_heap, *this); + init_kqueue(_heap, *this, _fd_alloc); _init_file_descriptors(); diff --git a/repos/libports/src/lib/libc/kqueue.cc b/repos/libports/src/lib/libc/kqueue.cc index 1b69939aa9..9712166419 100644 --- a/repos/libports/src/lib/libc/kqueue.cc +++ b/repos/libports/src/lib/libc/kqueue.cc @@ -462,10 +462,12 @@ struct Libc::Kqueue }; -void Libc::init_kqueue(Genode::Allocator &alloc, Monitor &monitor) +void Libc::init_kqueue(Genode::Allocator &alloc, Monitor &monitor, + File_descriptor_allocator &fd_alloc) { _kqueue_plugin_ptr = new (alloc) Kqueue_plugin(alloc); _monitor_ptr = &monitor; + _fd_alloc_ptr = &fd_alloc; } diff --git a/repos/libports/src/lib/libc/poll.cc b/repos/libports/src/lib/libc/poll.cc index 0e526559e7..1bd838cc6b 100644 --- a/repos/libports/src/lib/libc/poll.cc +++ b/repos/libports/src/lib/libc/poll.cc @@ -31,10 +31,12 @@ using namespace Libc; static Monitor *_monitor_ptr; static Libc::Signal *_signal_ptr; -void Libc::init_poll(Signal &signal, Monitor &monitor) +void Libc::init_poll(Signal &signal, Monitor &monitor, + File_descriptor_allocator &fd_alloc) { - _signal_ptr = &signal; - _monitor_ptr = &monitor; + _signal_ptr = &signal; + _monitor_ptr = &monitor; + _fd_alloc_ptr = &fd_alloc; } diff --git a/repos/libports/src/lib/libc/pread_pwrite.cc b/repos/libports/src/lib/libc/pread_pwrite.cc index 758fd540fe..0a23cc49f4 100644 --- a/repos/libports/src/lib/libc/pread_pwrite.cc +++ b/repos/libports/src/lib/libc/pread_pwrite.cc @@ -20,8 +20,9 @@ #include /* libc-internal includes */ -#include +#include #include +#include struct Read @@ -42,13 +43,27 @@ struct Write }; +static Libc::File_descriptor_allocator *_fd_alloc_ptr; + + +void Libc::init_pread_pwrite(Libc::File_descriptor_allocator &fd_alloc) +{ + _fd_alloc_ptr = &fd_alloc; +} + + using namespace Libc; template static ssize_t pread_pwrite_impl(Rw_func rw_func, int fd, Buf_type buf, ::size_t count, ::off_t offset) { - File_descriptor *fdesc = file_descriptor_allocator()->find_by_libc_fd(fd); + if (!_fd_alloc_ptr) { + error("missing call of init_pread_pwrite"); + return -1; + } + + File_descriptor *fdesc = _fd_alloc_ptr->find_by_libc_fd(fd); if (fdesc == 0) return -1; diff --git a/repos/libports/src/lib/libc/socket_fs_plugin.cc b/repos/libports/src/lib/libc/socket_fs_plugin.cc index f5b9b49ed7..a6dbd7e12e 100644 --- a/repos/libports/src/lib/libc/socket_fs_plugin.cc +++ b/repos/libports/src/lib/libc/socket_fs_plugin.cc @@ -56,10 +56,12 @@ static Libc::Suspend *_suspend_ptr; static Libc::Monitor *_monitor_ptr; -void Libc::init_socket_fs(Suspend &suspend, Monitor &monitor) +void Libc::init_socket_fs(Suspend &suspend, Monitor &monitor, + File_descriptor_allocator &fd_alloc) { - _suspend_ptr = &suspend; - _monitor_ptr = &monitor; + _suspend_ptr = &suspend; + _monitor_ptr = &monitor; + _fd_alloc_ptr = &fd_alloc; } diff --git a/repos/libports/src/lib/libc/socket_operations.cc b/repos/libports/src/lib/libc/socket_operations.cc index dcd0467530..34309fdcda 100644 --- a/repos/libports/src/lib/libc/socket_operations.cc +++ b/repos/libports/src/lib/libc/socket_operations.cc @@ -28,6 +28,13 @@ extern "C" { #include #include #include +#include + + +void Libc::init_socket_operations(Libc::File_descriptor_allocator &fd_alloc) +{ + _fd_alloc_ptr = &fd_alloc; +} using namespace Libc; diff --git a/repos/libports/src/lib/libc/vfs_plugin.cc b/repos/libports/src/lib/libc/vfs_plugin.cc index 33ea35b6b3..d51db16ec4 100644 --- a/repos/libports/src/lib/libc/vfs_plugin.cc +++ b/repos/libports/src/lib/libc/vfs_plugin.cc @@ -304,8 +304,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::open_from_kernel(const char *path, int /* the directory was successfully opened */ - File_descriptor *fd = - file_descriptor_allocator()->alloc(this, vfs_context(handle), libc_fd); + File_descriptor *fd = _fd_alloc.alloc(this, vfs_context(handle), libc_fd); if (!fd) { handle->close(); @@ -383,8 +382,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::open_from_kernel(const char *path, int /* the file was successfully opened */ - File_descriptor *fd = - file_descriptor_allocator()->alloc(this, vfs_context(handle), libc_fd); + File_descriptor *fd = _fd_alloc.alloc(this, vfs_context(handle), libc_fd); if (!fd) { handle->close(); @@ -436,7 +434,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags) /* the directory was successfully opened */ - fd = file_descriptor_allocator()->alloc(this, vfs_context(handle), Libc::ANY_FD); + fd = _fd_alloc.alloc(this, vfs_context(handle), Libc::ANY_FD); if (!fd) { handle->close(); @@ -515,7 +513,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::open(char const *path, int flags) /* the file was successfully opened */ - fd = file_descriptor_allocator()->alloc(this, vfs_context(handle), Libc::ANY_FD); + fd = _fd_alloc.alloc(this, vfs_context(handle), Libc::ANY_FD); if (!fd) { handle->close(); @@ -605,7 +603,7 @@ int Libc::Vfs_plugin::close_from_kernel(File_descriptor *fd) } handle->close(); - file_descriptor_allocator()->free(fd); + _fd_alloc.free(fd); return 0; } @@ -623,7 +621,7 @@ int Libc::Vfs_plugin::close(File_descriptor *fd) return Fn::INCOMPLETE; handle->close(); - file_descriptor_allocator()->free(fd); + _fd_alloc.free(fd); return Fn::COMPLETE; }); @@ -681,8 +679,7 @@ Libc::File_descriptor *Libc::Vfs_plugin::dup(File_descriptor *fd) handle->seek(vfs_handle(fd)->seek()); handle->handler(&_response_handler); - File_descriptor * const new_fd = - file_descriptor_allocator()->alloc(this, vfs_context(handle)); + File_descriptor * const new_fd = _fd_alloc.alloc(this, vfs_context(handle)); if (!new_fd) { handle->close(); @@ -2059,8 +2056,7 @@ int Libc::Vfs_plugin::fcntl(File_descriptor *fd, int cmd, long arg) /* * Allocate free file descriptor locally. */ - File_descriptor *new_fd = - file_descriptor_allocator()->alloc(this, 0); + File_descriptor *new_fd = _fd_alloc.alloc(this, 0); if (!new_fd) return Errno(EMFILE); /*