From 36e6ca83518c5afec980561ae9dbd6bdf4118420 Mon Sep 17 00:00:00 2001 From: Alejandro Soto Date: Wed, 29 Dec 2021 06:11:24 -0600 Subject: Refactor FsInfo API --- examples/ext2.rs | 22 +++++++++++----------- src/fuse/io.rs | 3 ++- src/fuse/ops.rs | 5 ++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/examples/ext2.rs b/examples/ext2.rs index 3a68eee..4c62a3f 100644 --- a/examples/ext2.rs +++ b/examples/ext2.rs @@ -330,17 +330,17 @@ impl Ext2 { let total_inodes = self.superblock.s_inodes_count as u64; let free_inodes = self.superblock.s_free_inodes_count as u64; - reply.info( - FsInfo::default() - .blocks( - self.block_size() as u32, - total_blocks, - free_blocks, - available_blocks, - ) - .inodes(total_inodes, free_inodes) - .filenames(255), - ) + let info = FsInfo::default() + .blocks( + self.block_size() as u32, + total_blocks, + free_blocks, + available_blocks, + ) + .inodes(total_inodes, free_inodes) + .max_filename(255); + + reply.info(&info) } async fn getattr<'o>(&self, (request, reply): Op<'o, Getattr>) -> Done<'o> { diff --git a/src/fuse/io.rs b/src/fuse/io.rs index 7ba2944..db33ab3 100644 --- a/src/fuse/io.rs +++ b/src/fuse/io.rs @@ -41,6 +41,7 @@ pub struct Entry<'a, K> { pub ttl: Ttl, } +#[derive(Copy, Clone)] pub struct FsInfo(proto::StatfsOut); impl<'o, O: Operation<'o>> Request<'o, O> { @@ -296,7 +297,7 @@ impl FsInfo { }) } - pub fn filenames(self, max: u32) -> Self { + pub fn max_filename(self, max: u32) -> Self { FsInfo(proto::StatfsOut { namelen: max, ..self.0 diff --git a/src/fuse/ops.rs b/src/fuse/ops.rs index bfb45b8..01d671e 100644 --- a/src/fuse/ops.rs +++ b/src/fuse/ops.rs @@ -311,9 +311,8 @@ op! { impl Reply { /// Replies with filesystem statistics. - pub fn info(self, statfs: FsInfo) -> Done<'o> { - let statfs: proto::StatfsOut = statfs.into(); - self.single(&statfs) + pub fn info(self, statfs: &FsInfo) -> Done<'o> { + self.single(&proto::StatfsOut::from(*statfs)) } } } -- cgit v1.2.3