mirror of
https://github.com/RGBCube/serenity
synced 2025-05-25 19:25:07 +00:00
Kernel: Separate VFS stat() from open().
It was very confusing that you had to open a FileDescriptor in order to stat a file. This patch gives VFS a separate stat() function and uses it to implement the stat() and lstat() syscalls.
This commit is contained in:
parent
f5f136931a
commit
ce3b548077
3 changed files with 20 additions and 8 deletions
|
@ -1217,10 +1217,9 @@ int Process::sys$lstat(const char* path, stat* statbuf)
|
|||
if (!validate_write_typed(statbuf))
|
||||
return -EFAULT;
|
||||
int error;
|
||||
auto descriptor = VFS::the().open(move(path), error, O_NOFOLLOW_NOERROR | O_DONT_OPEN_DEVICE, 0, *cwd_inode());
|
||||
if (!descriptor)
|
||||
if (!VFS::the().stat(move(path), error, O_NOFOLLOW_NOERROR, *cwd_inode(), *statbuf))
|
||||
return error;
|
||||
return descriptor->fstat(statbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$stat(const char* path, stat* statbuf)
|
||||
|
@ -1228,10 +1227,9 @@ int Process::sys$stat(const char* path, stat* statbuf)
|
|||
if (!validate_write_typed(statbuf))
|
||||
return -EFAULT;
|
||||
int error;
|
||||
auto descriptor = VFS::the().open(move(path), error, O_DONT_OPEN_DEVICE, 0, *cwd_inode());
|
||||
if (!descriptor)
|
||||
if (!VFS::the().stat(move(path), error, 0, *cwd_inode(), *statbuf))
|
||||
return error;
|
||||
return descriptor->fstat(statbuf);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int Process::sys$readlink(const char* path, char* buffer, size_t size)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue