libc: configurable initial FDs

The libc already supports the configuration of 'stdin', 'stdout', and
'stderr' using '<libc>' config attributes. This patch equips the libc
with the additional ability to pre-initialize any other file descriptor.
A file descriptor is configured as follows:

<config>
  ...
  <libc ...>
    <fd id="3" path="/dev/log" writeable="yes" readable="no" seek="10"/>
    ...
  </libc>
</config>

Furthermore, this patch moves the FD initialization code from the VFS
plugin to the libc kernel initialization because opening the FDs
depends on 'malloc' ('strdup'), which should not be used at early
'Libc::Kernel' initialization time.

Issue #3478
This commit is contained in:
Norman Feske
2019-08-16 19:04:04 +02:00
committed by Christian Helmuth
parent 6e38b53001
commit 65f75589e9
4 changed files with 94 additions and 54 deletions

View File

@ -109,6 +109,11 @@ namespace Libc {
*/
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);
};