From 31066e17e843b10e4abeb983ae4c8cc0279591d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Fri, 31 May 2024 02:27:43 +0200 Subject: [PATCH 1/2] fix: keep compat with MSRV MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Mühlbacher --- src/commands/mount.rs | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/commands/mount.rs b/src/commands/mount.rs index 49849aae..622f6cb9 100644 --- a/src/commands/mount.rs +++ b/src/commands/mount.rs @@ -345,15 +345,15 @@ fn cmd_mount_inner(opt: Cli) -> Result<()> { if unsafe { bcachefs::bch2_sb_is_encrypted(first_sb.sb) } { let _key_handle = KeyHandle::new_from_search(&uuid).or_else(|_| { opt.passphrase_file - .map(|path| { - Passphrase::new_from_file(&first_sb, path) - .inspect_err(|e| { - error!( - "Failed to read passphrase from file, falling back to prompt: {}", - e - ) - }) - .and_then(|p| KeyHandle::new(&first_sb, &p)) + .and_then(|path| match Passphrase::new_from_file(&first_sb, path) { + Ok(p) => Some(KeyHandle::new(&first_sb, &p)), + Err(e) => { + error!( + "Failed to read passphrase from file, falling back to prompt: {}", + e + ); + None + } }) .unwrap_or_else(|| opt.unlock_policy.apply(&first_sb)) }); From 781ea5d40ff40e2028868c9951c564d136fb24f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=BChlbacher?= Date: Fri, 31 May 2024 02:28:25 +0200 Subject: [PATCH 2/2] fix: minor tweaks for key.rs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Thomas Mühlbacher --- src/key.rs | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/key.rs b/src/key.rs index b4735d66..2a90fbd3 100644 --- a/src/key.rs +++ b/src/key.rs @@ -1,5 +1,5 @@ use std::{ - ffi::{CStr, CString}, + ffi::{c_long, CStr, CString}, fs, io::{stdin, IsTerminal}, mem, @@ -34,10 +34,7 @@ impl UnlockPolicy { pub fn apply(&self, sb: &bch_sb_handle) -> Result { let uuid = sb.sb().uuid(); - info!( - "Attempting to unlock filesystem {} with unlock policy '{}'", - uuid, self - ); + info!("Using filesystem unlock policy '{self}' on {uuid}"); match self { Self::Fail => Err(anyhow!("no passphrase available")), @@ -57,12 +54,12 @@ impl Default for UnlockPolicy { pub struct KeyHandle { // FIXME: Either these come in useful for something or we remove them _uuid: Uuid, - _id: i64, + _id: c_long, } impl KeyHandle { pub fn format_key_name(uuid: &Uuid) -> CString { - CString::new(format!("bcachefs:{}", uuid)).unwrap() + CString::new(format!("bcachefs:{uuid}")).unwrap() } pub fn new(sb: &bch_sb_handle, passphrase: &Passphrase) -> Result { @@ -106,7 +103,7 @@ impl KeyHandle { info!("Found key in keyring"); Ok(KeyHandle { _uuid: sb.sb().uuid(), - _id: key_id as i64, + _id: key_id as c_long, }) } else { Err(anyhow!("failed to add key to keyring: {}", errno::errno()))