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