diff --git a/kernel/Cargo.lock b/kernel/Cargo.lock index 20120199..bed0e887 100644 --- a/kernel/Cargo.lock +++ b/kernel/Cargo.lock @@ -358,11 +358,11 @@ dependencies = [ "raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)", "rboot 0.1.2", "rcore-console 0.1.0 (git+https://github.com/rcore-os/rcore-console?rev=b7bacf9)", - "rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", - "rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", - "rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", - "rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", - "rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", + "rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", + "rcore-fs-devfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", + "rcore-fs-mountfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", + "rcore-fs-ramfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", + "rcore-fs-sfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", "rcore-memory 0.1.0", "rcore-thread 0.1.0 (git+https://github.com/function2-llx/rcore-thread?rev=8c1022d)", "riscv 0.5.0 (git+https://github.com/rcore-os/riscv)", @@ -388,7 +388,7 @@ dependencies = [ [[package]] name = "rcore-fs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a#7e7c74a921803d6c8edc99b8ebb6fc85774819b9" +source = "git+https://github.com/function2-llx/rcore-fs?rev=837a298#837a298e2d09690b005258479cc1ad3173f0ac40" dependencies = [ "filetime 0.2.9 (registry+https://github.com/rust-lang/crates.io-index)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", @@ -398,42 +398,42 @@ dependencies = [ [[package]] name = "rcore-fs-devfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a#7e7c74a921803d6c8edc99b8ebb6fc85774819b9" +source = "git+https://github.com/function2-llx/rcore-fs?rev=837a298#837a298e2d09690b005258479cc1ad3173f0ac40" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", + "rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rcore-fs-mountfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a#7e7c74a921803d6c8edc99b8ebb6fc85774819b9" +source = "git+https://github.com/function2-llx/rcore-fs?rev=837a298#837a298e2d09690b005258479cc1ad3173f0ac40" dependencies = [ "lazy_static 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", + "rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rcore-fs-ramfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a#7e7c74a921803d6c8edc99b8ebb6fc85774819b9" +source = "git+https://github.com/function2-llx/rcore-fs?rev=837a298#837a298e2d09690b005258479cc1ad3173f0ac40" dependencies = [ "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", + "rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "rcore-fs-sfs" version = "0.1.0" -source = "git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a#7e7c74a921803d6c8edc99b8ebb6fc85774819b9" +source = "git+https://github.com/function2-llx/rcore-fs?rev=837a298#837a298e2d09690b005258479cc1ad3173f0ac40" dependencies = [ "bitvec 0.17.4 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.8 (registry+https://github.com/rust-lang/crates.io-index)", - "rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)", + "rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)", "spin 0.5.2 (registry+https://github.com/rust-lang/crates.io-index)", "static_assertions 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -743,11 +743,11 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum raw-cpuid 6.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "30a9d219c32c9132f7be513c18be77c9881c7107d2ab5569d205a6a0f0e6dc7d" "checksum raw-cpuid 7.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "b4a349ca83373cfa5d6dbb66fd76e58b2cca08da71a5f6400de0a0a6a9bceeaf" "checksum rcore-console 0.1.0 (git+https://github.com/rcore-os/rcore-console?rev=b7bacf9)" = "" -"checksum rcore-fs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)" = "" -"checksum rcore-fs-devfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)" = "" -"checksum rcore-fs-mountfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)" = "" -"checksum rcore-fs-ramfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)" = "" -"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/rcore-os/rcore-fs?rev=7e7c74a)" = "" +"checksum rcore-fs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)" = "" +"checksum rcore-fs-devfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)" = "" +"checksum rcore-fs-mountfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)" = "" +"checksum rcore-fs-ramfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)" = "" +"checksum rcore-fs-sfs 0.1.0 (git+https://github.com/function2-llx/rcore-fs?rev=837a298)" = "" "checksum rcore-thread 0.1.0 (git+https://github.com/function2-llx/rcore-thread?rev=8c1022d)" = "" "checksum redox_syscall 0.1.56 (registry+https://github.com/rust-lang/crates.io-index)" = "2439c63f3f6139d1b57529d16bc3b8bb855230c8efcc5d3a896c8bea7c3b1e84" "checksum register 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "e10f31b6d2299e5620986ad9fcdd66463e125ad72af4f403f9aedf7592d5ccdb" diff --git a/kernel/Cargo.toml b/kernel/Cargo.toml index 7c34869b..2b7e9938 100644 --- a/kernel/Cargo.toml +++ b/kernel/Cargo.toml @@ -66,11 +66,11 @@ bitmap-allocator = { git = "https://github.com/rcore-os/bitmap-allocator" } rcore-console = { git = "https://github.com/rcore-os/rcore-console", rev = "b7bacf9", default-features = false } rcore-memory = { path = "../crate/memory" } rcore-thread = { git = "https://github.com/function2-llx/rcore-thread", rev = "8c1022d" } -rcore-fs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7e7c74a" } -rcore-fs-sfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7e7c74a" } -rcore-fs-ramfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7e7c74a" } -rcore-fs-mountfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7e7c74a" } -rcore-fs-devfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "7e7c74a" } +rcore-fs = { git = "https://github.com/function2-llx/rcore-fs", rev = "837a298" } +rcore-fs-sfs = { git = "https://github.com/function2-llx/rcore-fs", rev = "837a298" } +rcore-fs-ramfs = { git = "https://github.com/function2-llx/rcore-fs", rev = "837a298" } +rcore-fs-mountfs = { git = "https://github.com/function2-llx/rcore-fs", rev = "837a298" } +rcore-fs-devfs = { git = "https://github.com/function2-llx/rcore-fs", rev = "837a298" } compression = { version = "0.1.4", default-features = false, features = ["gzip"] } diff --git a/kernel/src/syscall/fs.rs b/kernel/src/syscall/fs.rs index 5260d8d9..570e993c 100644 --- a/kernel/src/syscall/fs.rs +++ b/kernel/src/syscall/fs.rs @@ -563,7 +563,14 @@ impl Syscall<'_> { file_inode } Err(FsError::EntryNotFound) => { - dir_inode.create(file_name, FileType::File, mode as u32)? + let inode = dir_inode.create(file_name, FileType::File, mode as u32)?; + let mut metadata = inode.metadata()?; + let now = TimeSpec::get_epoch().into(); + metadata.atime = now; + metadata.mtime = now; + metadata.ctime = now; + inode.set_metadata(&metadata)?; + inode } Err(e) => return Err(SysError::from(e)), } @@ -650,7 +657,8 @@ impl Syscall<'_> { let mut proc = self.process(); let stat_ref = unsafe { self.vm().check_write_ptr(stat_ptr)? }; let file = proc.get_file(fd)?; - let stat = Stat::from(file.metadata()?); + let metadata = file.metadata()?; + let stat = Stat::from(metadata); *stat_ref = stat; Ok(0) } diff --git a/kernel/src/syscall/time.rs b/kernel/src/syscall/time.rs index 3424c68a..3220cd15 100644 --- a/kernel/src/syscall/time.rs +++ b/kernel/src/syscall/time.rs @@ -4,6 +4,7 @@ use super::*; use crate::consts::USEC_PER_TICK; use core::time::Duration; use lazy_static::lazy_static; +use rcore_fs::vfs::Timespec; impl Syscall<'_> { pub fn sys_gettimeofday(&mut self, tv: *mut TimeVal, tz: *const u8) -> SysResult { @@ -151,6 +152,15 @@ impl TimeSpec { } } +impl Into for TimeSpec { + fn into(self) -> Timespec { + Timespec { + sec: self.sec as i64, + nsec: self.nsec as i32, + } + } +} + // ignore other fields for now #[repr(C)] pub struct RUsage {