Skip to contentSkip to conversation

rust keylocation add none variant and implement ValueEnum

PATCH Superseded Finn Behrens 1 participant 1 message Nov 12, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rust keylocation add none variant and implement ValueEnum

This enables a possible values help in the clap help text.

---
 rust-src/src/cmd_mount.rs | 11 +++-------
 rust-src/src/key.rs       | 44 ++++++++++++++++++++++++++-------------
 2 files changed, 32 insertions(+), 23 deletions(-)
rust-src/src/cmd_mount.rs +3 -8
index bb23c1a..e045a3c 100644
@@ -5,7 +5,7 @@ use clap::Parser;
 use uuid::Uuid;
 use std::path::PathBuf;
 use crate::key;
-use crate::key::KeyLoc;
+use crate::key::KeyLocation;
 use crate::logger::SimpleLogger;
 use std::ffi::{CStr, CString, OsStr, c_int, c_char, c_void};
 use std::os::unix::ffi::OsStrExt;
@@ -137,7 +137,7 @@ struct Cli {
     /// "wait" - wait for password to become available before mounting;
     /// "ask" -  prompt the user for password;
     #[arg(short, long, default_value = "ask", verbatim_doc_comment)]
-    key_location:   KeyLoc,
+    key_location:   KeyLocation,
 
     /// Device, or UUID=<UUID>
     dev:            String,
@@ -199,12 +199,7 @@ fn cmd_mount_inner(opt: Cli) -> anyhow::Result<()> {
     if sbs.len() == 0 {
         Err(anyhow::anyhow!("No device found from specified parameters"))?;
     } else if unsafe { bcachefs::bch2_sb_is_encrypted(sbs[0].sb) } {
-        let key = opt
-            .key_location
-            .0
-            .ok_or_else(|| anyhow::anyhow!("no keyoption specified for locked filesystem"))?;
-
-        key::prepare_key(&sbs[0], key)?;
+        key::prepare_key(&sbs[0], opt.key_location)?;
     }
 
     if let Some(mountpoint) = opt.mountpoint {
rust-src/src/key.rs +29 -15

71 lines not on this page · raw message

Signature · 1 line
2.39.3 (Apple Git-145)