diff options
author | NewbieOrange <NewbieOrange@users.noreply.github.com> | 2025-08-26 21:32:31 +0800 |
---|---|---|
committer | Kent Overstreet <kent.overstreet@linux.dev> | 2025-08-27 19:22:37 -0400 |
commit | 34f9eeba1df78d94f862f268e9d05101ad1dea17 (patch) | |
tree | b4f2fef9f1ce2e957a461f291900791000aeb818 /src | |
parent | 90cbe3f3b4289abb39804bb0f7e78ad286e556fd (diff) |
mount: try to mount even if module is not loaded
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Diffstat (limited to 'src')
-rw-r--r-- | src/commands/mount.rs | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/commands/mount.rs b/src/commands/mount.rs index d0fd7168..71bc2bd4 100644 --- a/src/commands/mount.rs +++ b/src/commands/mount.rs @@ -218,23 +218,19 @@ pub struct Cli { verbose: u8, } -fn require_bcachefs_module() { +fn check_bcachefs_module() -> bool { let path = Path::new("/sys/module/bcachefs"); - if !path.exists() { + path.exists() || { let _ = std::process::Command::new("modprobe") .arg("bcachefs") .status(); - - if !path.exists() { - error!("bcachefs module not loaded?"); - std::process::exit(1); - } + path.exists() } } pub fn mount(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> std::process::ExitCode { - require_bcachefs_module(); + let module_loaded = check_bcachefs_module(); // 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 @@ -252,6 +248,9 @@ pub fn mount(mut argv: Vec<String>, symlink_cmd: Option<&str>) -> std::process:: Ok(_) => std::process::ExitCode::SUCCESS, Err(e) => { error!("Mount failed: {e}"); + if !module_loaded { + error!("bcachefs module not loaded?"); + } std::process::ExitCode::FAILURE } } |