Skip to content

Commit

Permalink
Add umask().
Browse files Browse the repository at this point in the history
  • Loading branch information
awesomekling committed Nov 6, 2018
1 parent 77fe8e8 commit b2d23f8
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 0 deletions.
7 changes: 7 additions & 0 deletions Kernel/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions Kernel/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ class Process : public InlineLinkedListNode<Process> {
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);
Expand Down Expand Up @@ -235,6 +236,7 @@ class Process : public InlineLinkedListNode<Process> {
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);

Expand Down
2 changes: 2 additions & 0 deletions Kernel/Syscall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions Kernel/Syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
1 change: 1 addition & 0 deletions LibC/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ LIBC_OBJS = \
times.o \
termcap.o \
setjmp.o \
stat.o \
entry.o

OBJS = $(AK_OBJS) $(LIBC_OBJS)
Expand Down
10 changes: 10 additions & 0 deletions LibC/sys/stat.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#pragma once

#include <sys/cdefs.h>
#include <sys/types.h>

__BEGIN_DECLS

mode_t umask(mode_t);

__END_DECLS

0 comments on commit b2d23f8

Please sign in to comment.