Git Product home page Git Product logo

rustfs's Introduction

RustFS

RustFS is a virtual file system written completely in Rust.

Usage

Add RustFS to your dependencies:

[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);
  p.close(fd);

  // 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);
  p.close(fd);

  // All done. Unlink.
p.unlink("file");

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

Testing

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

Benchmarking

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.

rustfs's People

Contributors

nabijaczleweli avatar sergiobenitez avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

rustfs's Issues

Test failure

Hello Sergio,

Tried to run the test like RUST_TEST_THREADS=1 cargo test under RustFS directory on Mac OS 10.10.5 with rustc version rustc 1.27.2 (58cc626de 2018-07-18). The error looks like:

    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.2.43
   Compiling rand v0.4.3
   Compiling time v0.1.40
   Compiling rand v0.3.22
   Compiling rustfs v0.1.0 (file:///Users/zeyuan/Documents/projects/RustFS)
warning: static variable `test_inode_drop` should have an upper case name such as `TEST_INODE_DROP`
   --> src/lib.rs:112:3
    |
112 |   static mut test_inode_drop: bool = false;
    |   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    |
    = note: #[warn(non_upper_case_globals)] on by default

    Finished dev [unoptimized + debuginfo] target(s) in 24.11s
     Running target/debug/deps/rustfs-0a853a8761bd29e2

running 7 tests
test inode::tests::test_simple_write ... error: process didn't exit successfully: `/Users/zeyuan/Documents/projects/RustFS/target/debug/deps/rustfs-0a853a8761bd29e2` (signal: 11, SIGSEGV: invalid memory reference)

Do you know what is proc.rs? I tried to run ./src/test.sh and I get the following error message:

./src/test.sh
error: couldn't read "proc.rs": No such file or directory (os error 2)

error: aborting due to previous error

./src/test.sh: line 2: ./rustfs.out: No such file or directory

I also test on Ubuntu 16.04 and everything works. I'm wondering which part of code that relies on the Mac OS?

Thanks!

Compilation failure

Hello, SergioBenitez!
I can't compile the library on rustc 1.8.0.
$ rustc --opt-level=3 src/proc.rs
error: Unrecognized option: 'opt-level'.
$ rustc src/proc.rs
src/inode.rs:9:21: 9:22 error: expected one of !, (, +, ::, ;, <, or ], found ,
src/inode.rs:9 type Page = Box<([u8, ..PAGE_SIZE])>;
^
error: aborting due to previous error

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.