]> git.sesse.net Git - bcachefs-tools-debian/commitdiff
cmd_mount: don't return 0 on mount failure
authorLinus Heckemann <git@sphalerite.org>
Thu, 10 Aug 2023 13:22:25 +0000 (15:22 +0200)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 10 Aug 2023 15:01:24 +0000 (11:01 -0400)
Signed-off-by: Linus Heckemann <git@sphalerite.org>
bcachefs.c
cmds.h
rust-src/src/cmd_mount.rs

index 750e11dbb1ae97508950c6b4461c4638f143a9eb..e0e2045852415064a100e29818555f2cd74fdef2 100644 (file)
@@ -254,8 +254,7 @@ int main(int argc, char *argv[])
                return cmd_setattr(argc, argv);
 #ifndef BCACHEFS_NO_RUST
        if (!strcmp(cmd, "mount")) {
-               cmd_mount(argc, argv);
-               return 0;
+               return cmd_mount(argc, argv);
        }
 #endif
 
diff --git a/cmds.h b/cmds.h
index 96216b217de7bc1bdf834144be3d67905d4b1655..8b56795398bafc7a73b7e0e32747788c9a6c4004 100644 (file)
--- a/cmds.h
+++ b/cmds.h
@@ -60,6 +60,6 @@ int cmd_subvolume_delete(int argc, char *argv[]);
 int cmd_subvolume_snapshot(int argc, char *argv[]);
 
 int cmd_fusemount(int argc, char *argv[]);
-void cmd_mount(int agc, char *argv[]);
+int cmd_mount(int agc, char *argv[]);
 
 #endif /* _CMDS_H */
index 0150ffd5ab1bf9581a03f6ae138c684681493a3f..b79985d82c4040bcfeeb623dfdc6d269a8872203 100644 (file)
@@ -219,14 +219,14 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
 }
 
 #[no_mangle]
-pub extern "C" fn cmd_mount(argc: c_int, argv: *const *const c_char) {
+pub extern "C" fn cmd_mount(argc: c_int, argv: *const *const c_char) -> c_int {
     let argv: Vec<_> = (0..argc)
         .map(|i| unsafe { CStr::from_ptr(*argv.add(i as usize)) })
         .map(|i| OsStr::from_bytes(i.to_bytes()))
         .collect();
 
     let opt = Cli::parse_from(argv);
-    
+
     log::set_boxed_logger(Box::new(SimpleLogger)).unwrap();
 
     // @TODO : more granular log levels via mount option
@@ -239,7 +239,9 @@ pub extern "C" fn cmd_mount(argc: c_int, argv: *const *const c_char) {
     colored::control::set_override(opt.colorize);
     if let Err(e) = cmd_mount_inner(opt) {
         error!("Fatal error: {}", e);
+        1
     } else {
         info!("Successfully mounted");
+        0
     }
 }