A virtual file system written in Rust.
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.
bench Bring RustFS into 2016. Sep 27, 2016
libbench Bring RustFS into 2016. Sep 27, 2016
libslab Bring RustFS into 2016. Sep 27, 2016
src Bring RustFS into 2016. Sep 27, 2016
README.md Fix formatting in README Dec 26, 2016
cheatsheet.md Bring RustFS into 2016. Sep 27, 2016



RustFS is a virtual file system written completely in Rust.


Add RustFS to your dependencies:

rustfs = { git = "https://github.com/SergioBenitez/RustFS" }

Then, import the crate into your project and bring types into the namespace:

extern crate rustfs;

use rustfs::{Proc, O_CREAT, O_RDWR};

Finally, use Proc::new() to create a new Proc. Call open / close / seek / read / write on it:

let mut p = Proc::new();

// Let's write `data` to a new file named "file".
let data = b"... some data ...";
  let fd = p.open("file", O_CREAT | O_RDWR);
  p.write(fd, &data);

  // Let's read back that data to a buffer named `buf` of the correct size.
  let mut buf = vec![0; size];
  let fd = p.open("file", O_RDWR);
  p.read(fd, &mut buf);

  // All done. Unlink.

For more examples on how to use RustFS, see the benchmarks in bench/bench.rs and tests in src/proc.rs.


Run the tests using RUST_TEST_THREADS=1 cargo test. The tests need to be run sequentially.


You'll need Rust nightly to run the benchmarks. We use a custom built benchmarking tool to get accurate results, and that benchmarking tool uses assembly. Assembly can only be used in Rust nightly.

To run the benchmarks, switch into the bench directory:

cd bench

Run them with Cargo:

cargo run --release

Directory Structure

  • bench/

    • bench.rs The benchmarks.
  • libbench/lib.rs The benchmarking library.

  • libslab/lib.rs The slab allocator library.

  • src/

    • directory.rs Insert/Remove/Get directory method implementations.
    • file.rs FileHandle implementation and structure definitions.
    • inode.rs Inode structure and implementation.
    • proc.rs Proc structure (which wraps everything) and implementation.