remove library from bcachefs-tools Rust package

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>
This commit is contained in:
Thomas Bertschinger 2024-01-15 23:41:01 -07:00 committed by Kent Overstreet
parent 0a284fc4ff
commit fb35dbfdc5
7 changed files with 17 additions and 17 deletions

View File

@ -9,9 +9,6 @@ rust-version = "1.65"
name = "bcachefs" name = "bcachefs"
path = "src/bcachefs.rs" path = "src/bcachefs.rs"
[lib]
name = "bcachefs"
[dependencies] [dependencies]
atty = "0.2.14" atty = "0.2.14"
log = { version = "0.4", features = ["std"] } log = { version = "0.4", features = ["std"] }

View File

@ -1,11 +1,24 @@
mod commands;
mod key;
use std::ffi::CString; use std::ffi::CString;
use bcachefs::cmd_completions::cmd_completions; use commands::cmd_completions::cmd_completions;
use bcachefs::cmd_list::cmd_list; use commands::cmd_list::cmd_list;
use bcachefs::cmd_mount::cmd_mount; use commands::cmd_mount::cmd_mount;
use bcachefs::logger::SimpleLogger; use commands::logger::SimpleLogger;
use bch_bindgen::c; 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 { fn handle_c_command(args: Vec<String>, symlink_cmd: Option<&str>) -> i32 {
let mut argv: Vec<_> = args.clone(); let mut argv: Vec<_> = args.clone();

View File

@ -1,6 +1,5 @@
use clap::Subcommand; use clap::Subcommand;
pub mod key;
pub mod logger; pub mod logger;
pub mod cmd_mount; pub mod cmd_mount;
pub mod cmd_list; 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 {}