The second mount works if the device is already part of the `bcachefs
format` but fails if it's added afterwards. In particular the `blkid`
output is interesting.
This reverts commit 88aa61eb95.
No longer required because the added nixos-tests check already causes
the package to be built now.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This in particular speeds up the dev/run/debug cycle for writing more
tests. Without this, the actual bcachefs-tools package will be rebuilt
by Nix all the time because of changes to files that are tracked by git.
Even when it's changes in parts that aren't relevant to that package
build such as `checks/*`.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
Use nixos-test scaffolding to spawn VMs and run any scripts in
`checks/*.sh` as tests inside of the VM. This should lessen the risk of
any obvious breakage in the CI but needs more and better tests to cover
more commands.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
We already can check if an fs is encrypted with `bcachefs unlock -c`.
With this option we can now instead check if we have a key but not
actually mount by not specifying a mount point. e.g.
```sh
if bcachefs mount -k fail "$blkdev"`; then
echo "device is unlocked!"
fi
```
Not sure what the original intent for this was. For scenarios where
encryption is simply not supported on principle?
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
This changes the semantics of some arguments related to unlocking and
slightly changes the unlocking logic. Also update help formatting/text.
Instead of defaulting to `UnlockPolicy::Ask`, the argument becomes
optional. That means if it is specified, the user really wants that
specific policy. Similar to how `passphrase_file` also works.
This also extends `UnlockPolicy` to override `isatty` detection.
Fixes: #292
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
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>
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>
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>
Previously, using `bcachefs unlock -k session` would still cause mount
to ask for a passphrase.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
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>
Because we were using `DESTDIR` instead of `PREFIX` for some reason, no
one noticed that this didn't work.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
Otherwise the directory {a,m,c} times will be modified by the recursive
copy of the directory tree.
Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
The copy_data function takes a start and an end parameter as the range
of bytes to copy, but it was called with a start and a length parameter.
This resulted in incomplete file copies. Fix it by passing the end of
the range instead of the length.
Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This kernel commit: 65bd442397274347e721a89c2c4882a392bae982 removes
BTREE_ITER_cached from bch2_btree_insert_trans, which causes the
update_inode function to take a long time (~20s). Add this flag back in
the update_inode function.
Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
Add a new source command line argument which specifies the directory
tree that will be copied onto the newly formatted bcachefs filesystem.
This commit also fixes an issue in copy_link where uninitialized data is
copied into the symlink because of a round_up of the buffer size.
Signed-off-by: Ariel Miculas <ariel.miculas@gmail.com>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
This way we get an actually unique version for every version that can be
traced back to the source.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
A useful addition to make sure is available, since we also make clangd
available through clang-tools. bear can generate the
`compile_commands.json` for clangd. For example with `make clean && bear
-- make -j$(nproc)`.
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
`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>