Before asking for a passphrase, mount.bcachefs searches for an existing
key in the keyring containing a passphrase for the filesystem. This
means that the user only has to enter the passphrase once when mounting
the filesystem multiple times.
However, if the key appears in between the check and the time when
systemd-ask-password queries the user for a password, the existing key
will not be reused. Also, when multiple instances of mount.bcachefs
are started in parallel for the same filesystem (such as during boot),
each of them will see that the key is not in the keyring and start an
instance of systemd-ask-password, meaning that the user will be queried
multiple times.
Fix the race condition by passing the --keyname and --accept-cached
options to systemd-ask-password which also makes it try itself to
retreive a cached password from the keyring before querying the user
for a password.
When mount.bcachefs is started with stdin set to /dev/null (such as when
it is started by systemd during boot), try to use systemd-ask-password
to ask for the passphrase.
Add our own version of 'qemu-img convert', which doesn't have the l1
table size limit or require fixing our missing reflink table.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Fix a compatibility issue - old tools can now mount newer filesystems
with incompatible features, even if they can't do anything else with
them.
cmd_show_super now uses no_version_check as well.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Fix accidental splitbrain issues caused by writing to only some of a
filesystem's devices: now, all subcommands that take member devices will
scan for all members before opening.
Fixes: https://github.com/koverstreet/bcachefs/issues/924
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Pull out the code for scanning for component devices into a separate
module with a nicer interface.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Add a tool for creating small image files.
Data is written out in a reproducible order, sequentially from the
start of the device.
Metadata is initially written to a temporary device, then after writing
out data, the metadata we want to keep (alloc info is left out by
default) is migrated to the real device.
Then, the image file is trimmed to minimum size and the temporary
metadata device dropped.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Add a command for stripping allocation info for a filesystem.
This is primarily to test codepaths used by the new image creation tool.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Currently, when no targets are provided for "bcachefs subvolume create" or
"bcachefs subvolume delete", it will exit silently with code 0. Make targets
(arguments) required to solve this problem.
This patch solves issue https://github.com/koverstreet/bcachefs/issues/766.
Signed-off-by: Integral <integral@archlinuxcn.org>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
New tool for scanning for backup superblocks, to recover when the
primary superblock + sb layout have been overwritten.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Just returning a failure exit status makes it hard to tell what the
actual issue was. Instead, the mount command now also provides some
textual output.
See https://github.com/koverstreet/bcachefs-tools/issues/308 for an
example where mount does not provide any helpful output, even with
BCACHEFS_LOG=trace enabled.
Signed-off-by: Florian Schmaus <flo@geekplace.eu>
This requires something other than literally zero code to replace, but
is another opportunity to deny packagers the fun of experimenting with
replacing crate versions with incompatible patched crate versions.
When mounting a multi device filesystem we have to scan for component
devices from the UUID, but we don't want to scan if it's a single device
filesystem; if the same filesystem is exposed via multiple device nodes
(e.g. dm faulty testing), the scan can pick up the wrong node.
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Fixes Rust panics if some C command (like fsck) returns a value bigger
than 255. The process exit code will be mangled but what can we do, it's
less confusing than a panic (that unfortunately doesn't print the return
value).
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This would allow to supply the password via the plymouth password input.
If systemd-ask-password does not exist or fails to start, falls back to
the old-style password request.
Signed-off-by: Sasha Finkelstein <fnkl.kernel@gmail.com>
Same as it was in most previous releases. Without this, you may not see
any output for certain errors.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This mostly tries to be similar to the default `env_logger` format but
instead of using the more vague target in the log message, we instead
put the file name and line number in the log.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
this is the mount helper's job, and since we're the mount helper...
fixes: xfstests generic/050
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
because rpassword unconditionally open()s /dev/tty, it fails with ENXIO
on the console without workarounds like busybox's cttyhack. in contrast,
bcachefs unlock works fine on console, so change the passphrase prompt
logic in mount to be closer to what it is in unlock.
Signed-off-by: Lauri Tirkkonen <lauri@hacktheplanet.fi>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Should provide us with better outputs on process failure, also makes
unwinding better and is generally recommended over `exit()`.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
Instead of the custom logger impl, which limits the features we can
easily provide for users.
This introduces the `BCACHEFS_LOG` environment variable for setting the
log verbosity. Setting `BCACHEFS_LOG=trace`, e.g. in a test environment,
will yield all log messages.
Also I think it's reasonable to print INFO level logs by default.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>