summaryrefslogtreecommitdiff
path: root/Kernel/Process.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-02-10 19:32:40 +0100
committerAndreas Kling <kling@serenityos.org>2020-02-10 19:49:49 +0100
commit580a94bc44bcea61bf1b07abf24c1b00e43a1d64 (patch)
treec2f78a376958434b3b6c97ab191755762f216d22 /Kernel/Process.cpp
parentb67035c3ac5659b26d88c91d03eda6bf19c35df3 (diff)
downloadserenity-580a94bc44bcea61bf1b07abf24c1b00e43a1d64.zip
Kernel+LibC: Merge sys$stat() and sys$lstat()
There is now only one sys$stat() instead of two separate syscalls.
Diffstat (limited to 'Kernel/Process.cpp')
-rw-r--r--Kernel/Process.cpp30
1 files changed, 7 insertions, 23 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index 6ee08c341a..5755cd1ab4 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -1783,41 +1783,25 @@ int Process::sys$fstat(int fd, stat* statbuf)
return description->fstat(*statbuf);
}
-int Process::sys$lstat(const char* user_path, size_t path_length, stat* user_statbuf)
+int Process::sys$stat(const Syscall::SC_stat_params* user_params)
{
REQUIRE_PROMISE(rpath);
- if (!validate_write_typed(user_statbuf))
+ Syscall::SC_stat_params params;
+ if (!validate_read_and_copy_typed(&params, user_params))
return -EFAULT;
- auto path = get_syscall_path_argument(user_path, path_length);
- if (path.is_error())
- return path.error();
- auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory(), O_NOFOLLOW_NOERROR);
- if (metadata_or_error.is_error())
- return metadata_or_error.error();
- stat statbuf;
- auto result = metadata_or_error.value().stat(statbuf);
- if (result.is_error())
- return result;
- copy_to_user(user_statbuf, &statbuf);
- return 0;
-}
-
-int Process::sys$stat(const char* user_path, size_t path_length, stat* user_statbuf)
-{
- REQUIRE_PROMISE(rpath);
- if (!validate_write_typed(user_statbuf))
+ if (!validate_write_typed(params.statbuf))
return -EFAULT;
- auto path = get_syscall_path_argument(user_path, path_length);
+ auto path = get_syscall_path_argument(params.path);
if (path.is_error())
return path.error();
- auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory());
+ auto metadata_or_error = VFS::the().lookup_metadata(path.value(), current_directory(), params.follow_symlinks ? 0 : O_NOFOLLOW_NOERROR);
if (metadata_or_error.is_error())
return metadata_or_error.error();
stat statbuf;
auto result = metadata_or_error.value().stat(statbuf);
if (result.is_error())
return result;
- copy_to_user(user_statbuf, &statbuf);
+ copy_to_user(params.statbuf, &statbuf);
return 0;
}