public inbox for linux-bcachefs@vger.kernel.org
 help / color / mirror / Atom feed
From: Linus Heckemann <git@sphalerite.org>
To: linux-bcachefs@vger.kernel.org
Cc: Linus Heckemann <git@sphalerite.org>
Subject: [PATCH] cmd_mount: don't return 0 on mount failure
Date: Thu, 10 Aug 2023 15:22:25 +0200	[thread overview]
Message-ID: <20230810132225.796096-1-git@sphalerite.org> (raw)

Signed-off-by: Linus Heckemann <git@sphalerite.org>
---
 bcachefs.c                | 3 +--
 cmds.h                    | 2 +-
 rust-src/src/cmd_mount.rs | 6 ++++--
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/bcachefs.c b/bcachefs.c
index a3fe6d8..d1efcd5 100644
--- a/bcachefs.c
+++ b/bcachefs.c
@@ -250,8 +250,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 96216b2..8b56795 100644
--- 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 */
diff --git a/rust-src/src/cmd_mount.rs b/rust-src/src/cmd_mount.rs
index 0150ffd..b79985d 100644
--- a/rust-src/src/cmd_mount.rs
+++ b/rust-src/src/cmd_mount.rs
@@ -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
     }
 }
-- 
2.40.1


             reply	other threads:[~2023-08-10 13:30 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 13:22 Linus Heckemann [this message]
2023-08-10 15:01 ` [PATCH] cmd_mount: don't return 0 on mount failure Kent Overstreet

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230810132225.796096-1-git@sphalerite.org \
    --to=git@sphalerite.org \
    --cc=linux-bcachefs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox