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