Skip to content

Commit c3d06f4

Browse files
committed
macos_session: add with_writer for macOS
macos_session originally lacked the `with_writer` API. This commit ports the implementation from `linux_session` to provide a consistent interface across platforms.
1 parent 2f6ff6f commit c3d06f4

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

src/transport/fusedev/macos_session.rs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,19 @@ impl FuseSession {
188188
Err(SessionFailure("invalid fuse session".to_string()))
189189
}
190190
}
191+
192+
/// Create a new fuse message channel with a specific buffer size.
193+
pub fn with_writer<F>(&mut self, f: F)
194+
where
195+
F: FnOnce(FuseDevWriter),
196+
{
197+
if let Some(file) = &self.file {
198+
let fd = file.as_raw_fd();
199+
let mut buf = vec![0x0u8; self.bufsize];
200+
let writer = FuseDevWriter::new(fd, &mut buf).unwrap();
201+
f(writer);
202+
}
203+
}
191204

192205
/// Wake channel loop
193206
/// After macfuse unmount, read will throw ENODEV

0 commit comments

Comments
 (0)