Skip to content

Commit

Permalink
trickfs: add trickmnt
Browse files Browse the repository at this point in the history
adds a binary target called `trickmnt` to quickly mount a trickfs
locally.
  • Loading branch information
pepyakin committed Jan 31, 2025
1 parent e323b4a commit 990225a
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 13 deletions.
15 changes: 13 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 9 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
[workspace]
resolver = "2"
members = ["core", "nomt", "fuzz", "torture", "examples/*", "trickfs"]
members = [
"core",
"nomt",
"fuzz",
"torture",
"examples/*",
"trickfs",
"trickfs/trickmnt",
]
exclude = ["benchtop"]

[workspace.package]
Expand Down
4 changes: 3 additions & 1 deletion trickfs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ edition.workspace = true
license.workspace = true

[dependencies]
env_logger = "0.11.6"
fuser = { version = "0.15.1", features = ["abi-7-23"] }
libc = "0.2.169"
log = "0.4.22"
tempfile = "3.15.0"

[dev-dependencies]
env_logger = "0.11.6"
10 changes: 10 additions & 0 deletions trickfs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

A FUSE filesystem useful for failure injection.

# Using trickfs.

Typically you would not need to run trickfs directly, because it should be used as a dependency
in other projects. However, if you want to test the filesystem, you can do so by running the
following command:

```sh
cargo run --release --bin trickmnt
```

# Building

Building the project requires fuse3 and fuse to be available. On Ubuntu, you can install them with
Expand Down
9 changes: 0 additions & 9 deletions trickfs/src/main.rs

This file was deleted.

15 changes: 15 additions & 0 deletions trickfs/trickmnt/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
[package]
name = "trickmnt"
version = "0.1.0"
authors.workspace = true
homepage.workspace = true
repository.workspace = true
edition.workspace = true
license.workspace = true

[dependencies]
trickfs = { path = ".." }
clap = { version = "4.3.5", features = ["derive"] }
env_logger = "0.11.6"
log = "0.4.22"
anyhow = "1.0.95"
28 changes: 28 additions & 0 deletions trickfs/trickmnt/src/main.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
use clap::Parser;

#[derive(Parser, Debug)]
#[command(author, version, about, long_about = None)]
struct Args {
/// Path to the directory where trickfs will be mounted
#[arg(short, long, default_value = "/tmp/trick")]
mountpoint: String,
}

fn waitline() {
log::info!("press return to stop...");
let _ = std::io::stdin().read_line(&mut String::new());
}

fn main() -> anyhow::Result<()> {
env_logger::builder()
.filter_level(log::LevelFilter::Info)
.init();

let args = Args::parse();

let handle = trickfs::spawn_trick(args.mountpoint).unwrap();
waitline();
drop(handle);

Ok(())
}

0 comments on commit 990225a

Please sign in to comment.