1*6a54128fSAndroid Build Coastguard Workerif ! test -x $DEBUGFS_EXE; then 2*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: skipped (no debugfs)" 3*6a54128fSAndroid Build Coastguard Worker return 0 4*6a54128fSAndroid Build Coastguard Workerfi 5*6a54128fSAndroid Build Coastguard Worker 6*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-fy 7*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log 8*6a54128fSAndroid Build Coastguard Workerif [ -f $test_dir/expect.gz ]; then 9*6a54128fSAndroid Build Coastguard Worker EXP=$test_name.tmp 10*6a54128fSAndroid Build Coastguard Worker gunzip < $test_dir/expect.gz > $EXP 11*6a54128fSAndroid Build Coastguard Workerelse 12*6a54128fSAndroid Build Coastguard Worker EXP=$test_dir/expect 13*6a54128fSAndroid Build Coastguard Workerfi 14*6a54128fSAndroid Build Coastguard Worker 15*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.conf << ENDL 16*6a54128fSAndroid Build Coastguard Worker[fs_types] 17*6a54128fSAndroid Build Coastguard Workerext4 = { 18*6a54128fSAndroid Build Coastguard Worker 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*6a54128fSAndroid Build Coastguard Worker blocksize = 1024 20*6a54128fSAndroid Build Coastguard Worker inode_size = 256 21*6a54128fSAndroid Build Coastguard Worker inode_ratio = 16384 22*6a54128fSAndroid Build Coastguard Worker} 23*6a54128fSAndroid Build Coastguard WorkerENDL 24*6a54128fSAndroid Build Coastguard WorkerMKE2FS_CONFIG=$TMPFILE.conf $MKE2FS -F -o Linux -b 1024 -O ^bigalloc -T ext4 $TMPFILE 65536 > $OUT.new 2>&1 25*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE.conf 26*6a54128fSAndroid Build Coastguard Worker 27*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1 28*6a54128fSAndroid Build Coastguard Workerstatus=$? 29*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new 30*6a54128fSAndroid Build Coastguard Worker 31*6a54128fSAndroid Build Coastguard Workerecho "debugfs write files" >> $OUT.new 32*6a54128fSAndroid Build Coastguard Workermake_file() { 33*6a54128fSAndroid Build Coastguard Worker name="$1" 34*6a54128fSAndroid Build Coastguard Worker start="$2" 35*6a54128fSAndroid Build Coastguard Worker flag="$3" 36*6a54128fSAndroid Build Coastguard Worker 37*6a54128fSAndroid Build Coastguard Worker cat << ENDL 38*6a54128fSAndroid Build Coastguard Workerwrite /dev/null $name 39*6a54128fSAndroid Build Coastguard Workersif /$name size 40960 40*6a54128fSAndroid Build Coastguard Workereo /$name 41*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 10 $((start + 10)) 42*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 13 $((start + 13)) 43*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 26 $((start + 26)) 44*6a54128fSAndroid Build Coastguard Workerset_bmap $flag 29 $((start + 29)) 45*6a54128fSAndroid Build Coastguard Workerec 46*6a54128fSAndroid Build Coastguard Workersif /$name blocks 8 47*6a54128fSAndroid Build Coastguard Workersetb $((start + 10)) 48*6a54128fSAndroid Build Coastguard Workersetb $((start + 13)) 49*6a54128fSAndroid Build Coastguard Workersetb $((start + 26)) 50*6a54128fSAndroid Build Coastguard Workersetb $((start + 29)) 51*6a54128fSAndroid Build Coastguard WorkerENDL 52*6a54128fSAndroid Build Coastguard Worker} 53*6a54128fSAndroid Build Coastguard Worker 54*6a54128fSAndroid Build Coastguard Worker#Files we create: 55*6a54128fSAndroid Build Coastguard Worker# a: fallocate a 40k file 56*6a54128fSAndroid Build Coastguard Worker# b*: falloc sparse file starting at b* 57*6a54128fSAndroid Build Coastguard Worker# c*: falloc spare file ending at c* 58*6a54128fSAndroid Build Coastguard Worker# d: midcluster to midcluster, surrounding sparse 59*6a54128fSAndroid Build Coastguard Worker# e: partial middle cluster alloc 60*6a54128fSAndroid Build Coastguard Worker# f: one big file 61*6a54128fSAndroid Build Coastguard Worker# g*: falloc sparse init file starting at g* 62*6a54128fSAndroid Build Coastguard Worker# h*: falloc sparse init file ending at h* 63*6a54128fSAndroid Build Coastguard Worker# i: midcluster to midcluster, surrounding sparse init 64*6a54128fSAndroid Build Coastguard Worker# j: partial middle cluster alloc 65*6a54128fSAndroid Build Coastguard Worker# k: one big init file 66*6a54128fSAndroid Build Coastguard Workerbase=5000 67*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL 68*6a54128fSAndroid Build Coastguard Workerwrite /dev/null a 69*6a54128fSAndroid Build Coastguard Workersif /a size 40960 70*6a54128fSAndroid Build Coastguard Workerfallocate /a 0 39 71*6a54128fSAndroid Build Coastguard WorkerENDL 72*6a54128fSAndroid Build Coastguard Workerecho "ex /a" >> $TMPFILE.cmd2 73*6a54128fSAndroid Build Coastguard Worker 74*6a54128fSAndroid Build Coastguard Workermake_file sample $base --uninit >> $TMPFILE.cmd 75*6a54128fSAndroid Build Coastguard Workerecho "ex /sample" >> $TMPFILE.cmd2 76*6a54128fSAndroid Build Coastguard Workerbase=10000 77*6a54128fSAndroid Build Coastguard Worker 78*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do 79*6a54128fSAndroid Build Coastguard Worker make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd 80*6a54128fSAndroid Build Coastguard Worker echo "fallocate /b$i $i 39" >> $TMPFILE.cmd 81*6a54128fSAndroid Build Coastguard Worker echo "ex /b$i" >> $TMPFILE.cmd2 82*6a54128fSAndroid Build Coastguard Workerdone 83*6a54128fSAndroid Build Coastguard Worker 84*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do 85*6a54128fSAndroid Build Coastguard Worker make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd 86*6a54128fSAndroid Build Coastguard Worker echo "fallocate /c$i 0 $i" >> $TMPFILE.cmd 87*6a54128fSAndroid Build Coastguard Worker echo "ex /c$i" >> $TMPFILE.cmd2 88*6a54128fSAndroid Build Coastguard Workerdone 89*6a54128fSAndroid Build Coastguard Worker 90*6a54128fSAndroid Build Coastguard Workermake_file d $(($base + 640)) --uninit >> $TMPFILE.cmd 91*6a54128fSAndroid Build Coastguard Workerecho "fallocate /d 4 35" >> $TMPFILE.cmd 92*6a54128fSAndroid Build Coastguard Workerecho "ex /d" >> $TMPFILE.cmd2 93*6a54128fSAndroid Build Coastguard Worker 94*6a54128fSAndroid Build Coastguard Workermake_file e $(($base + 680)) --uninit >> $TMPFILE.cmd 95*6a54128fSAndroid Build Coastguard Workerecho "fallocate /e 19 20" >> $TMPFILE.cmd 96*6a54128fSAndroid Build Coastguard Workerecho "ex /e" >> $TMPFILE.cmd2 97*6a54128fSAndroid Build Coastguard Worker 98*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL 99*6a54128fSAndroid Build Coastguard Workerwrite /dev/null f 100*6a54128fSAndroid Build Coastguard Workersif /f size 1024 101*6a54128fSAndroid Build Coastguard Workereo /f 102*6a54128fSAndroid Build Coastguard Workerset_bmap --uninit 0 9000 103*6a54128fSAndroid Build Coastguard Workerec 104*6a54128fSAndroid Build Coastguard Workersif /f blocks 2 105*6a54128fSAndroid Build Coastguard Workersetb 9000 106*6a54128fSAndroid Build Coastguard Workerfallocate /f 0 8999 107*6a54128fSAndroid Build Coastguard WorkerENDL 108*6a54128fSAndroid Build Coastguard Workerecho "ex /f" >> $TMPFILE.cmd2 109*6a54128fSAndroid Build Coastguard Worker 110*6a54128fSAndroid Build Coastguard Worker# Now do it again, but with initialized blocks 111*6a54128fSAndroid Build Coastguard Workerbase=20000 112*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do 113*6a54128fSAndroid Build Coastguard Worker make_file g$i $(($base + (40 * ($i - 8)))) >> $TMPFILE.cmd 114*6a54128fSAndroid Build Coastguard Worker echo "fallocate /g$i $i 39" >> $TMPFILE.cmd 115*6a54128fSAndroid Build Coastguard Worker echo "ex /g$i" >> $TMPFILE.cmd2 116*6a54128fSAndroid Build Coastguard Workerdone 117*6a54128fSAndroid Build Coastguard Worker 118*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do 119*6a54128fSAndroid Build Coastguard Worker make_file h$i $(($base + 320 + (40 * ($i - 24)))) >> $TMPFILE.cmd 120*6a54128fSAndroid Build Coastguard Worker echo "fallocate /h$i 0 $i" >> $TMPFILE.cmd 121*6a54128fSAndroid Build Coastguard Worker echo "ex /h$i" >> $TMPFILE.cmd2 122*6a54128fSAndroid Build Coastguard Workerdone 123*6a54128fSAndroid Build Coastguard Worker 124*6a54128fSAndroid Build Coastguard Workermake_file i $(($base + 640)) >> $TMPFILE.cmd 125*6a54128fSAndroid Build Coastguard Workerecho "fallocate /i 4 35" >> $TMPFILE.cmd 126*6a54128fSAndroid Build Coastguard Workerecho "ex /i" >> $TMPFILE.cmd2 127*6a54128fSAndroid Build Coastguard Worker 128*6a54128fSAndroid Build Coastguard Workermake_file j $(($base + 680)) >> $TMPFILE.cmd 129*6a54128fSAndroid Build Coastguard Workerecho "fallocate /j 19 20" >> $TMPFILE.cmd 130*6a54128fSAndroid Build Coastguard Workerecho "ex /j" >> $TMPFILE.cmd2 131*6a54128fSAndroid Build Coastguard Worker 132*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL 133*6a54128fSAndroid Build Coastguard Workerwrite /dev/null k 134*6a54128fSAndroid Build Coastguard Workersif /k size 1024 135*6a54128fSAndroid Build Coastguard Workereo /k 136*6a54128fSAndroid Build Coastguard Workerset_bmap 0 19000 137*6a54128fSAndroid Build Coastguard Workerec 138*6a54128fSAndroid Build Coastguard Workersif /k blocks 2 139*6a54128fSAndroid Build Coastguard Workersetb 19000 140*6a54128fSAndroid Build Coastguard Workerfallocate /k 0 8999 141*6a54128fSAndroid Build Coastguard Workersif /k size 9216000 142*6a54128fSAndroid Build Coastguard WorkerENDL 143*6a54128fSAndroid Build Coastguard Workerecho "ex /k" >> $TMPFILE.cmd2 144*6a54128fSAndroid Build Coastguard Worker 145*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1 146*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1 147*6a54128fSAndroid Build Coastguard Worker 148*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1 149*6a54128fSAndroid Build Coastguard Workerstatus=$? 150*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new 151*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT.new > $OUT 152*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new 153*6a54128fSAndroid Build Coastguard Worker 154*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP 155*6a54128fSAndroid Build Coastguard Workerstatus=$? 156*6a54128fSAndroid Build Coastguard Worker 157*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then 158*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: ok" 159*6a54128fSAndroid Build Coastguard Worker touch $test_name.ok 160*6a54128fSAndroid Build Coastguard Workerelse 161*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: failed" 162*6a54128fSAndroid Build Coastguard Worker diff $DIFF_OPTS $EXP $OUT > $test_name.failed 163*6a54128fSAndroid Build Coastguard Workerfi 164*6a54128fSAndroid Build Coastguard Workerrm -f $EXP 165*6a54128fSAndroid Build Coastguard Worker 166*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP 167