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 > $EXP 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 sif /$name size 40960 42 eo /$name 43 set_bmap $flag 10 $((start + 10)) 44 set_bmap $flag 13 $((start + 13)) 45 set_bmap $flag 26 $((start + 26)) 46 set_bmap $flag 29 $((start + 29)) 47 ec 48 sif /$name blocks 32 49 setb $((start + 10)) 50 setb $((start + 13)) 51 setb $((start + 26)) 52 setb $((start + 29)) 53 ENDL 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 68 base=5000 69 cat > $TMPFILE.cmd << ENDL 70 write /dev/null a 71 sif /a size 40960 72 fallocate /a 0 39 73 ENDL 74 echo "ex /a" >> $TMPFILE.cmd2 75 76 make_file sample $base --uninit >> $TMPFILE.cmd 77 echo "ex /sample" >> $TMPFILE.cmd2 78 base=10000 79 80 for 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 84 done 85 86 for 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 90 done 91 92 make_file d $(($base + 640)) --uninit >> $TMPFILE.cmd 93 echo "fallocate /d 4 35" >> $TMPFILE.cmd 94 echo "ex /d" >> $TMPFILE.cmd2 95 96 make_file e $(($base + 680)) --uninit >> $TMPFILE.cmd 97 echo "fallocate /e 19 20" >> $TMPFILE.cmd 98 echo "ex /e" >> $TMPFILE.cmd2 99 100 cat >> $TMPFILE.cmd << ENDL 101 write /dev/null f 102 sif /f size 1024 103 eo /f 104 set_bmap --uninit 0 9000 105 ec 106 sif /f blocks 16 107 setb 9000 108 fallocate /f 0 8999 109 ENDL 110 echo "ex /f" >> $TMPFILE.cmd2 111 112 # Now do it again, but with initialized blocks 113 base=20000 114 for 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 118 done 119 120 for 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 124 done 125 126 make_file i $(($base + 640)) >> $TMPFILE.cmd 127 echo "fallocate /i 4 35" >> $TMPFILE.cmd 128 echo "ex /i" >> $TMPFILE.cmd2 129 130 make_file j $(($base + 680)) >> $TMPFILE.cmd 131 echo "fallocate /j 19 20" >> $TMPFILE.cmd 132 echo "ex /j" >> $TMPFILE.cmd2 133 134 cat >> $TMPFILE.cmd << ENDL 135 write /dev/null k 136 sif /k size 1024 137 eo /k 138 set_bmap 0 19000 139 ec 140 sif /k blocks 16 141 setb 19000 142 fallocate /k 0 8999 143 sif /k size 9216000 144 ENDL 145 echo "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 149 sed -f $cmd_dir/filter.sed < $OUT.new >> $OUT 150 rm -rf $OUT.new $TMPFILE.cmd $TMPFILE.cmd2 151 152 $FSCK -fy -N test_filesys $TMPFILE > $OUT.new 2>&1 153 status=$? 154 echo Exit status is $status >> $OUT.new 155 sed -f $cmd_dir/filter.sed -e "s;$TMPFILE;test.img;" $OUT.new >> $OUT 156 rm -f $OUT.new 157 158 rm -f $TMPFILE 159 160 cmp -s $OUT $EXP 161 status=$? 162 163 if [ "$status" = 0 ] ; then 164 echo "$test_name: $test_description: ok" 165 touch $test_name.ok 166 else 167 echo "$test_name: $test_description: failed" 168 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 169 rm -f $test_name.tmp 170 fi 171 172 unset IMAGE FSCK_OPT OUT EXP 173 174 else #if test -x $DEBUGFS_EXE; then 175 echo "$test_name: $test_description: skipped" 176 fi 177