mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:27:34 +00:00
Kernel+LibC+LibCore: Add lchown and fchownat functions
This modifies sys$chown to allow specifying whether or not to follow symlinks and in which directory. This was then used to implement lchown and fchownat in LibC and LibCore.
This commit is contained in:
parent
344cfa0db4
commit
63760603f3
8 changed files with 64 additions and 7 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue