2017-08-31 16:49:38 +00:00
|
|
|
#!/bin/bash
|
|
|
|
#
|
|
|
|
# test 'btrfs check --force' on a mounted filesystem
|
|
|
|
|
2023-04-19 15:08:41 +00:00
|
|
|
source "$TEST_TOP/common" || exit
|
2017-08-31 16:49:38 +00:00
|
|
|
|
|
|
|
check_prereq mkfs.btrfs
|
|
|
|
check_prereq btrfs
|
|
|
|
|
|
|
|
setup_root_helper
|
|
|
|
|
2017-10-10 12:57:26 +00:00
|
|
|
# we need to use a real block device, because the check opens the device in
|
2018-11-26 16:53:43 +00:00
|
|
|
# exclusive mode, that unfortunately behaves differently for direct file
|
2017-10-10 12:57:26 +00:00
|
|
|
# access and for the real /dev/loop0 device
|
|
|
|
setup_loopdevs 1
|
|
|
|
prepare_loopdevs
|
|
|
|
TEST_DEV=${loopdevs[1]}
|
|
|
|
|
2019-06-05 17:09:38 +00:00
|
|
|
run_check_mkfs_test_dev
|
2017-08-31 16:49:38 +00:00
|
|
|
run_check_mount_test_dev
|
2017-09-11 15:29:03 +00:00
|
|
|
run_mustfail "checking mounted filesystem without --force" \
|
|
|
|
$SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
|
2017-08-31 16:49:38 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV"
|
2019-10-18 11:16:03 +00:00
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" check --force --repair "$TEST_DEV"
|
2017-08-31 16:49:38 +00:00
|
|
|
run_check_umount_test_dev
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
|
|
|
|
run_check $SUDO_HELPER "$TOP/btrfs" check --force "$TEST_DEV"
|
2017-10-10 12:57:26 +00:00
|
|
|
|
|
|
|
cleanup_loopdevs
|