Kernel/LibC: Implement all chown family function with fchownat

This commit is contained in:
2024-09-17 18:35:01 +03:00
parent 4aa466b948
commit e431e90b20
4 changed files with 49 additions and 9 deletions

View File

@@ -57,7 +57,7 @@ __BEGIN_DECLS
O(SYS_READLINKAT, readlinkat) \
O(SYS_MSYNC, msync) \
O(SYS_PREAD, pread) \
O(SYS_CHOWN, chown) \
O(SYS_FCHOWNAT, fchownat) \
O(SYS_LOAD_KEYMAP, load_keymap) \
O(SYS_SOCKET, socket) \
O(SYS_BIND, bind) \

View File

@@ -315,7 +315,22 @@ int chdir(const char* path)
int chown(const char* path, uid_t owner, gid_t group)
{
return syscall(SYS_CHOWN, path, owner, group);
return fchownat(AT_FDCWD, path, owner, group, 0);
}
int lchown(const char* path, uid_t owner, gid_t group)
{
return fchownat(AT_FDCWD, path, owner, group, AT_SYMLINK_NOFOLLOW);
}
int fchown(int fildes, uid_t owner, gid_t group)
{
return fchownat(fildes, nullptr, owner, group, 0);
}
int fchownat(int fd, const char* path, uid_t owner, gid_t group, int flag)
{
return syscall(SYS_FCHOWNAT, fd, path, owner, group, flag);
}
void sync(void)