Crates.io | my-test-app-bergwolf |
lib.rs | my-test-app-bergwolf |
version | 1.4.0 |
source | src |
created_at | 2022-02-07 09:36:34.431655 |
updated_at | 2022-02-07 09:54:52.925435 |
description | A rust library for Fuse(filesystem in userspace) servers and virtio-fs devices |
homepage | https://github.com/cloud-hypervisor/ |
repository | https://github.com/cloud-hypervisor/fuse-backend-rs |
max_upload_size | |
id | 528293 |
size | 677,099 |
The fuse-backend-rs crate is an rust library to implement Fuse daemons based on the Linux FUSE device (/dev/fuse) or the virtiofs draft specification.
Linux FUSE is an userspace filesystem framework, and the /dev/fuse device node is the interface for userspace filesystem daemons to communicate with the in-kernel fuse driver.
And the virito-fs specification extends the FUSE framework into the virtualization world, which uses the Virtio protocol to transfer FUSE requests and responses between the Fuse client and server. With virtio-fs, the Fuse client runs within the guest kernel and the Fuse server runs on the host userspace or hardware.
So the fuse-rs crate is a library to communicate with the Linux FUSE clients, which includes:
A sample fuse server based on the Linux Fuse device (/dev/fuse):
use fuse_backend_rs::api::{server::Server, Vfs, VfsOptions};
use fuse_backend_rs::transport::fusedev::{FuseSession, FuseChannel};
struct FuseServer {
server: Arc<Server<Arc<Vfs>>>,
ch: FuseChannel,
}
impl FuseServer {
fn svc_loop(&self) -> Result<()> {
// Given error EBADF, it means kernel has shut down this session.
let _ebadf = std::io::Error::from_raw_os_error(libc::EBADF);
loop {
if let Some((reader, writer)) = self
.ch
.get_request()
.map_err(|_| std::io::Error::from_raw_os_error(libc::EINVAL))?
{
if let Err(e) = self.server.handle_message(reader, writer, None, None) {
match e {
fuse_backend_rs::Error::EncodeMessage(_ebadf) => {
break;
}
_ => {
error!("Handling fuse message failed");
continue;
}
}
}
} else {
info!("fuse server exits");
break;
}
}
Ok(())
}
}
This project is licensed under