1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Add getumask(2).

This commit is contained in:
Jonas 'Sortie' Termansen 2014-01-19 22:45:49 +01:00
parent 9771f29138
commit 2fe3595feb
5 changed files with 48 additions and 4 deletions

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
This file is part of Sortix.
@ -147,6 +147,7 @@
#define SYSCALL_SYMLINKAT 123
#define SYSCALL_TCGETWINCURPOS 124
#define SYSCALL_PIPE2 125
#define SYSCALL_MAX_NUM 126 /* index of highest constant + 1 */
#define SYSCALL_GETUMASK 126
#define SYSCALL_MAX_NUM 127 /* index of highest constant + 1 */
#endif

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
This file is part of Sortix.
@ -1208,6 +1208,13 @@ static mode_t sys_umask(mode_t newmask)
return oldmask;
}
static mode_t sys_getumask(void)
{
Process* process = CurrentProcess();
ScopedLock lock(&process->idlock);
return process->umask;
}
void Process::Init()
{
Syscall::Register(SYSCALL_EXEC, (void*) sys_execve);
@ -1216,6 +1223,7 @@ void Process::Init()
Syscall::Register(SYSCALL_GETPGID, (void*) sys_getpgid);
Syscall::Register(SYSCALL_GETPID, (void*) sys_getpid);
Syscall::Register(SYSCALL_GETPPID, (void*) sys_getppid);
Syscall::Register(SYSCALL_GETUMASK, (void*) sys_getumask);
Syscall::Register(SYSCALL_SBRK, (void*) sys_sbrk);
Syscall::Register(SYSCALL_SETPGID, (void*) sys_setpgid);
Syscall::Register(SYSCALL_TFORK, (void*) sys_tfork);

View file

@ -429,6 +429,7 @@ sys/stat/fchmod.o \
sys/stat/fstatat.o \
sys/stat/fstat.o \
sys/stat/futimens.o \
sys/stat/getumask.o \
sys/stat/lstat.o \
sys/stat/mkdirat.o \
sys/stat/mkdir.o \

View file

@ -1,6 +1,6 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013.
Copyright(C) Jonas 'Sortie' Termansen 2011, 2012, 2013, 2014.
This file is part of the Sortix C Library.
@ -105,6 +105,7 @@ int fstat(int fd, struct stat* st);
int fstatat(int dirfd, const char* path, struct stat* buf, int flags);
int futimens(int fd, const struct timespec times[2]);
int lstat(const char* __restrict path, struct stat* __restrict st);
mode_t getumask(void);
int mkdir(const char* path, mode_t mode);
int mkdirat(int dirfd, const char* path, mode_t mode);
/* TODO: mkfifo */

View file

@ -0,0 +1,33 @@
/*******************************************************************************
Copyright(C) Jonas 'Sortie' Termansen 2014.
This file is part of the Sortix C Library.
The Sortix C Library is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at your
option) any later version.
The Sortix C Library is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
License for more details.
You should have received a copy of the GNU Lesser General Public License
along with the Sortix C Library. If not, see <http://www.gnu.org/licenses/>.
sys/stat/getumask.cpp
Get file mode creation mask.
*******************************************************************************/
#include <sys/stat.h>
#include <sys/syscall.h>
DEFN_SYSCALL0(mode_t, sys_getumask, SYSCALL_GETUMASK);
extern "C" mode_t getumask(void)
{
return sys_getumask();
}