From fb35dbfdc5a9446fbb856dae5542b23963e28b89 Mon Sep 17 00:00:00 2001 From: Thomas Bertschinger Date: Mon, 15 Jan 2024 23:41:01 -0700 Subject: 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 Signed-off-by: Kent Overstreet --- rust-src/src/commands/mod.rs | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 rust-src/src/commands/mod.rs (limited to 'rust-src/src/commands/mod.rs') diff --git a/rust-src/src/commands/mod.rs b/rust-src/src/commands/mod.rs new file mode 100644 index 00000000..e05a0848 --- /dev/null +++ b/rust-src/src/commands/mod.rs @@ -0,0 +1,31 @@ +use clap::Subcommand; + +pub mod logger; +pub mod cmd_mount; +pub mod cmd_list; +pub mod cmd_completions; + +#[derive(clap::Parser, Debug)] +#[command(name = "bcachefs")] +pub struct Cli { + #[command(subcommand)] + subcommands: Subcommands, +} + +#[derive(Subcommand, Debug)] +enum Subcommands { + List(cmd_list::Cli), + Mount(cmd_mount::Cli), + Completions(cmd_completions::Cli), +} + +#[macro_export] +macro_rules! c_str { + ($lit:expr) => { + unsafe { + std::ffi::CStr::from_ptr(concat!($lit, "\0").as_ptr() as *const std::os::raw::c_char) + .to_bytes_with_nul() + .as_ptr() as *const std::os::raw::c_char + } + }; +} -- cgit v1.2.3