Skip to content

Commit

Permalink
add file attributes for mounted directories
Browse files Browse the repository at this point in the history
  • Loading branch information
stlankes committed May 19, 2024
1 parent 716ee54 commit 7d4303c
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions src/fs/fuse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand Down Expand Up @@ -856,11 +857,24 @@ impl Clone for FuseFileHandle {
#[derive(Debug)]
pub(crate) struct FuseDirectory {
prefix: Option<String>,
attr: FileAttr,
}

impl FuseDirectory {
pub const fn new(prefix: Option<String>) -> Self {
FuseDirectory { prefix }
pub fn new(prefix: Option<String>) -> 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()
},
}
}
}

Expand All @@ -870,6 +884,10 @@ impl VfsNode for FuseDirectory {
NodeKind::Directory
}

fn get_file_attributes(&self) -> Result<FileAttr, IoError> {
Ok(self.attr)
}

fn traverse_readdir(&self, components: &mut Vec<&str>) -> Result<Vec<DirectoryEntry>, IoError> {
let path: String = if components.is_empty() {
if let Some(prefix) = &self.prefix {
Expand Down

0 comments on commit 7d4303c

Please sign in to comment.