Kernel: Move setting file flags and r/w mode to VFS::open()

Previously, VFS::open() would only use the passed flags for permission checking
purposes, and Process::sys$open() would set them on the created FileDescription
explicitly. Now, they should be set by VFS::open() on any files being opened,
including files that the kernel opens internally.

This also lets us get rid of the explicit check for whether or not the returned
FileDescription was a preopen fd, and in fact, fixes a bug where a read-only
preopen fd without any other flags would be considered freshly opened (due to
O_RDONLY being indistinguishable from 0) and granted a new set of flags.
This commit is contained in:
Sergey Bugaev 2020-01-19 01:15:52 +03:00 committed by Andreas Kling
commit d0d13e2bf5
Notes: sideshowbarker 2024-07-19 09:58:21 +09:00
4 changed files with 10 additions and 12 deletions

View file

@ -66,6 +66,7 @@ KResultOr<NonnullRefPtr<FileDescription>> PTYMultiplexer::open(int options)
#endif
auto description = FileDescription::create(move(master));
description->set_rw_mode(options);
description->set_file_flags(options);
return description;
}