Add sys_dup && support input/output redirection in user_shell

This commit is contained in:
Yifan Wu 2021-02-27 22:27:08 +08:00
parent ff685b86c8
commit 685ca2c1ea
6 changed files with 93 additions and 13 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])
}