"Fossies" - the Fresh Open Source Software Archive

Member "btrfs-progs-v5.4.1/tests/fsck-tests/013-extent-tree-rebuild/test.sh" (9 Jan 2020, 1127 Bytes) of package /linux/misc/btrfs-progs-v5.4.1.tar.xz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file. See also the latest Fossies "Diffs" side-by-side code changes report for "test.sh": v5.4_vs_v5.4.1.

    1 #!/bin/bash
    2 
    3 source "$TEST_TOP/common"
    4 
    5 check_prereq btrfs-corrupt-block
    6 check_prereq mkfs.btrfs
    7 check_prereq btrfs
    8 
    9 setup_root_helper
   10 prepare_test_dev
   11 
   12 # test whether fsck can rebuild a corrupted extent tree
   13 test_extent_tree_rebuild()
   14 {
   15     run_check_mkfs_test_dev
   16     run_check_mount_test_dev
   17     generate_dataset small
   18 
   19     for i in `seq 1 100`;do
   20         run_check $SUDO_HELPER "$TOP/btrfs" sub snapshot "$TEST_MNT" \
   21             "$TEST_MNT/snapaaaaaaa_$i"
   22     done
   23     run_check_umount_test_dev
   24 
   25     # get extent root bytenr
   26     extent_root_bytenr=`$SUDO_HELPER "$TOP/btrfs" inspect-internal dump-tree -r "$TEST_DEV" | \
   27                 grep extent | awk '{print $7}'`
   28     if [ -z "$extent_root_bytenr" ];then
   29         _fail "fail to get extent root bytenr"
   30     fi
   31 
   32     # corrupt extent root node block
   33     run_check $SUDO_HELPER "$TOP/btrfs-corrupt-block" -l "$extent_root_bytenr" \
   34         -b 4096 "$TEST_DEV"
   35 
   36     $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV" >& /dev/null && \
   37             _fail "btrfs check should detect failure"
   38     run_check $SUDO_HELPER "$TOP/btrfs" check --repair --force --init-extent-tree "$TEST_DEV"
   39     run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
   40 }
   41 
   42 test_extent_tree_rebuild