mirror of
https://github.com/RGBCube/serenity
synced 2025-05-23 16:05:08 +00:00
Kernel: Remove SmapDisablers in stat() and lstat()
This commit is contained in:
parent
08cfcb888c
commit
1226fec19e
1 changed files with 16 additions and 8 deletions
|
@ -1508,9 +1508,9 @@ int Process::sys$fstat(int fd, stat* statbuf)
|
||||||
return description->fstat(*statbuf);
|
return description->fstat(*statbuf);
|
||||||
}
|
}
|
||||||
|
|
||||||
int Process::sys$lstat(const char* user_path, size_t path_length, stat* statbuf)
|
int Process::sys$lstat(const char* user_path, size_t path_length, stat* user_statbuf)
|
||||||
{
|
{
|
||||||
if (!validate_write_typed(statbuf))
|
if (!validate_write_typed(user_statbuf))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
auto path = get_syscall_path_argument(user_path, path_length);
|
auto path = get_syscall_path_argument(user_path, path_length);
|
||||||
if (path.is_error())
|
if (path.is_error())
|
||||||
|
@ -1518,13 +1518,17 @@ int Process::sys$lstat(const char* user_path, size_t path_length, stat* statbuf)
|
||||||
auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory(), O_NOFOLLOW_NOERROR);
|
auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory(), O_NOFOLLOW_NOERROR);
|
||||||
if (metadata_or_error.is_error())
|
if (metadata_or_error.is_error())
|
||||||
return metadata_or_error.error();
|
return metadata_or_error.error();
|
||||||
SmapDisabler disabler;
|
stat statbuf;
|
||||||
return metadata_or_error.value().stat(*statbuf);
|
auto result = metadata_or_error.value().stat(statbuf);
|
||||||
|
if (result.is_error())
|
||||||
|
return result;
|
||||||
|
copy_to_user(user_statbuf, &statbuf, sizeof(statbuf));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Process::sys$stat(const char* user_path, size_t path_length, stat* statbuf)
|
int Process::sys$stat(const char* user_path, size_t path_length, stat* user_statbuf)
|
||||||
{
|
{
|
||||||
if (!validate_write_typed(statbuf))
|
if (!validate_write_typed(user_statbuf))
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
auto path = get_syscall_path_argument(user_path, path_length);
|
auto path = get_syscall_path_argument(user_path, path_length);
|
||||||
if (path.is_error())
|
if (path.is_error())
|
||||||
|
@ -1532,8 +1536,12 @@ int Process::sys$stat(const char* user_path, size_t path_length, stat* statbuf)
|
||||||
auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory());
|
auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory());
|
||||||
if (metadata_or_error.is_error())
|
if (metadata_or_error.is_error())
|
||||||
return metadata_or_error.error();
|
return metadata_or_error.error();
|
||||||
SmapDisabler disabler;
|
stat statbuf;
|
||||||
return metadata_or_error.value().stat(*statbuf);
|
auto result = metadata_or_error.value().stat(statbuf);
|
||||||
|
if (result.is_error())
|
||||||
|
return result;
|
||||||
|
copy_to_user(user_statbuf, &statbuf, sizeof(statbuf));
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int Process::sys$readlink(const char* path, char* buffer, ssize_t size)
|
int Process::sys$readlink(const char* path, char* buffer, ssize_t size)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue