From 88e4c2c1781cd69166efddefd601c3e179c1a79c Mon Sep 17 00:00:00 2001 From: Harry Cheng Date: Mon, 29 Jul 2019 23:25:27 +0800 Subject: [PATCH] Fix openat for incorrect conversion --- kernel/src/syscall/fs.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 2566626..f5c568f 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -263,12 +263,16 @@ impl Syscall<'_> { } pub fn sys_open(&mut self, path: *const u8, flags: usize, mode: usize) -> SysResult { + info!( + "open: path: {:?}, flags: {:?}, mode: {:#o}", + path, flags, mode + ); self.sys_openat(AT_FDCWD, path, flags, mode) } pub fn sys_openat( &mut self, - dir_fd: usize, + in_dir_fd: usize, path: *const u8, flags: usize, mode: usize, @@ -276,6 +280,12 @@ impl Syscall<'_> { let mut proc = self.process(); let path = check_and_clone_cstr(path)?; let flags = OpenFlags::from_bits_truncate(flags); + let dir_fd = if in_dir_fd == 4294967196 { + AT_FDCWD as usize + } else { + in_dir_fd + }; + info!( "openat: dir_fd: {}, path: {:?}, flags: {:?}, mode: {:#o}", dir_fd as isize, path, flags, mode