From b4db95b16ee4a684cad4471791a6b069368b0ddd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Tue, 30 Jul 2024 23:21:13 +0200 Subject: [PATCH 1/2] fix: don't try to convert C command returns to u8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- src/bcachefs.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/bcachefs.rs b/src/bcachefs.rs index 0e70d1351..0072ca449 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) + } } } From fb6a56bb817485abf984210d135f46068ed6dc19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Tue, 30 Jul 2024 23:33:53 +0200 Subject: [PATCH 2/2] fix(nix): silence trace from treefmt-nix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Mühlbacher --- flake.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flake.nix b/flake.nix index c670e51fe..4dba19d78 100644 --- a/flake.nix +++ b/flake.nix @@ -195,7 +195,7 @@ flakeCheck = false; programs = { - nixfmt-rfc-style.enable = true; + nixfmt.enable = true; rustfmt.edition = rustfmtToml.edition; rustfmt.enable = true; rustfmt.package = fenix.packages.${system}.default.rustfmt;