Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/valshaped/mkfs-btrfs-rs
A quick wrapper for mkfs.btrfs in pure safe Rust
https://github.com/valshaped/mkfs-btrfs-rs
btrfs-progs filesystem rust rust-crate
Last synced: about 1 month ago
JSON representation
A quick wrapper for mkfs.btrfs in pure safe Rust
- Host: GitHub
- URL: https://github.com/valshaped/mkfs-btrfs-rs
- Owner: ValShaped
- License: mit
- Created: 2023-02-04T23:12:56.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2023-02-06T04:06:44.000Z (almost 2 years ago)
- Last Synced: 2024-10-31T11:34:16.567Z (about 2 months ago)
- Topics: btrfs-progs, filesystem, rust, rust-crate
- Language: Rust
- Homepage:
- Size: 12.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# mkfs-btrfs-rs
A wrapper for `mkfs.btrfs` in type-safe Rust.
> NOT a FFI binding, just command wrapper, to make you feel a bit like you're writing rust.
* If you want to create a btrfs volume, check out the [`Formatter`].
* If you want to see the full list of options, check out [`format::FormatterOptions`].
# Examples
```rust no_run
use mkfs_btrfs_rs::{Result, Formatter};
fn main() -> Result<()> {
let formatter = Formatter::options()
.label("my_awesome_label")?
.build()
.format("/tmp/some/file")?;
Ok(())
}
```
```rust no_run
use mkfs_btrfs_rs::{Formatter, Result};
use std::process::Output;
fn main() -> Result<()> {
let formatter = Formatter::options()
// If you provide a rootdir, mkfs.btrfs will copy the stuff in that dir into the new volume
.rootdir("/")?
// Labels can be arbitrary UTF-8, max 256 bytes
.label("My Awesome New Partition")?
// Mix data and metadata blocks
.mixed()?
// Don't force-format
// .force()?
.build();
let Output {
status: _status,
stdout: out,
stderr: err,
} = formatter.format("/dev/sdxY")?;
println!(
"> STDOUT:\n{}\n> STDERR:\n{}",
String::from_utf8(out).unwrap(),
String::from_utf8(err).unwrap(),
);
Ok(())
}
```