Fix openat for incorrect conversion

master
Harry Cheng 5 years ago
parent 0e89d291ab
commit 88e4c2c178

@ -263,12 +263,16 @@ impl Syscall<'_> {
} }
pub fn sys_open(&mut self, path: *const u8, flags: usize, mode: usize) -> SysResult { 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) self.sys_openat(AT_FDCWD, path, flags, mode)
} }
pub fn sys_openat( pub fn sys_openat(
&mut self, &mut self,
dir_fd: usize, in_dir_fd: usize,
path: *const u8, path: *const u8,
flags: usize, flags: usize,
mode: usize, mode: usize,
@ -276,6 +280,12 @@ impl Syscall<'_> {
let mut proc = self.process(); let mut proc = self.process();
let path = check_and_clone_cstr(path)?; let path = check_and_clone_cstr(path)?;
let flags = OpenFlags::from_bits_truncate(flags); let flags = OpenFlags::from_bits_truncate(flags);
let dir_fd = if in_dir_fd == 4294967196 {
AT_FDCWD as usize
} else {
in_dir_fd
};
info!( info!(
"openat: dir_fd: {}, path: {:?}, flags: {:?}, mode: {:#o}", "openat: dir_fd: {}, path: {:?}, flags: {:?}, mode: {:#o}",
dir_fd as isize, path, flags, mode dir_fd as isize, path, flags, mode

Loading…
Cancel
Save