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