diff options
author | Andreas Kling <kling@serenityos.org> | 2020-02-10 19:32:40 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-02-10 19:49:49 +0100 |
commit | 580a94bc44bcea61bf1b07abf24c1b00e43a1d64 (patch) | |
tree | c2f78a376958434b3b6c97ab191755762f216d22 /Libraries/LibC | |
parent | b67035c3ac5659b26d88c91d03eda6bf19c35df3 (diff) | |
download | serenity-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 'Libraries/LibC')
-rw-r--r-- | Libraries/LibC/unistd.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/Libraries/LibC/unistd.cpp b/Libraries/LibC/unistd.cpp index 4a1d6b1e46..81769a2996 100644 --- a/Libraries/LibC/unistd.cpp +++ b/Libraries/LibC/unistd.cpp @@ -278,24 +278,25 @@ int close(int fd) __RETURN_WITH_ERRNO(rc, rc, -1); } -int lstat(const char* path, struct stat* statbuf) +static int do_stat(const char* path, struct stat* statbuf, bool follow_symlinks) { if (!path) { errno = EFAULT; return -1; } - int rc = syscall(SC_lstat, path, strlen(path), statbuf); + Syscall::SC_stat_params params { { path, strlen(path) }, statbuf, follow_symlinks }; + int rc = syscall(SC_stat, ¶ms); __RETURN_WITH_ERRNO(rc, rc, -1); } +int lstat(const char* path, struct stat* statbuf) +{ + return do_stat(path, statbuf, false); +} + int stat(const char* path, struct stat* statbuf) { - if (!path) { - errno = EFAULT; - return -1; - } - int rc = syscall(SC_stat, path, strlen(path), statbuf); - __RETURN_WITH_ERRNO(rc, rc, -1); + return do_stat(path, statbuf, true); } int fstat(int fd, struct stat* statbuf) |