瀏覽代碼

Add umask().

Andreas Kling 6 年之前
父節點
當前提交
b2d23f83ab
共有 6 個文件被更改,包括 23 次插入0 次删除
  1. 7 0
      Kernel/Process.cpp
  2. 2 0
      Kernel/Process.h
  3. 2 0
      Kernel/Syscall.cpp
  4. 1 0
      Kernel/Syscall.h
  5. 1 0
      LibC/Makefile
  6. 10 0
      LibC/sys/stat.h

+ 7 - 0
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)

+ 2 - 0
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);
 

+ 2 - 0
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;

+ 1 - 0
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))

+ 1 - 0
LibC/Makefile

@@ -23,6 +23,7 @@ LIBC_OBJS = \
        times.o \
        termcap.o \
        setjmp.o \
+       stat.o \
        entry.o
 
 OBJS = $(AK_OBJS) $(LIBC_OBJS)

+ 10 - 0
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