Kernel: Add fchown() syscall.
This commit is contained in:
parent
51581c21fc
commit
93d3d1ede1
Notes:
sideshowbarker
2024-07-19 13:48:01 +09:00
Author: https://github.com/awesomekling Commit: https://github.com/SerenityOS/serenity/commit/93d3d1ede14
8 changed files with 30 additions and 2 deletions
|
@ -324,3 +324,10 @@ void FileDescriptor::set_file_flags(dword flags)
|
|||
m_should_append = flags & O_APPEND;
|
||||
m_file_flags = flags;
|
||||
}
|
||||
|
||||
KResult FileDescriptor::chown(uid_t uid, gid_t gid)
|
||||
{
|
||||
if (!m_inode)
|
||||
return KResult(-EINVAL);
|
||||
return m_inode->chown(uid, gid);
|
||||
}
|
||||
|
|
|
@ -101,6 +101,8 @@ public:
|
|||
|
||||
off_t offset() const { return m_current_offset; }
|
||||
|
||||
KResult chown(uid_t, gid_t);
|
||||
|
||||
private:
|
||||
friend class VFS;
|
||||
FileDescriptor(RetainPtr<File>&&, SocketRole = SocketRole::None);
|
||||
|
|
|
@ -1991,6 +1991,14 @@ int Process::sys$fchmod(int fd, mode_t mode)
|
|||
return descriptor->fchmod(mode);
|
||||
}
|
||||
|
||||
int Process::sys$fchown(int fd, uid_t uid, gid_t gid)
|
||||
{
|
||||
auto* descriptor = file_descriptor(fd);
|
||||
if (!descriptor)
|
||||
return -EBADF;
|
||||
return descriptor->chown(uid, gid);
|
||||
}
|
||||
|
||||
int Process::sys$chown(const char* pathname, uid_t uid, gid_t gid)
|
||||
{
|
||||
if (!validate_read_str(pathname))
|
||||
|
|
|
@ -177,6 +177,7 @@ public:
|
|||
int sys$chmod(const char* pathname, mode_t);
|
||||
int sys$fchmod(int fd, mode_t);
|
||||
int sys$chown(const char* pathname, uid_t, gid_t);
|
||||
int sys$fchown(int fd, uid_t, gid_t);
|
||||
int sys$socket(int domain, int type, int protocol);
|
||||
int sys$bind(int sockfd, const sockaddr* addr, socklen_t);
|
||||
int sys$listen(int sockfd, int backlog);
|
||||
|
|
|
@ -242,6 +242,8 @@ static dword handle(RegisterDump& regs, dword function, dword arg1, dword arg2,
|
|||
return current->process().sys$release_shared_buffer((int)arg1);
|
||||
case Syscall::SC_chown:
|
||||
return current->process().sys$chown((const char*)arg1, (uid_t)arg2, (gid_t)arg3);
|
||||
case Syscall::SC_fchown:
|
||||
return current->process().sys$fchown((int)arg1, (uid_t)arg2, (gid_t)arg3);
|
||||
case Syscall::SC_restore_signal_mask:
|
||||
return current->process().sys$restore_signal_mask((dword)arg1);
|
||||
case Syscall::SC_seal_shared_buffer:
|
||||
|
|
|
@ -106,8 +106,9 @@
|
|||
__ENUMERATE_SYSCALL(beep) \
|
||||
__ENUMERATE_SYSCALL(getsockname) \
|
||||
__ENUMERATE_SYSCALL(getpeername) \
|
||||
__ENUMERATE_SYSCALL(sched_setparam) \
|
||||
__ENUMERATE_SYSCALL(sched_getparam)
|
||||
__ENUMERATE_SYSCALL(sched_setparam) \
|
||||
__ENUMERATE_SYSCALL(sched_getparam) \
|
||||
__ENUMERATE_SYSCALL(fchown) \
|
||||
|
||||
namespace Syscall {
|
||||
|
||||
|
|
|
@ -28,6 +28,12 @@ int chown(const char* pathname, uid_t uid, gid_t gid)
|
|||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
int fchown(int fd, uid_t uid, gid_t gid)
|
||||
{
|
||||
int rc = syscall(SC_fchown, fd, uid, gid);
|
||||
__RETURN_WITH_ERRNO(rc, rc, -1);
|
||||
}
|
||||
|
||||
pid_t fork()
|
||||
{
|
||||
int rc = syscall(SC_fork);
|
||||
|
|
|
@ -88,6 +88,7 @@ long fpathconf(int fd, int name);
|
|||
long pathconf(const char* path, int name);
|
||||
char* getlogin();
|
||||
int chown(const char* pathname, uid_t, gid_t);
|
||||
int fchown(int fd, uid_t, gid_t);
|
||||
int ftruncate(int fd, off_t length);
|
||||
|
||||
enum
|
||||
|
|
Loading…
Add table
Reference in a new issue