Kernel/LibC: Implement fchmod

This commit is contained in:
Bananymous 2024-08-25 15:07:42 +03:00
parent 2ce7205c80
commit 991ae4383a
4 changed files with 18 additions and 4 deletions

View File

@ -119,8 +119,9 @@ namespace Kernel
BAN::ErrorOr<long> sys_pread(int fd, void* buffer, size_t count, off_t offset);
BAN::ErrorOr<long> sys_chmod(const char*, mode_t);
BAN::ErrorOr<long> sys_chown(const char*, uid_t, gid_t);
BAN::ErrorOr<long> sys_chmod(const char* path, mode_t mode);
BAN::ErrorOr<long> sys_fchmod(int fildes, mode_t mode);
BAN::ErrorOr<long> sys_chown(const char* path, uid_t uid, gid_t gid);
BAN::ErrorOr<long> sys_socket(int domain, int type, int protocol);
BAN::ErrorOr<long> sys_getsockname(int socket, sockaddr* address, socklen_t* address_len);

View File

@ -1103,6 +1103,18 @@ namespace Kernel
return 0;
}
BAN::ErrorOr<long> Process::sys_fchmod(int fildes, mode_t mode)
{
if (mode & S_IFMASK)
return BAN::Error::from_errno(EINVAL);
LockGuard _(m_process_lock);
auto inode = TRY(m_open_file_descriptors.inode_of(fildes));
TRY(inode->chmod(mode));
return 0;
}
BAN::ErrorOr<long> Process::sys_chown(const char* path, uid_t uid, gid_t gid)
{
LockGuard _(m_process_lock);

View File

@ -55,6 +55,7 @@ __BEGIN_DECLS
O(SYS_TTY_CTRL, tty_ctrl) \
O(SYS_POWEROFF, poweroff) \
O(SYS_CHMOD, chmod) \
O(SYS_FCHMOD, fchmod) \
O(SYS_CREATE, create) \
O(SYS_CREATE_DIR, create_dir) \
O(SYS_UNLINK, unlink) \

View File

@ -13,9 +13,9 @@ int chmod(const char* path, mode_t mode)
return syscall(SYS_CHMOD, path, mode);
}
int fchmod(int, mode_t)
int fchmod(int fildes, mode_t mode)
{
ASSERT_NOT_REACHED();
return syscall(SYS_FCHMOD, fildes, mode);
}
int fstat(int fildes, struct stat* buf)