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