Migrate to use fuse crate's FuseConfig API
The old API is deprecated with a new replacement in
https://chromium-review.googlesource.com/c/chromiumos/platform/crosvm/+/3514617
Note that the original API uses write/read in an opposite perspective:
a write to the filesystem by another process is a read to these FUSE
filesystems. Which is also inconsistent to the mount opion of max_read.
The new API brings consistency. For this specific change:
- zipfuse happened to name them in the opposite (but now correct) way.
- authfs happened to use the same values for both, so just update the
comments. Also remove the comment in remote_file.rs that mentioned
the old API. It's not super helpful anyway with the compiler check.
Bug: 223659448
Test: atest AuthFsHostTest
Change-Id: I33436cdc3bf84c3a0d42a6b517fe9ef28958292a
diff --git a/authfs/src/file/remote_file.rs b/authfs/src/file/remote_file.rs
index 039285f..4c112bd 100644
--- a/authfs/src/file/remote_file.rs
+++ b/authfs/src/file/remote_file.rs
@@ -40,7 +40,6 @@
}
pub struct RemoteFileReader {
- // This needs to have Sync trait to be used in fuse::worker::start_message_loop.
service: VirtFdService,
file_fd: i32,
}
@@ -81,7 +80,6 @@
}
pub struct RemoteMerkleTreeReader {
- // This needs to be a Sync to be used in fuse::worker::start_message_loop.
service: VirtFdService,
file_fd: i32,
}
@@ -108,7 +106,6 @@
}
pub struct RemoteFileEditor {
- // This needs to have Sync trait to be used in fuse::worker::start_message_loop.
service: VirtFdService,
file_fd: i32,
}
diff --git a/authfs/src/fusefs.rs b/authfs/src/fusefs.rs
index 511db68..beb6b30 100644
--- a/authfs/src/fusefs.rs
+++ b/authfs/src/fusefs.rs
@@ -184,10 +184,9 @@
type DirHandleTable = BTreeMap<Handle, Arc<DirEntriesSnapshot>>;
-// AuthFS needs to be `Sync` to be accepted by fuse::worker::start_message_loop as a `FileSystem`.
+// AuthFS needs to be `Sync` to be used with the `fuse` crate.
pub struct AuthFs {
- /// Table for `Inode` to `InodeState` lookup. This needs to be `Sync` to be used in
- /// `fuse::worker::start_message_loop`.
+ /// Table for `Inode` to `InodeState` lookup.
inode_table: RwLock<BTreeMap<Inode, InodeState>>,
/// The next available inode number.
diff --git a/authfs/src/fusefs/mount.rs b/authfs/src/fusefs/mount.rs
index 294c6b1..38503df 100644
--- a/authfs/src/fusefs/mount.rs
+++ b/authfs/src/fusefs/mount.rs
@@ -21,11 +21,12 @@
use super::AuthFs;
-/// Maximum bytes in the write transaction to the FUSE device. This limits the maximum buffer
-/// size in a read request (including FUSE protocol overhead) that the filesystem writes to.
+/// Maximum bytes (excluding the FUSE header) `AuthFs` will receive from the kernel for write
+/// operations by another process.
pub const MAX_WRITE_BYTES: u32 = 65536;
-/// Maximum bytes in a read operation.
+/// Maximum bytes (excluding the FUSE header) `AuthFs` will receive from the kernel for read
+/// operations by another process.
/// TODO(victorhsieh): This option is deprecated by FUSE. Figure out if we can remove this.
const MAX_READ_BYTES: u32 = 65536;
@@ -61,5 +62,7 @@
)
.expect("Failed to mount fuse");
- fuse::worker::start_message_loop(dev_fuse, MAX_WRITE_BYTES, MAX_READ_BYTES, authfs)
+ let mut config = fuse::FuseConfig::new();
+ config.dev_fuse(dev_fuse).max_write(MAX_WRITE_BYTES).max_read(MAX_READ_BYTES);
+ config.enter_message_loop(authfs)
}
diff --git a/zipfuse/src/main.rs b/zipfuse/src/main.rs
index a91642c..c3fae69 100644
--- a/zipfuse/src/main.rs
+++ b/zipfuse/src/main.rs
@@ -82,7 +82,9 @@
libc::MS_NOSUID | libc::MS_NODEV | libc::MS_RDONLY,
&mount_options,
)?;
- Ok(fuse::worker::start_message_loop(dev_fuse, MAX_READ, MAX_WRITE, ZipFuse::new(zip_file)?)?)
+ let mut config = fuse::FuseConfig::new();
+ config.dev_fuse(dev_fuse).max_write(MAX_WRITE).max_read(MAX_READ);
+ Ok(config.enter_message_loop(ZipFuse::new(zip_file)?)?)
}
struct ZipFuse {