summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <awesomekling@gmail.com>2018-11-06 13:40:23 +0100
committerAndreas Kling <awesomekling@gmail.com>2018-11-06 13:47:56 +0100
commitb2d23f83ab04ee1e7ca5d16ec32416939077bc4c (patch)
tree4b4bd7b7a70d693394dac0f26ae75cb7c446bd6e
parent77fe8e8363140d600c4e9cfa4b5f6212a2c71234 (diff)
downloadserenity-b2d23f83ab04ee1e7ca5d16ec32416939077bc4c.zip
Add umask().
-rw-r--r--Kernel/Process.cpp7
-rw-r--r--Kernel/Process.h2
-rw-r--r--Kernel/Syscall.cpp2
-rw-r--r--Kernel/Syscall.h1
-rw-r--r--LibC/Makefile1
-rw-r--r--LibC/sys/stat.h10
6 files changed, 23 insertions, 0 deletions
diff --git a/Kernel/Process.cpp b/Kernel/Process.cpp
index e207870781..7ecddc2ae6 100644
--- a/Kernel/Process.cpp
+++ b/Kernel/Process.cpp
@@ -1320,6 +1320,13 @@ pid_t Process::sys$getppid()
return m_ppid;
}
+mode_t Process::sys$umask(mode_t mask)
+{
+ auto old_mask = m_umask;
+ m_umask = mask;
+ return old_mask;
+}
+
pid_t Process::sys$waitpid(pid_t waitee, int* wstatus, int options)
{
if (wstatus)
diff --git a/Kernel/Process.h b/Kernel/Process.h
index 7558b8bfaf..64deb9a44a 100644
--- a/Kernel/Process.h
+++ b/Kernel/Process.h
@@ -104,6 +104,7 @@ public:
gid_t sys$getegid();
pid_t sys$getpid();
pid_t sys$getppid();
+ mode_t sys$umask(mode_t);
int sys$open(const char* path, int options);
int sys$close(int fd);
ssize_t sys$read(int fd, void* outbuf, size_t nread);
@@ -235,6 +236,7 @@ private:
LinearAddress m_return_from_signal_trampoline;
pid_t m_ppid { 0 };
+ mode_t m_umask { 022 };
static void notify_waiters(pid_t waitee, int exit_status, int signal);
diff --git a/Kernel/Syscall.cpp b/Kernel/Syscall.cpp
index 83ffab9631..aa6d84cd1a 100644
--- a/Kernel/Syscall.cpp
+++ b/Kernel/Syscall.cpp
@@ -150,6 +150,8 @@ static DWORD handle(RegisterDump& regs, DWORD function, DWORD arg1, DWORD arg2,
return current->sys$dup2((int)arg1, (int)arg2);
case Syscall::SC_sigaction:
return current->sys$sigaction((int)arg1, (const Unix::sigaction*)arg2, (Unix::sigaction*)arg3);
+ case Syscall::SC_umask:
+ return current->sys$umask((mode_t)arg1);
default:
kprintf("<%u> int0x80: Unknown function %x requested {%x, %x, %x}\n", current->pid(), function, arg1, arg2, arg3);
break;
diff --git a/Kernel/Syscall.h b/Kernel/Syscall.h
index 04cae54102..53b3ed848b 100644
--- a/Kernel/Syscall.h
+++ b/Kernel/Syscall.h
@@ -51,6 +51,7 @@
__ENUMERATE_SYSCALL(dup2) \
__ENUMERATE_SYSCALL(sigaction) \
__ENUMERATE_SYSCALL(getppid) \
+ __ENUMERATE_SYSCALL(umask) \
#define DO_SYSCALL_A0(function) Syscall::invoke((dword)(function))
diff --git a/LibC/Makefile b/LibC/Makefile
index a0036d427b..03f367cf58 100644
--- a/LibC/Makefile
+++ b/LibC/Makefile
@@ -23,6 +23,7 @@ LIBC_OBJS = \
times.o \
termcap.o \
setjmp.o \
+ stat.o \
entry.o
OBJS = $(AK_OBJS) $(LIBC_OBJS)
diff --git a/LibC/sys/stat.h b/LibC/sys/stat.h
index e69de29bb2..902e63268d 100644
--- a/LibC/sys/stat.h
+++ b/LibC/sys/stat.h
@@ -0,0 +1,10 @@
+#pragma once
+
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+__BEGIN_DECLS
+
+mode_t umask(mode_t);
+
+__END_DECLS