diff options
| author | Alejandro Soto <alejandro@34project.org> | 2022-01-03 07:13:53 -0600 |
|---|---|---|
| committer | Alejandro Soto <alejandro@34project.org> | 2022-01-03 07:13:53 -0600 |
| commit | 2b6a6881cb1e816f7eb0327c0bef5e643889af2c (patch) | |
| tree | f1cd17faf3666c8394f7d489278e9663453b8ddd /src | |
| parent | dc95a1a9f4abed042d2350eda2e870de20545be9 (diff) | |
Split io::Known into io::Known and io::Stat
Diffstat (limited to 'src')
| -rw-r--r-- | src/fuse/io.rs | 10 | ||||
| -rw-r--r-- | src/fuse/ops.rs | 19 |
2 files changed, 18 insertions, 11 deletions
diff --git a/src/fuse/io.rs b/src/fuse/io.rs index 3d2445e..c0356ff 100644 --- a/src/fuse/io.rs +++ b/src/fuse/io.rs @@ -25,10 +25,16 @@ pub enum Interruptible<'o, O: Operation<'o>, T> { Interrupted(Done<'o>), } -pub trait Known { +pub trait Stat { fn ino(&self) -> Ino; fn inode_type(&self) -> EntryType; fn attrs(&self) -> (Attrs, Ttl); +} + +pub trait Known { + type Inode: Stat; + + fn inode(&self) -> &Self::Inode; fn unveil(self); } @@ -271,7 +277,7 @@ impl Attrs { }) } - pub(crate) fn finish(self, inode: &impl Known) -> proto::Attrs { + pub(crate) fn finish(self, inode: &impl Stat) -> proto::Attrs { let Ino(ino) = inode.ino(); let inode_type = match inode.inode_type() { EntryType::Fifo => SFlag::S_IFIFO, diff --git a/src/fuse/ops.rs b/src/fuse/ops.rs index becc143..c688669 100644 --- a/src/fuse/ops.rs +++ b/src/fuse/ops.rs @@ -12,7 +12,7 @@ use crate::{ }; use super::{ - io::{AccessFlags, Entry, EntryType, FsInfo, Interruptible, Known, OpenFlags}, + io::{AccessFlags, Entry, EntryType, FsInfo, Interruptible, Known, OpenFlags, Stat}, private_trait::Sealed, Done, Operation, Reply, Request, }; @@ -71,10 +71,10 @@ op! { /// The requested entry was found. The FUSE client will become aware of the found inode if /// it wasn't before. This result may be cached by the client for up to the given TTL. pub fn found(self, entry: impl Known, ttl: Ttl) -> Done<'o> { - let (attrs, attrs_ttl) = entry.attrs(); - let attrs = attrs.finish(&entry); + let (attrs, attrs_ttl) = entry.inode().attrs(); + let attrs = attrs.finish(entry.inode()); - let done = self.single(&make_entry((entry.ino(), ttl), (attrs, attrs_ttl))); + let done = self.single(&make_entry((entry.inode().ino(), ttl), (attrs, attrs_ttl))); entry.unveil(); done @@ -140,7 +140,7 @@ op! { } impl Reply { - pub fn known(self, inode: &impl Known) -> Done<'o> { + pub fn known(self, inode: &impl Stat) -> Done<'o> { let (attrs, ttl) = inode.attrs(); let attrs = attrs.finish(inode); @@ -598,7 +598,8 @@ impl<'o, B: BufMut + AsRef<[u8]>> Reply<'o, BufferedReaddir<B>> { return Interruptible::Interrupted(self.end()); } - let entry_type = match entry.inode.inode_type() { + let inode = entry.inode.inode(); + let entry_type = match inode.inode_type() { EntryType::Fifo => SFlag::S_IFIFO, EntryType::CharacterDevice => SFlag::S_IFCHR, EntryType::Directory => SFlag::S_IFDIR, @@ -608,7 +609,7 @@ impl<'o, B: BufMut + AsRef<[u8]>> Reply<'o, BufferedReaddir<B>> { EntryType::Socket => SFlag::S_IFSOCK, }; - let ino = entry.inode.ino(); + let ino = inode.ino(); let dirent = proto::Dirent { ino: ino.as_raw(), off: entry.offset, @@ -622,8 +623,8 @@ impl<'o, B: BufMut + AsRef<[u8]>> Reply<'o, BufferedReaddir<B>> { } let ent = if self.tail.is_plus { - let (attrs, attrs_ttl) = entry.inode.attrs(); - let attrs = attrs.finish(&entry.inode); + let (attrs, attrs_ttl) = inode.attrs(); + let attrs = attrs.finish(inode); let entry_out = make_entry((ino, entry.ttl), (attrs, attrs_ttl)); if name != ".".as_bytes() && name != "..".as_bytes() { |
