diff --git a/src/fs/fuse.rs b/src/fs/fuse.rs index 99ed57e3f9..792804f821 100644 --- a/src/fs/fuse.rs +++ b/src/fs/fuse.rs @@ -14,6 +14,7 @@ use async_lock::Mutex; use async_trait::async_trait; use crate::alloc::string::ToString; +use crate::arch; #[cfg(not(feature = "pci"))] use crate::arch::kernel::mmio::get_filesystem_driver; #[cfg(feature = "pci")] @@ -856,11 +857,24 @@ impl Clone for FuseFileHandle { #[derive(Debug)] pub(crate) struct FuseDirectory { prefix: Option, + attr: FileAttr, } impl FuseDirectory { - pub const fn new(prefix: Option) -> Self { - FuseDirectory { prefix } + pub fn new(prefix: Option) -> Self { + let microseconds = arch::kernel::systemtime::now_micros(); + let t = timespec::from_usec(microseconds as i64); + + FuseDirectory { + prefix, + attr: FileAttr { + st_mode: AccessPermission::from_bits(0o777).unwrap() | AccessPermission::S_IFDIR, + st_atim: t, + st_mtim: t, + st_ctim: t, + ..Default::default() + }, + } } } @@ -870,6 +884,10 @@ impl VfsNode for FuseDirectory { NodeKind::Directory } + fn get_file_attributes(&self) -> Result { + Ok(self.attr) + } + fn traverse_readdir(&self, components: &mut Vec<&str>) -> Result, IoError> { let path: String = if components.is_empty() { if let Some(prefix) = &self.prefix {