summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2021-12-28 22:28:05 -0600
committerAlejandro Soto <alejandro@34project.org>2021-12-28 22:28:05 -0600
commit606846f23726c3472e6e12b17447b102ad6158cc (patch)
tree6540f5687b267c116b727c0b6c11f77ee3ab6b5a
parent808d7b000bd02d8238ba7b0f1d6800428de661ef (diff)
Add missing request accessors
Diffstat (limited to '')
-rw-r--r--src/fuse/ops.rs72
1 files changed, 63 insertions, 9 deletions
diff --git a/src/fuse/ops.rs b/src/fuse/ops.rs
index 1a5a578..66708ad 100644
--- a/src/fuse/ops.rs
+++ b/src/fuse/ops.rs
@@ -96,6 +96,19 @@ op! {
type ReplyTail = ();
}
+ impl Request {
+ pub fn forget_list(&self) -> impl '_ + Iterator<Item = (Ino, u64)> {
+ use proto::OpcodeSelect::*;
+
+ let slice = match self.body {
+ Match((_, slice)) => slice,
+ Alt(single) => std::slice::from_ref(single),
+ };
+
+ slice.iter().map(|forget| (Ino(forget.ino), forget.nlookup))
+ }
+ }
+
impl Reply {
pub fn ok(self) -> Done<'o> {
// No reply for forget requests
@@ -110,6 +123,12 @@ op! {
type ReplyTail = ();
}
+ impl Request {
+ pub fn handle(&self) -> u64 {
+ self.body.fh
+ }
+ }
+
impl Reply {
pub fn known(self, inode: &impl Known) -> Done<'o> {
let (attrs, ttl) = inode.attrs();
@@ -175,16 +194,44 @@ op! {
op! {
Read {
- type RequestBody = ();
+ type RequestBody = &'o proto::ReadIn;
type ReplyTail = ();
}
+
+ impl Request {
+ pub fn handle(&self) -> u64 {
+ self.body.fh
+ }
+
+ pub fn offset(&self) -> u64 {
+ self.body.offset
+ }
+
+ pub fn size(&self) -> u32 {
+ self.body.size
+ }
+ }
}
op! {
Write {
- type RequestBody = &'o proto::WriteIn;
+ type RequestBody = (&'o proto::WriteIn, &'o [u8]);
type ReplyTail = ();
}
+
+ impl Request {
+ pub fn handle(&self) -> u64 {
+ self.body.0.fh
+ }
+
+ pub fn offset(&self) -> u64 {
+ self.body.0.offset
+ }
+
+ pub fn data(&self) -> &[u8] {
+ self.body.1
+ }
+ }
}
op! {
@@ -250,6 +297,12 @@ op! {
type RequestBody = &'o proto::ReleaseIn;
type ReplyTail = ();
}
+
+ impl Request {
+ pub fn handle(&self) -> u64 {
+ self.body.fh
+ }
+ }
}
op! {
@@ -266,10 +319,18 @@ op! {
}
impl Request {
+ pub fn handle(&self) -> u64 {
+ self.body.read_in.fh
+ }
+
/// Returns the base offset in the directory stream to read from.
pub fn offset(&self) -> u64 {
self.body.read_in.offset
}
+
+ pub fn size(&self) -> u32 {
+ self.body.read_in.size
+ }
}
impl Reply {
@@ -316,13 +377,6 @@ op! {
}
}
-op! {
- Destroy {
- type RequestBody = ();
- type ReplyTail = ();
- }
-}
-
pub(crate) mod state {
use crate::proto;