mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 06:48:49 +00:00
Kernel: Pass path+length to the stat() and lstat() syscalls
It's not pleasant having to deal with null-terminated strings as input to syscalls, so let's get rid of them one by one.
This commit is contained in:
parent
152a83fac5
commit
f231e9ea76
Notes:
sideshowbarker
2024-07-19 10:19:37 +09:00
Author: https://github.com/awesomekling
Commit: f231e9ea76
3 changed files with 16 additions and 10 deletions
|
@ -1499,25 +1499,31 @@ int Process::sys$fstat(int fd, stat* statbuf)
|
|||
return description->fstat(*statbuf);
|
||||
}
|
||||
|
||||
int Process::sys$lstat(const char* path, stat* statbuf)
|
||||
int Process::sys$lstat(const char* user_path, size_t path_length, stat* statbuf)
|
||||
{
|
||||
if (!validate_write_typed(statbuf))
|
||||
return -EFAULT;
|
||||
SmapDisabler disabler;
|
||||
auto metadata_or_error = VFS::the().lookup_metadata(StringView(path), current_directory(), O_NOFOLLOW_NOERROR);
|
||||
if (!validate_read(user_path, path_length))
|
||||
return -EFAULT;
|
||||
auto path = copy_string_from_user(user_path, path_length);
|
||||
auto metadata_or_error = VFS::the().lookup_metadata(path, current_directory(), O_NOFOLLOW_NOERROR);
|
||||
if (metadata_or_error.is_error())
|
||||
return metadata_or_error.error();
|
||||
SmapDisabler disabler;
|
||||
return metadata_or_error.value().stat(*statbuf);
|
||||
}
|
||||
|
||||
int Process::sys$stat(const char* path, stat* statbuf)
|
||||
int Process::sys$stat(const char* user_path, size_t path_length, stat* statbuf)
|
||||
{
|
||||
if (!validate_write_typed(statbuf))
|
||||
return -EFAULT;
|
||||
SmapDisabler disabler;
|
||||
auto metadata_or_error = VFS::the().lookup_metadata(StringView(path), current_directory());
|
||||
if (!validate_read(user_path, path_length))
|
||||
return -EFAULT;
|
||||
auto path = copy_string_from_user(user_path, path_length);
|
||||
auto metadata_or_error = VFS::the().lookup_metadata(path, current_directory());
|
||||
if (metadata_or_error.is_error())
|
||||
return metadata_or_error.error();
|
||||
SmapDisabler disabler;
|
||||
return metadata_or_error.value().stat(*statbuf);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue