Add getuid, getgid, geteuid, getegid, etc.

This commit is contained in:
Tate, Hongliang Tian 2019-04-10 00:13:57 +08:00 committed by Tate Tian
parent e335e8df1d
commit 785d3237b9
3 changed files with 34 additions and 2 deletions

@ -10,7 +10,7 @@ lazy_static! {
task: Default::default(),
status: Default::default(),
pid: 0,
pgid: 0,
pgid: 1,
tgid: 0,
exit_status: 0,
cwd: "/".to_owned(),
@ -38,7 +38,7 @@ impl Process {
task: task,
status: Default::default(),
pid: new_pid,
pgid: new_pid,
pgid: 1, // TODO: implement pgid
tgid: new_pid,
cwd: cwd.to_owned(),
clear_child_tid: None,

@ -68,6 +68,8 @@ pub fn do_clone(
let mut new_thread = new_thread_ref.lock().unwrap();
parent.children.push(Arc::downgrade(&new_thread_ref));
new_thread.parent = Some(parent_ref.clone());
new_thread.tgid = current.tgid;
}
process_table::put(new_thread_pid, new_thread_ref.clone());

@ -86,6 +86,12 @@ pub extern "C" fn dispatch_syscall(
SYS_GETPID => do_getpid(),
SYS_GETTID => do_gettid(),
SYS_GETPPID => do_getppid(),
SYS_GETPGID => do_getpgid(),
SYS_GETUID => do_getuid(),
SYS_GETGID => do_getgid(),
SYS_GETEUID => do_geteuid(),
SYS_GETEGID => do_getegid(),
SYS_RT_SIGACTION => do_rt_sigaction(),
SYS_RT_SIGPROCMASK => do_rt_sigprocmask(),
@ -577,6 +583,30 @@ fn do_getppid() -> Result<isize, Error> {
Ok(ppid as isize)
}
fn do_getpgid() -> Result<isize, Error> {
let pgid = process::do_getpgid();
Ok(pgid as isize)
}
// TODO: implement uid, gid, euid, egid
fn do_getuid() -> Result<isize, Error> {
Ok(0)
}
fn do_getgid() -> Result<isize, Error> {
Ok(0)
}
fn do_geteuid() -> Result<isize, Error> {
Ok(0)
}
fn do_getegid() -> Result<isize, Error> {
Ok(0)
}
fn do_pipe2(fds_u: *mut i32, flags: u32) -> Result<isize, Error> {
check_mut_array(fds_u, 2)?;
// TODO: how to deal with open flags???