Add fchmod(2).
This commit is contained in:
parent
c1280bedb0
commit
f21462bf18
|
@ -1,6 +1,6 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
|
|
||||||
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012.
|
Copyright(C) Jonas 'Sortie' Termansen 2012.
|
||||||
|
|
||||||
This file is part of the Sortix C Library.
|
This file is part of the Sortix C Library.
|
||||||
|
|
||||||
|
@ -22,15 +22,13 @@
|
||||||
|
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
|
|
||||||
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <sys/syscall.h>
|
#include <sys/syscall.h>
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
// TODO: Implement this in the kernel.
|
DEFN_SYSCALL2(int, sys_fchmod, SYSCALL_FCHMOD, int, mode_t);
|
||||||
|
|
||||||
extern "C" int fchmod(int fd, mode_t mode)
|
extern "C" int fchmod(int fd, mode_t mode)
|
||||||
{
|
{
|
||||||
(void) fd;
|
return sys_fchmod(fd, mode);
|
||||||
(void) mode;
|
|
||||||
errno = ENOSYS;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@
|
||||||
#define SYSCALL_TRUNCATEAT 65
|
#define SYSCALL_TRUNCATEAT 65
|
||||||
#define SYSCALL_FCHOWNAT 66
|
#define SYSCALL_FCHOWNAT 66
|
||||||
#define SYSCALL_FCHOWN 67
|
#define SYSCALL_FCHOWN 67
|
||||||
#define SYSCALL_MAX_NUM 68 /* index of highest constant + 1 */
|
#define SYSCALL_FCHMOD 68
|
||||||
|
#define SYSCALL_MAX_NUM 69 /* index of highest constant + 1 */
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -384,6 +384,15 @@ static int sys_chown(const char* path, uid_t owner, gid_t group)
|
||||||
return sys_fchownat(AT_FDCWD, path, owner, group, 0);
|
return sys_fchownat(AT_FDCWD, path, owner, group, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int sys_fchmod(int fd, mode_t mode)
|
||||||
|
{
|
||||||
|
Ref<Descriptor> desc = CurrentProcess()->GetDescriptor(fd);
|
||||||
|
if ( !desc )
|
||||||
|
return -1;
|
||||||
|
ioctx_t ctx; SetupUserIOCtx(&ctx);
|
||||||
|
return desc->chmod(&ctx, mode);
|
||||||
|
}
|
||||||
|
|
||||||
static int sys_chmod(const char* path, mode_t mode)
|
static int sys_chmod(const char* path, mode_t mode)
|
||||||
{
|
{
|
||||||
char* pathcopy = GetStringFromUser(path);
|
char* pathcopy = GetStringFromUser(path);
|
||||||
|
@ -478,6 +487,7 @@ void Init()
|
||||||
Syscall::Register(SYSCALL_DUP2, (void*) sys_dup2);
|
Syscall::Register(SYSCALL_DUP2, (void*) sys_dup2);
|
||||||
Syscall::Register(SYSCALL_FACCESSAT, (void*) sys_faccessat);
|
Syscall::Register(SYSCALL_FACCESSAT, (void*) sys_faccessat);
|
||||||
Syscall::Register(SYSCALL_FCHDIR, (void*) sys_fchdir);
|
Syscall::Register(SYSCALL_FCHDIR, (void*) sys_fchdir);
|
||||||
|
Syscall::Register(SYSCALL_FCHMOD, (void*) sys_fchmod);
|
||||||
Syscall::Register(SYSCALL_FCHOWNAT, (void*) sys_fchownat);
|
Syscall::Register(SYSCALL_FCHOWNAT, (void*) sys_fchownat);
|
||||||
Syscall::Register(SYSCALL_FCHOWN, (void*) sys_fchown);
|
Syscall::Register(SYSCALL_FCHOWN, (void*) sys_fchown);
|
||||||
Syscall::Register(SYSCALL_FCNTL, (void*) sys_fcntl);
|
Syscall::Register(SYSCALL_FCNTL, (void*) sys_fcntl);
|
||||||
|
|
Loading…
Reference in New Issue