diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 5fa45bd..d02cb3a 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -338,12 +338,12 @@ dependencies = [ [[package]] name = "rcore-fs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?branch=sefs#c9322710b4ba67c086f500befb8208c6ae353493" +source = "git+https://github.com/rcore-os/rcore-fs?branch=sefs#166616e5ade1a5c929f705fd1564ef0ea337ba72" [[package]] name = "rcore-fs-sfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?branch=sefs#c9322710b4ba67c086f500befb8208c6ae353493" +source = "git+https://github.com/rcore-os/rcore-fs?branch=sefs#166616e5ade1a5c929f705fd1564ef0ea337ba72" dependencies = [ "bitvec 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", diff --git a/kernel/src/fs/pipe.rs b/kernel/src/fs/pipe.rs index 9521904..4f35fc3 100644 --- a/kernel/src/fs/pipe.rs +++ b/kernel/src/fs/pipe.rs @@ -69,6 +69,7 @@ macro_rules! impl_inode { fn get_entry(&self, _id: usize) -> Result { Err(FsError::NotDir) } fn fs(&self) -> Arc { unimplemented!() } fn as_any_ref(&self) -> &Any { self } + fn chmod(&self, _mode: u16) -> Result<()> { Ok(()) } }; } diff --git a/kernel/src/fs/stdio.rs b/kernel/src/fs/stdio.rs index 4987fe6..562e783 100644 --- a/kernel/src/fs/stdio.rs +++ b/kernel/src/fs/stdio.rs @@ -64,6 +64,7 @@ macro_rules! impl_inode { fn get_entry(&self, _id: usize) -> Result { Err(FsError::NotDir) } fn fs(&self) -> Arc { unimplemented!() } fn as_any_ref(&self) -> &Any { self } + fn chmod(&self, _mode: u16) -> Result<()> { Ok(()) } }; } diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 03f2569..2a97b4c 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -725,19 +725,9 @@ impl Process { } }) } - fn lookup_inode(&self, path: &str) -> Result, SysError> { + pub fn lookup_inode(&self, path: &str) -> Result, SysError> { debug!("lookup_inode: cwd {} path {}", self.cwd, path); - if path.len() > 0 && path.as_bytes()[0] == b'/' { - // absolute path - let abs_path = path.split_at(1).1; // skip start '/' - let inode = ROOT_INODE.lookup_follow(abs_path, FOLLOW_MAX_DEPTH)?; - Ok(inode) - } else { - // relative path - let cwd = self.cwd.split_at(1).1; // skip start '/' - let inode = ROOT_INODE.lookup(cwd)?.lookup_follow(path, FOLLOW_MAX_DEPTH)?; - Ok(inode) - } + Ok(ROOT_INODE.lookup(&self.cwd)?.lookup_follow(path, FOLLOW_MAX_DEPTH)?) } } diff --git a/kernel/src/syscall/mod.rs b/kernel/src/syscall/mod.rs index ce68f44..4bfe201 100644 --- a/kernel/src/syscall/mod.rs +++ b/kernel/src/syscall/mod.rs @@ -131,11 +131,15 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize { SYS_GETCWD => sys_getcwd(args[0] as *mut u8, args[1]), // 80 SYS_CHDIR => sys_chdir(args[0] as *const u8), - SYS_GETTIMEOFDAY => sys_gettimeofday(args[0] as *mut TimeVal, args[1] as *const u8), + SYS_FCHOWN => { + warn!("sys_fchown is unimplemented"); + Ok(0) + } SYS_UMASK => { warn!("sys_umask is unimplemented"); Ok(0o777) } + SYS_GETTIMEOFDAY => sys_gettimeofday(args[0] as *mut TimeVal, args[1] as *const u8), // SYS_GETRLIMIT => sys_getrlimit(), SYS_GETRUSAGE => sys_getrusage(args[0], args[1] as *mut RUsage), SYS_SYSINFO => sys_sysinfo(args[0] as *mut SysInfo), @@ -202,10 +206,16 @@ pub fn syscall(id: usize, args: [usize; 6], tf: &mut TrapFrame) -> isize { SYS_OPENAT => sys_openat(args[0], args[1] as *const u8, args[2], args[3]), // TODO: handle `dfd` SYS_MKDIRAT => sys_mkdir(args[1] as *const u8, args[2]), // TODO: handle `dfd` // SYS_MKNODAT => sys_mknod(), + // 260 + SYS_FCHOWNAT => { + warn!("sys_fchownat is unimplemented"); + Ok(0) + }, SYS_NEWFSTATAT => sys_stat(args[1] as *const u8, args[2] as *mut Stat), // TODO: handle `dfd`, `flag` SYS_UNLINKAT => sys_unlink(args[1] as *const u8), // TODO: handle `dfd`, `flag` SYS_RENAMEAT => sys_renameat(args[0], args[1] as *const u8, args[2], args[3] as *const u8), // TODO: handle `olddfd`, `newdfd` SYS_LINKAT => sys_link(args[1] as *const u8, args[3] as *const u8), // TODO: handle `olddfd`, `newdfd`, `flags` + SYS_SYMLINKAT => Err(SysError::EACCES), SYS_FACCESSAT => sys_access(args[1] as *const u8, args[2]), // TODO: handle `dfd` // 280 SYS_UTIMENSAT => { diff --git a/kernel/src/syscall/proc.rs b/kernel/src/syscall/proc.rs index c95d788..446805a 100644 --- a/kernel/src/syscall/proc.rs +++ b/kernel/src/syscall/proc.rs @@ -1,7 +1,7 @@ //! Syscalls for process use super::*; -use crate::fs::{INodeExt, FOLLOW_MAX_DEPTH}; +use crate::fs::INodeExt; /// Fork the current process. Return the child's PID. pub fn sys_fork(tf: &TrapFrame) -> SysResult { @@ -120,7 +120,7 @@ pub fn sys_exec(name: *const u8, argv: *const *const u8, envp: *const *const u8, // Read program file let path = args[0].as_str(); - let inode = crate::fs::ROOT_INODE.lookup_follow(path, FOLLOW_MAX_DEPTH)?; + let inode = proc.lookup_inode(path)?; let buf = inode.read_as_vec()?; // Make new Thread