mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Kernel: Let inodes provide pre-open file descriptions
Some magical inodes, such as /proc/pid/fd/fileno, are going to want to open() to a custom FileDescription, so add a hook for that.
This commit is contained in:
parent
ae64fd1b27
commit
8642a7046c
3 changed files with 13 additions and 2 deletions
|
@ -1908,8 +1908,14 @@ int Process::sys$open(const Syscall::SC_open_params* user_params)
|
|||
if (result.is_error())
|
||||
return result.error();
|
||||
auto description = result.value();
|
||||
description->set_rw_mode(options);
|
||||
description->set_file_flags(options);
|
||||
if (description->file_flags()) {
|
||||
// We already have file flags set on this description, so
|
||||
// it must be a preopen description (probably, /proc/pid/fd).
|
||||
// So don't reset its flags and r/w mode.
|
||||
} else {
|
||||
description->set_rw_mode(options);
|
||||
description->set_file_flags(options);
|
||||
}
|
||||
u32 fd_flags = (options & O_CLOEXEC) ? FD_CLOEXEC : 0;
|
||||
m_fds[fd].set(move(description), fd_flags);
|
||||
return fd;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue