diff options
Diffstat (limited to 'Userland/Libraries/LibC/unistd.cpp')
-rw-r--r-- | Userland/Libraries/LibC/unistd.cpp | 24 |
1 files changed, 23 insertions, 1 deletions
diff --git a/Userland/Libraries/LibC/unistd.cpp b/Userland/Libraries/LibC/unistd.cpp index 2c0ba9a8f1..d2a7c134bb 100644 --- a/Userland/Libraries/LibC/unistd.cpp +++ b/Userland/Libraries/LibC/unistd.cpp @@ -38,13 +38,24 @@ static __thread int s_cached_tid = 0; static int s_cached_pid = 0; +int lchown(const char* pathname, uid_t uid, gid_t gid) +{ + if (!pathname) { + errno = EFAULT; + return -1; + } + Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid, AT_FDCWD, false }; + int rc = syscall(SC_chown, ¶ms); + __RETURN_WITH_ERRNO(rc, rc, -1); +} + int chown(const char* pathname, uid_t uid, gid_t gid) { if (!pathname) { errno = EFAULT; return -1; } - Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid }; + Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid, AT_FDCWD, true }; int rc = syscall(SC_chown, ¶ms); __RETURN_WITH_ERRNO(rc, rc, -1); } @@ -55,6 +66,17 @@ int fchown(int fd, uid_t uid, gid_t gid) __RETURN_WITH_ERRNO(rc, rc, -1); } +int fchownat(int fd, const char* pathname, uid_t uid, gid_t gid, int flags) +{ + if (!pathname) { + errno = EFAULT; + return -1; + } + Syscall::SC_chown_params params { { pathname, strlen(pathname) }, uid, gid, fd, !(flags & AT_SYMLINK_NOFOLLOW) }; + int rc = syscall(SC_chown, ¶ms); + __RETURN_WITH_ERRNO(rc, rc, -1); +} + pid_t fork() { __pthread_fork_prepare(); |