summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
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>
2024-02-22Refactor ask_for_key to call new decrypt_master_keyRoland Vet
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-20rust: use libc::Ioctl type for ioctl() request argumentThomas Bertschinger
The second argument to ioctl() can be defined as a different type by different libc implementations, and can be a different size on different architectures depending on what type it is defined as. For example, glibc defines it as `unsigned long` which may have a different size on 32-bit vs. 64-bit architectures, and musl libc defines it as `int`. The Rust libc crate exposes a type `libc::Ioctl` which is defined as the appropriate integer type for the given libc implementation. Using this type for the request argument to `libc::ioctl()` ensures code will compile correctly regardless of architecture and libc implementation. Also, because ioctl request numbers are defined to be 32 bits (regardless of the fact that `unsigned long` might sometimes take 64 bits on some architectures), this patch changes the Rust representation of the bcachefs ioctl numbers to u32 instead of u64. Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-09feat: add aliases for a few subcommandsErrorNoInternet
2024-02-09refactor: clean up argumentsErrorNoInternet
2024-02-07Replace atty with stdlibAlexander Fougner
is_terminal() is part of rust 1.70 std, no need for isatty Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2024-02-06kill dependency on char signednessKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06fix snapshotting when dst is single component pathKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06Update bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode ↵Kent Overstreet
pointers in check_inode() Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-05cmd_subvolume: Fix snapshot creation with implicit sourceKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-27feat(rust/commands): introduce Rust-driven `subvolume` sub-CLIRyan Lahfa
This makes use of `BcachefsHandle` to introduce an elegant Rust driven CLI for subvolumes. Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
2024-01-27feat(rust/wrappers): init `BcachefsHandle`Ryan Lahfa
We propose a simple low-level wrapper which can perform various subvolume-related operations as an example for the API surface. This will be used in an upcoming commit to migrate the subvolume CLI fully to Rust. The API design is the following: - `BcachefsHandle` is meant as a low level handle to carry around whenever you need a filesystem handle to send ioctl to. - it possess type-safe operations Type safe operations are handled by having type safe wrappers for ioctl commands *and* their payloads. We assume that all ioctl payloads only use *one* argument, this can easily be changed if needed. When the handle goes out of scope, we automatically close it à la C++ RAII. Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
2024-01-23rust: fix docsWill Fancher
2024-01-20Remove gag usageKent Overstreet
Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217 Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-16rust: bump rpassword to v7.xFaidon Liambotis
Including a tiny API change. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-16move Rust sources to top level, C sources into c_srcThomas Bertschinger
This moves the Rust sources out of rust_src/ and into the top level. Running the bcachefs executable out of the development tree is now: $ ./target/release/bcachefs command or $ cargo run --profile release -- command instead of "./bcachefs command". Building and installing is still: $ make && make install Signed-off-by: Thomas Bertschinger <tahbertschinger@gmail.com> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>