cezarmathe / btrfsutil-rs Goto Github PK
View Code? Open in Web Editor NEWSafe wrappers for libbtrfsutil.
Home Page: https://crates.io/crates/btrfsutil
License: MIT License
Safe wrappers for libbtrfsutil.
Home Page: https://crates.io/crates/btrfsutil
License: MIT License
The Subvolume struct should include the id, the filesystem root and the path.
Create two ways of getting a Subvolume:
Refactor all functions that require the path so that they do not call the C function every time.
btrfsutil-rs 0.2.0?
I'm currently relying on master
but this prevents me from publishing to crates.io. I published to btrfsutil-fake
to work around this, but would prefer to use the mainline.
/// Get a subvolume.
///
/// The path must point to the root of a subvolume.
I tried calling Subvolume::get()
with the path to a normal directory on a btrfs filesystem and it worked, contrary to what the above comment says. I'm not sure if the code, or the comment, needs to be changed.
Calling btrfs_util_subvolume_path
with path "/" only works if btrfs is the filesystem mounted at /. If I have a btrfs filesystem mounted at /mnt/btrfs
(and some other filesystem type is mounted at /
), the filesystem root that needs to be passed is /mnt/btrfs
.
I think this means a Subvolume
needs to have some way to remember its filesystem root.
btrfsutil 0.1.0 contains code that will become an error in the future, as reported to me by rustc
1.71.0:
$ cargo report future-incompatibilities --id 1 --package [email protected]
The following warnings were discovered during the build. These warnings are an
indication that the packages contain code that will become an error in a
future release of Rust. These warnings typically cover changes to close
soundness problems, unintended or undocumented behavior, or critical problems
that cannot be fixed in a backwards-compatible fashion, and are not expected
to be in wide use.
Each warning should contain a link for more information on what the warning
means and how to resolve it.
To solve this problem, you can try the following approaches:
- If the issue is not solved by updating the dependencies, a fix has to be
implemented by those dependencies. You can help with that by notifying the
maintainers of this problem (e.g. by creating a bug report) or by proposing a
fix to the maintainers (e.g. by creating a pull request):
- [email protected]
- Repository: https://github.com/cezarmathe/btrfsutil-rs
- Detailed warning command: `cargo report future-incompatibilities --id 1 --package [email protected]`
- If waiting for an upstream fix is not an option, you can use the `[patch]`
section in `Cargo.toml` to use your own version of the dependency. For more
information, see:
https://doc.rust-lang.org/cargo/reference/overriding-dependencies.html#the-patch-section
The package `btrfsutil v0.1.0` currently triggers the following future incompatibility lints:
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/lib.rs:138:23
> |
> 138 | Err(e) => glue_error!(GlueError::Utf8Error(e)),
> | ------------------------------------ in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/lib.rs:207:18
> |
> 207 | _ => glue_error!(GlueError::UnknownErrno(errno)),
> | ------------------------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/common.rs:19:17
> |
> 19 | None => glue_error!(GlueError::BadPath(path)),
> | ------------------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/common.rs:23:19
> |
> 23 | Err(e) => glue_error!(GlueError::NulError(e)),
> | ----------------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol.rs:207:23
> |
> 207 | Err(e) => glue_error!(GlueError::Utf8Error(e)),
> | ------------------------------------ in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:146:26
> |
> 146 | let uuid: Uuid = handle_uuid!(&src.uuid);
> | ----------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_uuid` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:147:37
> |
> 147 | let parent_uuid_val: Uuid = handle_uuid!(&src.parent_uuid);
> | ------------------------------ in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_uuid` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:148:39
> |
> 148 | let received_uuid_val: Uuid = handle_uuid!(&src.received_uuid);
> | -------------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_uuid` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:149:36
> |
> 149 | let ctime: NaiveDateTime = handle_timespec!(src.ctime);
> | --------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_timespec` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:150:36
> |
> 150 | let otime: NaiveDateTime = handle_timespec!(src.otime);
> | --------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_timespec` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:151:40
> |
> 151 | let stime_val: NaiveDateTime = handle_timespec!(src.stime);
> | --------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_timespec` (in Nightly builds, run with -Z macro-backtrace for more info)
>
> warning: trailing semicolon in macro used in expression position
> --> /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/error/glue.rs:88:44
> |
> 88 | panic!("Glue error: {}", $glue_err);
> | ^
> |
> ::: /home/josh/.cargo/registry/src/index.crates.io-6f17d22bba15001f/btrfsutil-0.1.0/src/subvolume/subvol_info.rs:152:40
> |
> 152 | let rtime_val: NaiveDateTime = handle_timespec!(src.rtime);
> | --------------------------- in this macro invocation
> |
> = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
> = note: for more information, see issue #79813 <https://github.com/rust-lang/rust/issues/79813>
> = note: `#[allow(semicolon_in_expressions_from_macros)]` on by default
> = note: this warning originates in the macro `glue_error` which comes from the expansion of the macro `handle_timespec` (in Nightly builds, run with -Z macro-backtrace for more info)```
I'm currently using your library for a personal project with heavy usage of async code, and I was looking around in the code when I noticed a comment about planned async/await support (subvol.rs line 229). Is there any estimate for when that will be implemented?
Some functions in libbtrfsutil, like btrfs_subvolume_create_snapshot
, do not require privilege (CAP_SYS_ADMIN),
But inside Subvolume::snapshot
, it calls Subvolume::path
, which requires privilege, that cause these functions require privilege too.
Move raw bindings to a separate sys crate: btrfsutil-sys.
For some reason, I can't take a snapshot of a volume using Subvolume::snapshot
. I keep getting a SearchFalied response no matter the path I provide as the destination. Here is the code I am using to take the snapshot:
Subvolume::get("/mnt/images/alpine")
.unwrap()
.snapshot("/mnt/containers/test/rootfs", None, None)?;
/mnt
is a the root of a btrfs filesystem with a subvolume at images/alpine
. When I try it using the btrfs
command line, it works with no issue. Even when I call it using std::process::Command
it works properly. Am I doing something wrong, or is it within the library?
Edit: I should also add that I am running the program as root, so permissions shouldn't be an issue?
Hello,
I just cloned the repository and wanted to compile the examples like it's shown in the readme by using: cargo build --examples
Compiling btrfsutil v0.1.0 (/tmp/btrfsutil-rs)
Running `rustc --crate-name subvolume_iterator_info --edition=2018 examples/subvolume_iterator_info.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=99493dc0e499a1f7 -C extra-filename=-99493dc0e499a1f7 --out-dir /tmp/btrfsutil-rs/target/debug/examples -C incremental=/tmp/btrfsutil-rs/target/debug/incremental -L dependency=/tmp/btrfsutil-rs/target/debug/deps --extern bitflags=/tmp/btrfsutil-rs/target/debug/deps/libbitflags-0cd415034ee648ca.rlib --extern btrfsutil=/tmp/btrfsutil-rs/target/debug/deps/libbtrfsutil-966ab251e35e1ce3.rlib --extern btrfsutil_sys=/tmp/btrfsutil-rs/target/debug/deps/libbtrfsutil_sys-71a95990b4d2e496.rlib --extern chrono=/tmp/btrfsutil-rs/target/debug/deps/libchrono-e2e17c2673c59046.rlib --extern libc=/tmp/btrfsutil-rs/target/debug/deps/liblibc-bb07417106e69ff9.rlib --extern libmount=/tmp/btrfsutil-rs/target/debug/deps/liblibmount-375cfedd7c41acff.rlib --extern loopdev=/tmp/btrfsutil-rs/target/debug/deps/libloopdev-644ecdbbd5c7ce20.rlib --extern nix=/tmp/btrfsutil-rs/target/debug/deps/libnix-a65400f06839ac2c.rlib --extern tempfile=/tmp/btrfsutil-rs/target/debug/deps/libtempfile-28cb05591749222e.rlib --extern thiserror=/tmp/btrfsutil-rs/target/debug/deps/libthiserror-bfaab245d3803832.rlib --extern uuid=/tmp/btrfsutil-rs/target/debug/deps/libuuid-959314128929bc1a.rlib`
error[E0599]: no function or associated item named `from_path` found for struct `btrfsutil::subvolume::Subvolume` in the current scope
--> examples/subvolume_iterator_info.rs:7:34
|
7 | let root_subvol = Subvolume::from_path(Path::new("/")).unwrap();
| ^^^^^^^^^ function or associated item not found in `btrfsutil::subvolume::Subvolume`
error[E0599]: no method named `info` found for enum `std::result::Result<btrfsutil::subvolume::Subvolume, btrfsutil::error::LibError>` in the current scope
--> examples/subvolume_iterator_info.rs:15:36
|
15 | println!("{:?}", subvolume.info().unwrap());
| ^^^^ method not found in `std::result::Result<btrfsutil::subvolume::Subvolume, btrfsutil::error::LibError>`
error: aborting due to 2 previous errors
For more information about this error, try `rustc --explain E0599`.
error: could not compile `btrfsutil`.
Caused by:
process didn't exit successfully: `rustc --crate-name subvolume_iterator_info --edition=2018 examples/subvolume_iterator_info.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type bin --emit=dep-info,link -Cembed-bitcode=no -C debuginfo=2 --cfg 'feature="default"' -C metadata=99493dc0e499a1f7 -C extra-filename=-99493dc0e499a1f7 --out-dir /tmp/btrfsutil-rs/target/debug/examples -C incremental=/tmp/btrfsutil-rs/target/debug/incremental -L dependency=/tmp/btrfsutil-rs/target/debug/deps --extern bitflags=/tmp/btrfsutil-rs/target/debug/deps/libbitflags-0cd415034ee648ca.rlib --extern btrfsutil=/tmp/btrfsutil-rs/target/debug/deps/libbtrfsutil-966ab251e35e1ce3.rlib --extern btrfsutil_sys=/tmp/btrfsutil-rs/target/debug/deps/libbtrfsutil_sys-71a95990b4d2e496.rlib --extern chrono=/tmp/btrfsutil-rs/target/debug/deps/libchrono-e2e17c2673c59046.rlib --extern libc=/tmp/btrfsutil-rs/target/debug/deps/liblibc-bb07417106e69ff9.rlib --extern libmount=/tmp/btrfsutil-rs/target/debug/deps/liblibmount-375cfedd7c41acff.rlib --extern loopdev=/tmp/btrfsutil-rs/target/debug/deps/libloopdev-644ecdbbd5c7ce20.rlib --extern nix=/tmp/btrfsutil-rs/target/debug/deps/libnix-a65400f06839ac2c.rlib --extern tempfile=/tmp/btrfsutil-rs/target/debug/deps/libtempfile-28cb05591749222e.rlib --extern thiserror=/tmp/btrfsutil-rs/target/debug/deps/libthiserror-bfaab245d3803832.rlib --extern uuid=/tmp/btrfsutil-rs/target/debug/deps/libuuid-959314128929bc1a.rlib` (exit code: 1)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.