mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-04 07:36:50 +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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user