Skip to content

Commit

Permalink
添加uid、gid的系统调用(暴力封装返回0) (#434)
Browse files Browse the repository at this point in the history
  • Loading branch information
fslongjin authored Nov 12, 2023
1 parent ea8ad4d commit 02e249f
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 0 deletions.
20 changes: 20 additions & 0 deletions kernel/src/process/syscall.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 changes: 25 additions & 0 deletions kernel/src/syscall/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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),
};
Expand Down

0 comments on commit 02e249f

Please sign in to comment.