mirror of
https://github.com/SerenityOS/serenity
synced 2024-07-24 11:35:13 +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
|
@ -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…
Reference in a new issue