mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-31 05:09:12 +00:00
Kernel: Make sys$posix_fallocate() fail with ENODEV on non-regular files
Previously we tried to determine if `fd` refers to a non-regular file by doing a stat() operation on the file. This didn't work out very well since many File subclasses don't actually implement stat() but instead fall back to failing with EBADF. This patch fixes the issue by checking for regular files with File::is_regular_file() instead.
This commit is contained in:
parent
4dd148f07c
commit
961e1e590b
Notes:
sideshowbarker
2024-07-17 03:58:03 +09:00
Author: https://github.com/awesomekling
Commit: 961e1e590b
Pull-request: https://github.com/SerenityOS/serenity/pull/16231
Reviewed-by: https://github.com/Hendiadyoin1
Reviewed-by: https://github.com/emanuele6
Reviewed-by: https://github.com/fdellwing
Reviewed-by: https://github.com/skyrising
Reviewed-by: https://github.com/supercomputer7
Reviewed-by: https://github.com/timschumi ✅
1 changed files with 2 additions and 1 deletions
|
@ -37,7 +37,8 @@ ErrorOr<FlatPtr> Process::sys$posix_fallocate(int fd, Userspace<off_t const*> us
|
|||
if (description->is_fifo())
|
||||
return ESPIPE;
|
||||
|
||||
if (!S_ISREG(TRY(description->file().stat()).st_mode))
|
||||
// [ENODEV] The fd argument does not refer to a regular file.
|
||||
if (!description->file().is_regular_file())
|
||||
return ENODEV;
|
||||
|
||||
VERIFY(description->file().is_inode());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue