btrfs-progs/mkfs
Qu Wenruo c1d8bd82ca btrfs-progs: mkfs: skip failed mount check with --force
[BUG]
There is a bug report that, with very weird mount status, there can be
some mount source which can not be accessed:

  /path/dev/exports fs 500G 57G 444G 12% /path/dev/exports

Strace shows we can not access the above mount source:

 131065 stat("/path/dev/exports", 0x7ffed17b8e20) = -1 EACCES (Permission denied)

And lead to failed mount check:

 131065 write(2, "ERROR: ", 7)      = 7
 131065 write(2, "cannot check mount status of /de"..., 56) = 56
 131065 write(2, "\n", 1)        = 1

[CAUSE]
The mount check is based on libblkid, which gives the mount source, and
for non-btrfs mounts, we call path_is_reg_or_block_device() to check if
we even need to continue checking.

But in above case, the mount source is another fs, and we can not access
the source.

So we error out causing the check_mounted() to return error.

[FIX]
There is never any guarantee we can access the mount source, but on the
other hand, I do not want to ignore all access failure for the mount
source.

Let test_status_for_mkfs() to only skip check_mounted() error if
@force_overwrite is true.

This would still keep the old strict checks on whether the target is
already mounted, but if the end user really knows that certain mount
source do not need to be checked, they can always pass "-f" option to
skip the false alerts.

Link: https://bugzilla.suse.com/show_bug.cgi?id=1223799
Reported-by: Jiri Belka <jiri.belka@suse.com>
Signed-off-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
2024-05-17 18:23:46 +02:00
..
Makefile btrfs-progs: build: add stub makefile to image and mkfs 2019-07-04 15:36:01 +02:00
common.c btrfs-progs: mkfs: skip failed mount check with --force 2024-05-17 18:23:46 +02:00
common.h btrfs-progs: mkfs: add option to specify device uuid 2023-10-21 15:51:07 +02:00
main.c btrfs-progs: mkfs: make transaction start and commit errors verbose 2024-03-22 01:19:47 +01:00
rootdir.c btrfs-progs: reorder key initializations 2024-04-30 21:49:15 +02:00
rootdir.h btrfs-progs: mkfs: more verbose output for --rootdir 2023-05-26 22:17:33 +02:00