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 > $EXP 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 41sif /$name size 40960 42eo /$name 43set_bmap $flag 10 $((start + 10)) 44set_bmap $flag 13 $((start + 13)) 45set_bmap $flag 26 $((start + 26)) 46set_bmap $flag 29 $((start + 29)) 47ec 48sif /$name blocks 32 49setb $((start + 10)) 50setb $((start + 13)) 51setb $((start + 26)) 52setb $((start + 29)) 53ENDL 54} 55 56#Files we create: 57# a: fallocate a 40k file 58# b*: falloc sparse file starting at b* 59# c*: falloc spare file ending at c* 60# d: midcluster to midcluster, surrounding sparse 61# e: partial middle cluster alloc 62# f: one big file 63# g*: falloc sparse init file starting at g* 64# h*: falloc sparse init file ending at h* 65# i: midcluster to midcluster, surrounding sparse init 66# j: partial middle cluster alloc 67# k: one big init file 68base=5000 69cat > $TMPFILE.cmd << ENDL 70write /dev/null a 71sif /a size 40960 72fallocate /a 0 39 73ENDL 74echo "ex /a" >> $TMPFILE.cmd2 75 76make_file sample $base --uninit >> $TMPFILE.cmd 77echo "ex /sample" >> $TMPFILE.cmd2 78base=10000 79 80for i in 8 9 10 11 12 13 14 15; do 81 make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd 82 echo "fallocate /b$i $i 39" >> $TMPFILE.cmd 83 echo "ex /b$i" >> $TMPFILE.cmd2 84done 85 86for i in 24 25 26 27 28 29 30 31; do 87 make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd 88 echo "fallocate /c$i 0 $i" >> $TMPFILE.cmd 89 echo "ex /c$i" >> $TMPFILE.cmd2 90done 91 92make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd 93echo "fallocate /d 4 35" >> $TMPFILE.cmd 94echo "ex /d" >> $TMPFILE.cmd2 95 96make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd 97echo "fallocate /e 19 20" >> $TMPFILE.cmd 98echo "ex /e" >> $TMPFILE.cmd2 99 100cat >> $TMPFILE.cmd << ENDL 101write /dev/null f 102sif /f size 1024 103eo /f 104set_bmap --uninit 0 9000 105ec 106sif /f blocks 16 107setb 9000 108fallocate /f 0 8999 109ENDL 110echo "ex /f" >> $TMPFILE.cmd2 111 112# Now do it again, but with initialized blocks 113base=20000 114for i in 8 9 10 11 12 13 14 15; do 115 make_file g$i $(($base + (40 * ($i - 8)))) >> $TMPFILE.cmd 116 echo "fallocate /g$i $i 39" >> $TMPFILE.cmd 117 echo "ex /g$i" >> $TMPFILE.cmd2 118done 119 120for i in 24 25 26 27 28 29 30 31; do 121 make_file h$i $(($base + 320 + (40 * ($i - 24)))) >> $TMPFILE.cmd 122 echo "fallocate /h$i 0 $i" >> $TMPFILE.cmd 123 echo "ex /h$i" >> $TMPFILE.cmd2 124done 125 126make_file i $(($base + 640)) >> $TMPFILE.cmd 127echo "fallocate /i 4 35" >> $TMPFILE.cmd 128echo "ex /i" >> $TMPFILE.cmd2 129 130make_file j $(($base + 680)) >> $TMPFILE.cmd 131echo "fallocate /j 19 20" >> $TMPFILE.cmd 132echo "ex /j" >> $TMPFILE.cmd2 133 134cat >> $TMPFILE.cmd << ENDL 135write /dev/null k 136sif /k size 1024 137eo /k 138set_bmap 0 19000 139ec 140sif /k blocks 16 141setb 19000 142fallocate /k 0 8999 143sif /k size 9216000 144ENDL 145echo "ex /k" >> $TMPFILE.cmd2 146 147$DEBUGFS_EXE -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1 148$DEBUGFS_EXE -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1 149sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT 150rm -rf $OUT.new $TMPFILE.cmd $TMPFILE.cmd2 151 152$FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1 153status=$? 154echo Exit status is $status >> $OUT.new 155sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT 156rm -f $OUT.new 157 158rm -f $TMPFILE 159 160cmp -s $OUT $EXP 161status=$? 162 163if [ "$status" = 0 ] ; then 164 echo "$test_name: $test_description: ok" 165 touch $test_name.ok 166else 167 echo "$test_name: $test_description: failed" 168 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 169 rm -f $test_name.tmp 170fi 171 172unset IMAGE FSCK_OPT OUT EXP 173 174else #if test -x $DEBUGFS_EXE; then 175 echo "$test_name: $test_description: skipped" 176fi 177