diff options
author | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-07-30 23:21:13 +0200 |
---|---|---|
committer | Thomas Mühlbacher <tmuehlbacher@posteo.net> | 2024-07-30 23:33:09 +0200 |
commit | b4db95b16ee4a684cad4471791a6b069368b0ddd (patch) | |
tree | 6d89d5fa07cb4c2c8e6472a4f1122eba76cc7c09 | |
parent | 57cd58db1e7945c65ff03035fc54f69b5b3bd565 (diff) |
fix: don't try to convert C command returns to u8
Fixes Rust panics if some C command (like fsck) returns a value bigger
than 255. The process exit code will be mangled but what can we do, it's
less confusing than a panic (that unfortunately doesn't print the return
value).
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
-rw-r--r-- | src/bcachefs.rs | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/bcachefs.rs b/src/bcachefs.rs index 0e70d135..0072ca44 100644 --- a/src/bcachefs.rs +++ b/src/bcachefs.rs @@ -9,6 +9,7 @@ use std::{ }; use bch_bindgen::c; +use log::debug; #[derive(Debug)] pub struct ErrnoError(pub errno::Errno); @@ -110,6 +111,11 @@ fn main() -> ExitCode { "list" => commands::list(args[1..].to_vec()).report(), "mount" => commands::mount(args, symlink_cmd).report(), "subvolume" => commands::subvolume(args[1..].to_vec()).report(), - _ => ExitCode::from(u8::try_from(handle_c_command(args, symlink_cmd)).unwrap()), + _ => { + let r = handle_c_command(args, symlink_cmd); + + debug!("return code from C command: {r}"); + ExitCode::from(r as u8) + } } } |