summaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
5 daysmount: check if bcachefs module is loadedHEADmasterKent Overstreet
This lets us print out a more useful error. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
10 dayscmd_image_createKent Overstreet
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>
10 dayscmd_strip_allocKent Overstreet
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>
2025-05-29Update bcachefs sources to 7f938192650f bcachefs: darray_find(), darray_find_p()Kent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-29cmd_list: Don't run any fsck/upgradesKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-05-07list: Allow for lookups within a particular snapshotKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-04-13Update bcachefs sources to 2f9361370129 bcachefs: Improve opts.degradedKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-03-27bcachefs-tools: make targets of subvolume create/delete requiredIntegral
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>
2025-03-25mount: Parse bcachefs options, and pass them to mount helperKent Overstreet
This fixes the migrate test - we need to handle the sb=# option. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-03-21fix(key): replace c_str macro with `c""` literalThomas Mühlbacher
According to the MSRV in Cargo.toml, we can use this now. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2025-03-17cmd_recover_super: 'bcachefs recover-super'Kent Overstreet
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>
2024-12-29Merge pull request #345 from Flowdalic/mount-print-errorkoverstreet
mount: print a helpful error message
2024-10-25Allow multiple targets for subvolume delete.Malte Schröder
Signed-off-by: Malte Schröder <malte.schroeder@tnxip.de> Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-25mount: print a helpful error messageFlorian Schmaus
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>
2024-10-12cmd_mount: Change error message on -EBUSY to match util-linuxKent Overstreet
This causes xfstests generic/741 to pass Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-10-05Fix 'fuse' feature conditional compilationKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-09-29cmd_list: open with noxclKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-09-03Remove byteorder depJubilee Young
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.
2024-08-09mount: When mounting a single device, make sure we mount the device specifiedKent Overstreet
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>
2024-08-02Merge pull request #320 from WhatAmISupposedToPutHere/masterkoverstreet
Ask for password via systemd-ask-password
2024-07-30fix: don't try to convert C command returns to u8Thomas Mühlbacher
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>
2024-07-26mount: Ask for password via systemd-ask-passwordSasha Finkelstein
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>
2024-07-22mount: Fix UAF in option string handlingKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-21refactor: fix clippy lintThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-07-21style: nix fmtThomas Mühlbacher
Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-07-21fix(logging): re-enable warn and error by defaultThomas Mühlbacher
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>
2024-07-21feat(logging): switch to custom file:line formatThomas Mühlbacher
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>
2024-07-20Rename option commandsKent Overstreet
set-option -> set-fs-option setattr -> set-file-option Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-20mount: Fall back to read-only on -EROFSKent Overstreet
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>
2024-07-18mount: Close devices before doing mountKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-15logging: kill quiet optionv1.9.4Kent Overstreet
no logging by default, enabled with -v logging by default broke fstests Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-14fix silly clippy warningKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-07-14mount: replace rpassword with rustix::termiosLauri Tirkkonen
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>
2024-06-29feat: use `ExitCode` over `std::process:exit()`Thomas Mühlbacher
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>
2024-06-28feat: add `--quiet` cli argumentThomas Mühlbacher
To silence log outputs on the CLI. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-28feat: use env_loggerThomas Mühlbacher
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>
2024-06-26feat(key): make `UnlockPolicy::Fail` more usefulThomas Mühlbacher
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>
2024-06-26refactor(key): split up unlocking functionsThomas Mühlbacher
This is more similar to the existing C code, which is already in nice small chunks. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26refactor: simplify branches for parsing devThomas Mühlbacher
Less repetition and no nested if/else. Signed-off-by: Thomas Mühlbacher <tmuehlbacher@posteo.net>
2024-06-26feat(mount): make unlock policy optional/explictThomas Mühlbacher
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>
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>