]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
remove library from bcachefs-tools Rust package
authorThomas Bertschinger <tahbertschinger@gmail.com>
Tue, 16 Jan 2024 06:41:01 +0000 (23:41 -0700)
committerKent Overstreet <kent.overstreet@linux.dev>
Tue, 16 Jan 2024 06:46:58 +0000 (01:46 -0500)
When bcachefs was a C program that had some functions implemented in
Rust, it was necessary to make a static library containing the Rust
functions available for the C program to link.

Now that bcachefs is a Rust program, that library is no longer needed.
Instead, the Rust executable links in libbachefs.a.

This patch updates the crate structure to reflect that. The command
functions are moved into their own module.

There could be a need to create a "libbachefs-tools" library in the
future that exposes an API for bcachefs functionality to other
userspace programs. That will be a different, external API as opposed to
the previous library functions which were an internal API for the
bcachefs tool itself.

Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
rust-src/Cargo.toml
rust-src/src/bcachefs.rs
rust-src/src/commands/cmd_completions.rs [moved from rust-src/src/cmd_completions.rs with 100% similarity]
rust-src/src/commands/cmd_list.rs [moved from rust-src/src/cmd_list.rs with 100% similarity]
rust-src/src/commands/cmd_mount.rs [moved from rust-src/src/cmd_mount.rs with 100% similarity]
rust-src/src/commands/logger.rs [moved from rust-src/src/logger.rs with 100% similarity]
rust-src/src/commands/mod.rs [moved from rust-src/src/lib.rs with 72% similarity]

index 2786fc76987ebc6fb0c43e68a99f425bfb93ee2d..66d7bc6a5bf8f2f0a0af7f44f2acb295f23d6fd3 100644 (file)
@@ -9,9 +9,6 @@ rust-version = "1.65"
 name = "bcachefs"
 path = "src/bcachefs.rs"
 
-[lib]
-name = "bcachefs"
-
 [dependencies]
 atty = "0.2.14"
 log = { version = "0.4", features = ["std"] }
index 3d7af3d43aab3e772aa52c856892d1e84e0a24e5..95f5e1f0552dfcc1d0477a239ac65455ac129c7b 100644 (file)
@@ -1,11 +1,24 @@
+mod commands;
+mod key;
+
 use std::ffi::CString;
 
-use bcachefs::cmd_completions::cmd_completions;
-use bcachefs::cmd_list::cmd_list;
-use bcachefs::cmd_mount::cmd_mount;
-use bcachefs::logger::SimpleLogger;
+use commands::cmd_completions::cmd_completions;
+use commands::cmd_list::cmd_list;
+use commands::cmd_mount::cmd_mount;
+use commands::logger::SimpleLogger;
 use bch_bindgen::c;
 
+#[derive(Debug)]
+pub struct ErrnoError(pub errno::Errno);
+impl std::fmt::Display for ErrnoError {
+    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
+        self.0.fmt(f)
+    }
+}
+
+impl std::error::Error for ErrnoError {}
+
 fn handle_c_command(args: Vec<String>, symlink_cmd: Option<&str>) -> i32 {
     let mut argv: Vec<_> = args.clone();
 
similarity index 72%
rename from rust-src/src/lib.rs
rename to rust-src/src/commands/mod.rs
index f8b508dcaa116dadeed95e6c1c81f72b1f45e85c..e05a0848819e6e8e4f3b1cae6f4664fde08ffe1d 100644 (file)
@@ -1,6 +1,5 @@
 use clap::Subcommand;
 
-pub mod key;
 pub mod logger;
 pub mod cmd_mount;
 pub mod cmd_list;
@@ -30,12 +29,3 @@ macro_rules! c_str {
         }
     };
 }
-
-#[derive(Debug)]
-struct ErrnoError(errno::Errno);
-impl std::fmt::Display for ErrnoError {
-    fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
-        self.0.fmt(f)
-    }
-}
-impl std::error::Error for ErrnoError {}