2 use structopt::StructOpt;
7 message: std::borrow::Cow<'static, String>
10 pub type GResult<T, E, OE> =::core::result::Result< ::core::result::Result<T, E>, OE>;
11 pub type Result<T, E> = GResult<T, E, GError>;
18 std::ffi::CStr::from_ptr(concat!($lit, "\0").as_ptr() as *const std::os::raw::c_char)
20 .as_ptr() as *const std::os::raw::c_char
26 struct ErrnoError(errno::Errno);
27 impl std::fmt::Display for ErrnoError {
28 fn fmt(&self, f: &mut std::fmt::Formatter) -> Result<(), std::fmt::Error> {
32 impl std::error::Error for ErrnoError {}
35 pub enum KeyLocation {
42 pub struct KeyLoc(pub Option<KeyLocation>);
43 impl std::ops::Deref for KeyLoc {
44 type Target = Option<KeyLocation>;
45 fn deref(&self) -> &Self::Target {
49 impl std::str::FromStr for KeyLoc {
50 type Err = anyhow::Error;
51 fn from_str(s: &str) -> anyhow::Result<Self> {
52 // use anyhow::anyhow;
54 "" => Ok(KeyLoc(None)),
55 "fail" => Ok(KeyLoc(Some(KeyLocation::Fail))),
56 "wait" => Ok(KeyLoc(Some(KeyLocation::Wait))),
57 "ask" => Ok(KeyLoc(Some(KeyLocation::Ask))),
58 _ => Err(anyhow!("invalid password option")),
63 #[derive(StructOpt, Debug)]
64 /// Mount a bcachefs filesystem by its UUID.
66 /// Where the password would be loaded from.
68 /// Possible values are:
69 /// "fail" - don't ask for password, fail if filesystem is encrypted;
70 /// "wait" - wait for password to become available before mounting;
71 /// "ask" - prompt the user for password;
72 #[structopt(short, long, default_value = "")]
73 pub key_location: KeyLoc,
75 /// External UUID of the bcachefs filesystem
78 /// Where the filesystem should be mounted. If not set, then the filesystem
79 /// won't actually be mounted. But all steps preceeding mounting the
80 /// filesystem (e.g. asking for passphrase) will still be performed.
81 pub mountpoint: Option<std::path::PathBuf>,
84 #[structopt(short, default_value = "")]
91 // pub fn mnt_in_use()