1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#[allow(unused_imports)]
use tracing::{debug, error, info, instrument, span, trace, warn, Level};

use super::api::*;
use super::attr::*;

pub struct OpenHandle
where
    Self: Send + Sync,
{
    pub dirty: seqlock::SeqLock<bool>,

    pub inode: u64,
    pub fh: u64,
    pub spec: FileSpec,
    pub kind: FileKind,
    pub attr: FileAttr,
    pub read_only: bool,

    pub children: Vec<DirectoryEntry>,
}

pub struct DirectoryEntry
where
    Self: Send + Sync,
{
    pub inode: u64,
    pub kind: FileKind,
    pub attr: FileAttr,
    pub name: String,
    pub uid: u32,
    pub gid: u32,
}

impl OpenHandle {
    pub fn add_child(&mut self, spec: &FileSpec, uid: u32, gid: u32) {
        self.children.push(DirectoryEntry {
            inode: spec.ino(),
            kind: spec.kind(),
            name: spec.name(),
            attr: FileAttr::new(spec, uid, gid),
            uid,
            gid,
        });
    }
}