mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
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:
parent
544b8286da
commit
d0d13e2bf5
Notes:
sideshowbarker
2024-07-19 09:58:21 +09:00
Author: https://github.com/bugaevc
Commit: d0d13e2bf5
Pull-request: https://github.com/SerenityOS/serenity/pull/1096
4 changed files with 10 additions and 12 deletions
|
@ -277,7 +277,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::open(StringView path, int options
|
|||
inode.truncate(0);
|
||||
inode.set_mtime(kgettimeofday().tv_sec);
|
||||
}
|
||||
return FileDescription::create(custody);
|
||||
auto description = FileDescription::create(custody);
|
||||
description->set_rw_mode(options);
|
||||
description->set_file_flags(options);
|
||||
return description;
|
||||
}
|
||||
|
||||
KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
||||
|
@ -309,8 +312,6 @@ KResult VFS::mknod(StringView path, mode_t mode, dev_t dev, Custody& base)
|
|||
|
||||
KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int options, mode_t mode, Custody& parent_custody, Optional<UidAndGid> owner)
|
||||
{
|
||||
(void)options;
|
||||
|
||||
if (!is_socket(mode) && !is_fifo(mode) && !is_block_device(mode) && !is_character_device(mode)) {
|
||||
// Turn it into a regular file. (This feels rather hackish.)
|
||||
mode |= 0100000;
|
||||
|
@ -332,7 +333,10 @@ KResultOr<NonnullRefPtr<FileDescription>> VFS::create(StringView path, int optio
|
|||
return KResult(error);
|
||||
|
||||
auto new_custody = Custody::create(&parent_custody, p.basename(), *new_file, parent_custody.mount_flags());
|
||||
return FileDescription::create(*new_custody);
|
||||
auto description = FileDescription::create(*new_custody);
|
||||
description->set_rw_mode(options);
|
||||
description->set_file_flags(options);
|
||||
return description;
|
||||
}
|
||||
|
||||
KResult VFS::mkdir(StringView path, mode_t mode, Custody& base)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue