Commit Graph

33 Commits

Author SHA1 Message Date
Thomas Bertschinger
2b8a0f0caf remove redundant "cmd_" prefix from functions in "commands"
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-30 21:16:09 -04:00
Tony Asleson
825062222c mount: canonicalize device path for single device node
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-04-09 15:03:26 -05:00
Kent Overstreet
6e50a9b4fc cmd_list, cmd_list_journal: pass -o very_degraded 2024-03-30 22:09:06 -04:00
Tony Asleson
89b322abb3 mount: Handle multi-device with 1 device node
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-20 17:02:35 -04:00
Wesley Moore
888321446d
Avoid casting away const when processing C command args 2024-03-13 20:07:07 +10:00
Kent Overstreet
6a41851118 path_to_cstr()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-03-08 16:40:38 -05:00
Roland Vet
16661be294 bch2_sb_is_encrypted{,_and_locked}
Specifically also mention locked

Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-23 08:37:23 +01:00
Roland Vet
817e957697 Apply naming convention: passphrase->unlock->key->decrypt->fs
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-23 08:37:23 +01:00
Roland Vet
b582c9b4b8 Improve error message
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
eaf5575080 Rename sb to block_device
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
ceb9eaa020 Rename password{,_policy}
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
37c0ae2e79 Rename KeyLocation to more appropriate KeyPolicy
Also key_location to key_policy

Improve help description key policy

Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
ceb259b2a3 Typo
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
46ed72461f Rename sbs to block_devices_to_mount
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
b7c43996a1 Rephrase help message
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
911c53266a Remove unnecessary brackets
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:49 +01:00
Roland Vet
d67643f24c Add decryption by key_file
- 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-22 21:12:49 +01:00
Roland Vet
0ff96b2a0f Add fmt::Display for KeyLocation
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:36 +01:00
Roland Vet
86049a1641 Refactor ask_for_key to call new decrypt_master_key
Signed-off-by: Roland Vet <RlndVt@protonmail.com>
2024-02-22 21:12:02 +01:00
Thomas Bertschinger
25e84a9917 rust: use libc::Ioctl type for ioctl() request argument
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-20 22:27:19 -05:00
ErrorNoInternet
4327e0681b
feat: add aliases for a few subcommands 2024-02-09 17:37:01 +08:00
ErrorNoInternet
428948e120
refactor: clean up arguments 2024-02-09 17:36:49 +08:00
Alexander Fougner
a95a25dc1d Replace atty with stdlib
is_terminal() is part of rust 1.70 std, no need for isatty

Signed-off-by: Alexander Fougner <fougner89@gmail.com>
2024-02-07 21:27:35 +01:00
Kent Overstreet
bc0a443850 kill dependency on char signedness
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 23:13:02 -05:00
Kent Overstreet
168126a41e fix snapshotting when dst is single component path
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 01:34:50 -05:00
Kent Overstreet
f3f005c76e Update bcachefs sources to 50847e296b34 bcachefs: Check subvol <-> inode pointers in check_inode()
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-06 01:07:16 -05:00
Kent Overstreet
1ef396b684 cmd_subvolume: Fix snapshot creation with implicit source
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-02-05 21:31:08 -05:00
Ryan Lahfa
e1d08fc1fc feat(rust/commands): introduce Rust-driven subvolume sub-CLI
This makes use of `BcachefsHandle` to introduce an elegant Rust driven CLI for subvolumes.

Signed-off-by: Ryan Lahfa <bcachefs@lahfa.xyz>
2024-01-27 05:15:19 +01:00
Ryan Lahfa
9282cb953c feat(rust/wrappers): init BcachefsHandle
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-27 05:15:19 +01:00
Will Fancher
de191cd19c rust: fix docs 2024-01-23 02:38:24 -05:00
Kent Overstreet
5e224596cf Remove gag usage
Possibly-fixes: https://github.com/koverstreet/bcachefs-tools/issues/217
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-20 22:32:00 -05:00
Faidon Liambotis
06ff8b55b7 rust: bump rpassword to v7.x
Including a tiny API change.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-01-16 16:30:10 -05:00
Thomas Bertschinger
f5baaf48e3 move Rust sources to top level, C sources into c_src
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>
2024-01-16 01:47:05 -05:00