Browse Source

添加uid、gid的系统调用(暴力封装返回0) (#434)

LoGin 1 year ago
parent
commit
02e249f30b
2 changed files with 45 additions and 0 deletions
  1. 20 0
      kernel/src/process/syscall.rs
  2. 25 0
      kernel/src/syscall/mod.rs

+ 20 - 0
kernel/src/process/syscall.rs

@@ -300,4 +300,24 @@ impl Syscall {
         let pcb = ProcessManager::current_pcb();
         Ok(pcb.pid)
     }
+
+    pub fn getuid() -> Result<usize, SystemError> {
+        // todo: 增加credit功能之后,需要修改
+        return Ok(0);
+    }
+
+    pub fn getgid() -> Result<usize, SystemError> {
+        // todo: 增加credit功能之后,需要修改
+        return Ok(0);
+    }
+
+    pub fn geteuid() -> Result<usize, SystemError> {
+        // todo: 增加credit功能之后,需要修改
+        return Ok(0);
+    }
+
+    pub fn getegid() -> Result<usize, SystemError> {
+        // todo: 增加credit功能之后,需要修改
+        return Ok(0);
+    }
 }

+ 25 - 0
kernel/src/syscall/mod.rs

@@ -401,6 +401,15 @@ pub const SYS_MKDIR: usize = 83;
 
 pub const SYS_GETTIMEOFDAY: usize = 96;
 
+pub const SYS_GETUID: usize = 102;
+pub const SYS_SYSLOG: usize = 103;
+pub const SYS_GETGID: usize = 104;
+pub const SYS_SETUID: usize = 105;
+
+pub const SYS_SETGID: usize = 106;
+pub const SYS_GETEUID: usize = 107;
+pub const SYS_GETEGID: usize = 108;
+
 pub const SYS_GETPPID: usize = 110;
 pub const SYS_GETPGID: usize = 121;
 
@@ -1139,6 +1148,22 @@ impl Syscall {
                 Ok(0)
             }
             SYS_GETTID => Self::gettid().map(|tid| tid.into()),
+            SYS_GETUID => Self::getuid().map(|uid| uid.into()),
+            SYS_SYSLOG => {
+                kwarn!("SYS_SYSLOG has not yet been implemented");
+                Ok(0)
+            }
+            SYS_GETGID => Self::getgid().map(|gid| gid.into()),
+            SYS_SETUID => {
+                kwarn!("SYS_SETUID has not yet been implemented");
+                Ok(0)
+            }
+            SYS_SETGID => {
+                kwarn!("SYS_SETGID has not yet been implemented");
+                Ok(0)
+            }
+            SYS_GETEUID => Self::geteuid().map(|euid| euid.into()),
+            SYS_GETEGID => Self::getegid().map(|egid| egid.into()),
 
             _ => panic!("Unsupported syscall ID: {}", syscall_num),
         };