|
|
@ -274,7 +274,7 @@ impl Syscall<'_> {
|
|
|
|
mode: usize,
|
|
|
|
mode: usize,
|
|
|
|
) -> SysResult {
|
|
|
|
) -> SysResult {
|
|
|
|
let mut proc = self.process();
|
|
|
|
let mut proc = self.process();
|
|
|
|
let path = unsafe { 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);
|
|
|
|
info!(
|
|
|
|
info!(
|
|
|
|
"openat: dir_fd: {}, path: {:?}, flags: {:?}, mode: {:#o}",
|
|
|
|
"openat: dir_fd: {}, path: {:?}, flags: {:?}, mode: {:#o}",
|
|
|
@ -338,7 +338,7 @@ impl Syscall<'_> {
|
|
|
|
) -> SysResult {
|
|
|
|
) -> SysResult {
|
|
|
|
// TODO: check permissions based on uid/gid
|
|
|
|
// TODO: check permissions based on uid/gid
|
|
|
|
let proc = self.process();
|
|
|
|
let proc = self.process();
|
|
|
|
let path = unsafe { check_and_clone_cstr(path)? };
|
|
|
|
let path = check_and_clone_cstr(path)?;
|
|
|
|
let flags = AtFlags::from_bits_truncate(flags);
|
|
|
|
let flags = AtFlags::from_bits_truncate(flags);
|
|
|
|
if !proc.pid.is_init() {
|
|
|
|
if !proc.pid.is_init() {
|
|
|
|
// we trust pid 0 process
|
|
|
|
// we trust pid 0 process
|
|
|
@ -347,7 +347,7 @@ impl Syscall<'_> {
|
|
|
|
dirfd as isize, path, mode, flags
|
|
|
|
dirfd as isize, path, mode, flags
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
let inode =
|
|
|
|
let _inode =
|
|
|
|
proc.lookup_inode_at(dirfd, &path, !flags.contains(AtFlags::SYMLINK_NOFOLLOW))?;
|
|
|
|
proc.lookup_inode_at(dirfd, &path, !flags.contains(AtFlags::SYMLINK_NOFOLLOW))?;
|
|
|
|
Ok(0)
|
|
|
|
Ok(0)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -419,7 +419,7 @@ impl Syscall<'_> {
|
|
|
|
len: usize,
|
|
|
|
len: usize,
|
|
|
|
) -> SysResult {
|
|
|
|
) -> SysResult {
|
|
|
|
let proc = self.process();
|
|
|
|
let proc = self.process();
|
|
|
|
let path = unsafe { check_and_clone_cstr(path)? };
|
|
|
|
let path = check_and_clone_cstr(path)?;
|
|
|
|
let slice = unsafe { self.vm().check_write_array(base, len)? };
|
|
|
|
let slice = unsafe { self.vm().check_write_array(base, len)? };
|
|
|
|
info!(
|
|
|
|
info!(
|
|
|
|
"readlinkat: dirfd: {}, path: {:?}, base: {:?}, len: {}",
|
|
|
|
"readlinkat: dirfd: {}, path: {:?}, base: {:?}, len: {}",
|
|
|
@ -465,7 +465,7 @@ impl Syscall<'_> {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn sys_truncate(&mut self, path: *const u8, len: usize) -> SysResult {
|
|
|
|
pub fn sys_truncate(&mut self, path: *const u8, len: usize) -> SysResult {
|
|
|
|
let proc = self.process();
|
|
|
|
let proc = self.process();
|
|
|
|
let path = unsafe { check_and_clone_cstr(path)? };
|
|
|
|
let path = check_and_clone_cstr(path)?;
|
|
|
|
info!("truncate: path: {:?}, len: {}", path, len);
|
|
|
|
info!("truncate: path: {:?}, len: {}", path, len);
|
|
|
|
proc.lookup_inode(&path)?.resize(len)?;
|
|
|
|
proc.lookup_inode(&path)?.resize(len)?;
|
|
|
|
Ok(0)
|
|
|
|
Ok(0)
|
|
|
@ -678,7 +678,7 @@ impl Syscall<'_> {
|
|
|
|
|
|
|
|
|
|
|
|
pub fn sys_unlinkat(&mut self, dirfd: usize, path: *const u8, flags: usize) -> SysResult {
|
|
|
|
pub fn sys_unlinkat(&mut self, dirfd: usize, path: *const u8, flags: usize) -> SysResult {
|
|
|
|
let proc = self.process();
|
|
|
|
let proc = self.process();
|
|
|
|
let path = unsafe { check_and_clone_cstr(path)? };
|
|
|
|
let path = check_and_clone_cstr(path)?;
|
|
|
|
let flags = AtFlags::from_bits_truncate(flags);
|
|
|
|
let flags = AtFlags::from_bits_truncate(flags);
|
|
|
|
info!(
|
|
|
|
info!(
|
|
|
|
"unlinkat: dirfd: {}, path: {:?}, flags: {:?}",
|
|
|
|
"unlinkat: dirfd: {}, path: {:?}, flags: {:?}",
|
|
|
@ -876,7 +876,7 @@ impl Process {
|
|
|
|
dirfd: usize,
|
|
|
|
dirfd: usize,
|
|
|
|
path: &str,
|
|
|
|
path: &str,
|
|
|
|
follow: bool,
|
|
|
|
follow: bool,
|
|
|
|
) -> Result<Arc<INode>, SysError> {
|
|
|
|
) -> Result<Arc<dyn INode>, SysError> {
|
|
|
|
debug!(
|
|
|
|
debug!(
|
|
|
|
"lookup_inode_at: dirfd: {:?}, cwd: {:?}, path: {:?}, follow: {:?}",
|
|
|
|
"lookup_inode_at: dirfd: {:?}, cwd: {:?}, path: {:?}, follow: {:?}",
|
|
|
|
dirfd as isize, self.cwd, path, follow
|
|
|
|
dirfd as isize, self.cwd, path, follow
|
|
|
@ -916,7 +916,7 @@ impl Process {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
pub fn lookup_inode(&self, path: &str) -> Result<Arc<INode>, SysError> {
|
|
|
|
pub fn lookup_inode(&self, path: &str) -> Result<Arc<dyn INode>, SysError> {
|
|
|
|
self.lookup_inode_at(AT_FDCWD, path, true)
|
|
|
|
self.lookup_inode_at(AT_FDCWD, path, true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|