Merge updates from ch7

This commit is contained in:
Yifan Wu 2021-02-28 06:38:13 +08:00
parent 394dd61259
commit c4ee62e338
22 changed files with 477 additions and 62 deletions

View file

@ -1,3 +1,4 @@
const SYSCALL_DUP: usize = 24;
const SYSCALL_OPEN: usize = 56;
const SYSCALL_CLOSE: usize = 57;
const SYSCALL_PIPE: usize = 59;
@ -24,6 +25,10 @@ fn syscall(id: usize, args: [usize; 3]) -> isize {
ret
}
pub fn sys_dup(fd: usize) -> isize {
syscall(SYSCALL_DUP, [fd, 0, 0])
}
pub fn sys_open(path: &str, flags: u32) -> isize {
syscall(SYSCALL_OPEN, [path.as_ptr() as usize, flags as usize, 0])
}
@ -65,8 +70,8 @@ pub fn sys_fork() -> isize {
syscall(SYSCALL_FORK, [0, 0, 0])
}
pub fn sys_exec(path: &str) -> isize {
syscall(SYSCALL_EXEC, [path.as_ptr() as usize, 0, 0])
pub fn sys_exec(path: &str, args: &[*const u8]) -> isize {
syscall(SYSCALL_EXEC, [path.as_ptr() as usize, args.as_ptr() as usize, 0])
}
pub fn sys_waitpid(pid: isize, exit_code: *mut i32) -> isize {