diff options
author | Thomas Bertschinger <tahbertschinger@gmail.com> | 2024-01-15 23:41:00 -0700 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2024-01-16 01:46:41 -0500 |
commit | 0a284fc4ffcbb46f0a4b921415ef12a9c75fa05c (patch) | |
tree | 22aa82b7448833713ca975eb3c241f607742fc78 /rust-src/src/cmd_mount.rs | |
parent | 249bf7b9d446092e1b744c366b7e8c4563a437f0 (diff) |
convert main() from C to Rust
This moves the main() function from C to Rust. It also updates the name
of the Rust package from "bcachefs-rust" to "bcachefs-tools".
Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'rust-src/src/cmd_mount.rs')
-rw-r--r-- | rust-src/src/cmd_mount.rs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/rust-src/src/cmd_mount.rs b/rust-src/src/cmd_mount.rs index eccfe6d0..b120c91e 100644 --- a/rust-src/src/cmd_mount.rs +++ b/rust-src/src/cmd_mount.rs @@ -6,7 +6,7 @@ use uuid::Uuid; use std::path::PathBuf; use crate::key; use crate::key::KeyLocation; -use std::ffi::{CString, c_int, c_char, c_void, OsStr}; +use std::ffi::{CString, c_char, c_void}; use std::os::unix::ffi::OsStrExt; fn mount_inner( @@ -223,7 +223,14 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> { Ok(()) } -pub fn cmd_mount(argv: Vec<&OsStr>) -> c_int { +pub fn cmd_mount(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> i32 { + // If the bcachefs tool is being called as "bcachefs mount dev ..." (as opposed to via a + // symlink like "/usr/sbin/mount.bcachefs dev ...", then we need to pop the 0th argument + // ("bcachefs") since the CLI parser here expects the device at position 1. + if symlink_cmd.is_none() { + argv.remove(0); + } + let opt = Cli::parse_from(argv); // @TODO : more granular log levels via mount option |