Giter VIP home page Giter VIP logo

fuse-backend-rs's Introduction

Rust FUSE library for server, virtio-fs and vhost-user-fs

Crates.io Crates.io

Design

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:

  • ABI layer, which defines all data structures shared between linux Fuse framework and Fuse daemons.
  • API layer, defines the interfaces for Fuse daemons to implement a userspace file system.
  • Transport layer, which supports both the Linux Fuse device and virtio-fs protocol.
  • VFS/pseudo_fs, an abstraction layer to support multiple file systems by a single virtio-fs device.
  • A sample passthrough file system implementation, which passes through files from daemons to clients.

arch

Examples

Filesystem Drivers

Fuse Servers

Fuse Server and Main Service Loop

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(())
    }
}

License

This project is licensed under

fuse-backend-rs's People

Contributors

jiangliu avatar bergwolf avatar eryugey avatar liubogithub avatar wllenyj avatar changweige avatar killagu avatar zyfjeff avatar matthiasgoergens avatar imeoer avatar 00xc avatar zhangjaycee avatar mofishzz avatar champ-goblem avatar sctb512 avatar cbrewster avatar tim-zhang avatar justxuewei avatar uran0sh avatar xuejun-xj avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.