summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2024-06-26refactor(mount): rename `opt` => `cli`Thomas Mühlbacher
The term option is already used for mount options and the `Option` type. In other modules it's just called `cli`, so let's do that here as well. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26refactor: rm function param only used for log msgThomas Mühlbacher
We lose that bit of info but it's weird to require a parameter simply because we want to use it for a log message. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-20key: use c_long type for keyctl_search() helper fnDavid Disseldorp
The keyctl_search() C function returns a long, which is already reflected in the KeyHandle._id type. The search_keyring() helper function currently returns a Result<i64>, which breaks 32-bit builds for e.g. armv7l: error[E0308]: mismatched types --> src/key.rs:121:16 | 121 | Ok(key_id) | -- ^^^^^^ expected `i64`, found `i32` | | | arguments to this enum variant are incorrect ... error[E0308]: mismatched types --> src/key.rs:135:24 | 135 | _id: id, | ^^ expected `i32`, found `i64` Fix this by changing search_keyring() to return a Result<c_long>. Fixes: f72ded6a ("fix(key): search for key in all relevant keyrings") Signed-off-by: David Disseldorp <ddiss@suse.de> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-06-18fix(logger): log to stderrThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18fix(key): search for key in all relevant keyringsThomas Mühlbacher
Previously, using `bcachefs unlock -k session` would still cause mount to ask for a passphrase. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-18fix(key): remove any newlines from passphraseThomas Mühlbacher
To match the behavior of the C code and because there may be newlines under some conditions. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-10fix(subvol): canonicalize requires path to existThomas Mühlbacher
Which is probably not the case when you want to create a subvolume in that path. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-09fix(subvol): make cmds work with relative pathsThomas Mühlbacher
`Path::parent()` returns `Some("")` for relative paths with a single component. The simplest fix is to just canonicalize the paths first. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-03fix: avoid `addr_of` if we already use a referenceThomas Mühlbacher
It's kind of stupid to use this macro if we have to deref the parameter first. I was too enthusiastic about using this macro instead of `as` because it's nicer to read (imo). Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-03fix: unbreak subvolume commandsThomas Mühlbacher
This was a stupid mistake by me, "fixing" more than what clippy told me to. `p` is already a reference and we should not use the addr of it. Fixes: 96a3462 ("refactor: casting-related `clippy::pedantic` fixes") Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31Merge pull request #284 from tmuehlbacher/fix-result-evalkoverstreet
fix: evaluate KeyHandle Result
2024-05-31refactor: casting-related `clippy::pedantic` fixesThomas Mühlbacher
Prefer using `ptr::addr_of!()` and `pointer::cast()` instead of raw `as` where clippy complains and other type casting lints. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31refactor: make `c_str!` simpler, add testThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31refactor: change some fn type sigs and simplifyThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31refactor: treat harmless `clippy::pedantic` lintsThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31fix: evaluate KeyHandle ResultThomas Mühlbacher
This one is sort of bad to have missed, ouch. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31fix: minor tweaks for key.rsThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-31fix: keep compat with MSRVThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-30feat: rewrite key.rsThomas Mühlbacher
- Introduce `KeyHandle` and `Passphrase` types - Refactor the functions into associated functions - Add `zeroizing` crate to handle passphrase memory safely Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-30refactor: rename function againThomas Mühlbacher
`bch2_sb_is_encrypted_and_locked()` simply does not check if the fs is locked. The name is misleading. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-30refactor: reduce `UnlockPolicy` boilerplateThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-29mount: minor cleanupKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-27style: fix one straggler not caught by rustfmtThomas Mühlbacher
not sure why this wasn't picked up, maybe different versions of nightly rustfmt?
2024-05-26Format with rustfmtKent Overstreet
Note that we're using struct/enum align options, which require nightly. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-26`check_for_key` before `ask_for_passphrase`Thomas Mühlbacher
let's always first check if there is already a key in the keyring available before we try to get the key from some more involved means. Fixes: #261 Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-22refactor: manually fix remaining clippy lintsThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-22refactor: `cargo clippy --fix`Thomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-05-09add "bkey-type" option to list commandThomas Bertschinger
Only bkeys of the specified type will be printed. Also, this reworks the error type in bch_bindgen to be able to represent other kinds of error than just "invalid btree id". Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-07mount: Make udev_bcachefs_info more idiomaticTony Asleson
Signed-off-by: Tony Asleson <tasleson@redhat.com>
2024-05-07Handle mount with FS with 1 deviceTony Asleson
If the user passes a single device node during the mount and we have no information for it in the udev db, we read up the super block. When we do this, if the FS only has 1 block device we will simply go ahead and do the mount instead of walking all the block devices and reading up super blocks looking for devices with a matching FS UUID. Signed-off-by: Tony Asleson <tasleson@redhat.com>
2024-05-07Add env. variable BCACHEFS_BLOCK_SCANTony Asleson
Introduce an env. variable for users that have a broken blkid which renders the udev db as incomplete. Only checks for the existence of the variable, not its value. Signed-off-by: Tony Asleson <tasleson@redhat.com>
2024-05-07mount: Leverage udev dbTony Asleson
If the udev database contains information about bcachefs, utilize it. Otherwise, resort to traversing block devices and checking for bcachefs super blocks. V2: Reduce number of places we call read_super_slient in interators Signed-off-by: Tony Asleson <tasleson@redhat.com>
2024-04-30remove redundant "cmd_" prefix from functions in "commands"Thomas Bertschinger
It is more idiomatic to use `commands::mount` than `commands::cmd_mount`. No functionality changes intended by this patch. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-04-09mount: canonicalize device path for single device nodeTony Asleson
If we pass a symlink for a single device node we fail to locate the device node. Canonicalize the device node before we try to read up the superblock. This allows the following to work. # bcachefs mount /dev/mapper/vg-thinvolume /mnt/lv_thin Signed-off-by: Tony Asleson <tasleson@redhat.com>
2024-03-30cmd_list, cmd_list_journal: pass -o very_degradedKent Overstreet
2024-03-20mount: Handle multi-device with 1 device nodeTony Asleson
Instead of requiring the user to supply all the device nodes for a multi-device FS, allow them to specifiy 1 of them. We then fetch the UUID for the FS and then find all the disks on the system that match this UUID. This allows me to bring up a bcachefs FS in /etc/fstab by using a UUID. This works because it appears the mount command looks up the UUID, finds an entry in /dev/disk/by-uuid and then passes that found device node to mount.bcachefs which fails with `insufficient_devices_to_start` as bcachefs is expecting a list of devices with a ":" between them. This behavior is preserved if a user specifies a list of all the needed device nodes to bring up the FS. Signed-off-by: Tony Asleson <tasleson@redhat.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-13Avoid casting away const when processing C command argsWesley Moore
2024-03-08path_to_cstr()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-23bch2_sb_is_encrypted{,_and_locked}Roland Vet
Specifically also mention locked Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-23Apply naming convention: passphrase->unlock->key->decrypt->fsRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Improve error messageRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Rename sb to block_deviceRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Rename password{,_policy}Roland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Rename KeyLocation to more appropriate KeyPolicyRoland Vet
Also key_location to key_policy Improve help description key policy Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22TypoRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Rename sbs to block_devices_to_mountRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Rephrase help messageRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Remove unnecessary bracketsRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Add decryption by key_fileRoland Vet
- Add key_file option to Cli - Rework decryption flow logic to first attempt key_file - Read password from file and pass to decrypt_master_key Explicity specify '-k' for key_location Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22Add fmt::Display for KeyLocationRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>