2017-08-22 16:32:57 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# Check the various combinations of real blocks, holes, and tails
|
|
|
|
# Since it's possible to have a valid extent layout that check will
|
|
|
|
# happily accept AND have garbage in the output, compare the results
|
|
|
|
# as well.
|
|
|
|
# We use separate inputs for tails and real blocks so we can determine
|
|
|
|
# if there was a failure in copying either.
|
|
|
|
|
2018-02-08 06:34:19 +00:00
|
|
|
source "$TEST_TOP/common"
|
|
|
|
source "$TEST_TOP/common.convert"
|
2017-08-22 16:32:57 +00:00
|
|
|
|
2017-09-07 15:29:51 +00:00
|
|
|
if ! check_kernel_support_reiserfs >/dev/null; then
|
|
|
|
_not_run "no reiserfs support"
|
|
|
|
fi
|
|
|
|
|
2017-08-22 16:32:57 +00:00
|
|
|
check_prereq btrfs-convert
|
|
|
|
check_global_prereq md5sum
|
2017-08-29 14:35:01 +00:00
|
|
|
check_global_prereq mkreiserfs
|
2017-08-22 16:32:57 +00:00
|
|
|
|
2023-04-13 18:40:23 +00:00
|
|
|
setup_root_helper
|
|
|
|
prepare_test_dev
|
|
|
|
|
2018-03-23 15:03:14 +00:00
|
|
|
printf "%0.sa" {1..8192} > input
|
|
|
|
printf "%0.sb" {1..8192} > input2
|
2017-08-22 16:32:57 +00:00
|
|
|
|
|
|
|
default_mkfs="mkreiserfs -b 4096"
|
|
|
|
convert_test_preamble '' 'tail conversion test' 16k "$default_mkfs"
|
|
|
|
convert_test_prep_fs reiserfs $default_mkfs
|
|
|
|
|
|
|
|
# Hole alone
|
|
|
|
run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/hole"
|
|
|
|
|
|
|
|
# Tail alone
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/1k" bs=1k count=1 \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
|
|
|
|
# Single indirect block
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k" bs=1k count=4 \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
|
|
|
|
# Indirect block + tail
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/5k" bs=1k count=4 \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/5k" bs=1k count=1 \
|
|
|
|
seek=4 > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Hole followed by tail
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/hole-1k" bs=1k count=1 \
|
|
|
|
seek=4 > /dev/null 2>&1
|
|
|
|
|
|
|
|
# Indirect block followed by hole
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole" bs=1k count=4 \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
run_check $SUDO_HELPER truncate -s 81920 "$TEST_MNT/4k-hole"
|
|
|
|
|
|
|
|
# Indirect block followed by hole followed by tail
|
|
|
|
run_check $SUDO_HELPER dd if=input of="$TEST_MNT/4k-hole-1k" bs=1k count=4 \
|
|
|
|
> /dev/null 2>&1
|
|
|
|
run_check $SUDO_HELPER truncate -s 8192 "$TEST_MNT/4k-hole-1k"
|
|
|
|
run_check $SUDO_HELPER dd if=input2 of="$TEST_MNT/4k-hole-1k" bs=1k count=1 \
|
|
|
|
seek=8 > /dev/null 2>&1
|
|
|
|
|
|
|
|
rm -f input input2
|
|
|
|
|
|
|
|
declare -A SUMS
|
|
|
|
for file in "$TEST_MNT"/*; do
|
|
|
|
SUM=$(md5sum "$file")
|
|
|
|
SUMS["$file"]=$SUM
|
|
|
|
done
|
|
|
|
|
|
|
|
run_check_umount_test_dev
|
|
|
|
convert_test_do_convert
|
|
|
|
|
|
|
|
run_check_mount_test_dev
|
|
|
|
for file in "${!SUMS[@]}"; do
|
|
|
|
SUM=$(md5sum "$file")
|
|
|
|
run_check test "$SUM" = "${SUMS[$file]}"
|
|
|
|
done
|
|
|
|
run_check_umount_test_dev
|