1if ! test -x $DEBUGFS_EXE; then 2 echo "$test_name: $test_description: skipped (no debugfs)" 3 return 0 4fi 5 6FSCK_OPT=-fy 7OUT=$test_name.log 8if [ -f $test_dir/expect.gz ]; then 9 EXP=$test_name.tmp 10 gunzip < $test_dir/expect.gz > $EXP1 11else 12 EXP=$test_dir/expect 13fi 14 15cat > $TMPFILE.conf << ENDL 16[fs_types] 17ext4 = { 18 cluster_size = 8192 19 base_features = sparse_super,filetype,resize_inode,dir_index,ext_attr,^has_journal,extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,64bit 20 blocksize = 1024 21 inode_size = 256 22 inode_ratio = 16384 23} 24ENDL 25MKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1 26rm -f $TMPFILE.conf 27 28$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1 29status=$? 30echo Exit status is $status >> $OUT.new 31 32echo "debugfs write files" >> $OUT.new 33make_file() { 34 name="$1" 35 start="$2" 36 flag="$3" 37 38 cat << ENDL 39write /dev/null $name 40fallocate /$name 0 39 41punch /$name 10 10 42punch /$name 13 13 43punch /$name 26 26 44punch /$name 29 29 45ENDL 46} 47 48#Files we create: 49# a: punch a 40k file 50# b*: punch sparse file starting at b* 51# c*: punch spare file ending at c* 52# d: midcluster to midcluster, surrounding sparse 53# e: partial middle cluster alloc 54# f: one big file 55base=5000 56cat > $TMPFILE.cmd << ENDL 57write /dev/null a 58fallocate /a 0 39 59punch /a 0 39 60ENDL 61echo "ex /a" >> $TMPFILE.cmd2 62 63make_file sample $base --uninit >> $TMPFILE.cmd 64echo "ex /sample" >> $TMPFILE.cmd2 65base=10000 66 67for i in 8 9 10 11 12 13 14 15; do 68 make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd 69 echo "punch /b$i $i 39" >> $TMPFILE.cmd 70 echo "ex /b$i" >> $TMPFILE.cmd2 71done 72 73for i in 24 25 26 27 28 29 30 31; do 74 make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd 75 echo "punch /c$i 0 $i" >> $TMPFILE.cmd 76 echo "ex /c$i" >> $TMPFILE.cmd2 77done 78 79make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd 80echo "punch /d 4 35" >> $TMPFILE.cmd 81echo "ex /d" >> $TMPFILE.cmd2 82 83make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd 84echo "punch /e 19 20" >> $TMPFILE.cmd 85echo "ex /e" >> $TMPFILE.cmd2 86 87cat >> $TMPFILE.cmd << ENDL 88write /dev/null f 89sif /f size 1024 90eo /f 91set_bmap --uninit 0 9000 92ec 93sif /f blocks 16 94setb 9000 95fallocate /f 0 8999 96punch /f 1 8998 97ENDL 98echo "ex /f" >> $TMPFILE.cmd2 99 100$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1 101$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1 102 103$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1 104status=$? 105echo Exit status is $status >> $OUT.new 106sed -f $cmd_dir/filter.sed $OUT.new > $OUT 107rm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new 108 109cmp -s $OUT $EXP 110status=$? 111 112if [ "$status" = 0 ] ; then 113 echo "$test_name: $test_description: ok" 114 touch $test_name.ok 115else 116 echo "$test_name: $test_description: failed" 117 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 118 rm -f $test_name.tmp 119fi 120 121unset IMAGE FSCK_OPT OUT EXP 122