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 > $EXP1 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 Workerfallocate /$name 0 39 40*6a54128fSAndroid Build Coastguard Workerpunch /$name 10 10 41*6a54128fSAndroid Build Coastguard Workerpunch /$name 13 13 42*6a54128fSAndroid Build Coastguard Workerpunch /$name 26 26 43*6a54128fSAndroid Build Coastguard Workerpunch /$name 29 29 44*6a54128fSAndroid Build Coastguard WorkerENDL 45*6a54128fSAndroid Build Coastguard Worker} 46*6a54128fSAndroid Build Coastguard Worker 47*6a54128fSAndroid Build Coastguard Worker#Files we create: 48*6a54128fSAndroid Build Coastguard Worker# a: punch a 40k file 49*6a54128fSAndroid Build Coastguard Worker# b*: punch sparse file starting at b* 50*6a54128fSAndroid Build Coastguard Worker# c*: punch spare file ending at c* 51*6a54128fSAndroid Build Coastguard Worker# d: midcluster to midcluster, surrounding sparse 52*6a54128fSAndroid Build Coastguard Worker# e: partial middle cluster alloc 53*6a54128fSAndroid Build Coastguard Worker# f: one big file 54*6a54128fSAndroid Build Coastguard Workerbase=5000 55*6a54128fSAndroid Build Coastguard Workercat > $TMPFILE.cmd << ENDL 56*6a54128fSAndroid Build Coastguard Workerwrite /dev/null a 57*6a54128fSAndroid Build Coastguard Workerfallocate /a 0 39 58*6a54128fSAndroid Build Coastguard Workerpunch /a 0 39 59*6a54128fSAndroid Build Coastguard WorkerENDL 60*6a54128fSAndroid Build Coastguard Workerecho "ex /a" >> $TMPFILE.cmd2 61*6a54128fSAndroid Build Coastguard Worker 62*6a54128fSAndroid Build Coastguard Workermake_file sample $base --uninit >> $TMPFILE.cmd 63*6a54128fSAndroid Build Coastguard Workerecho "ex /sample" >> $TMPFILE.cmd2 64*6a54128fSAndroid Build Coastguard Workerbase=10000 65*6a54128fSAndroid Build Coastguard Worker 66*6a54128fSAndroid Build Coastguard Workerfor i in 8 9 10 11 12 13 14 15; do 67*6a54128fSAndroid Build Coastguard Worker make_file b$i $(($base + (40 * ($i - 8)))) --uninit >> $TMPFILE.cmd 68*6a54128fSAndroid Build Coastguard Worker echo "punch /b$i $i 39" >> $TMPFILE.cmd 69*6a54128fSAndroid Build Coastguard Worker echo "ex /b$i" >> $TMPFILE.cmd2 70*6a54128fSAndroid Build Coastguard Workerdone 71*6a54128fSAndroid Build Coastguard Worker 72*6a54128fSAndroid Build Coastguard Workerfor i in 24 25 26 27 28 29 30 31; do 73*6a54128fSAndroid Build Coastguard Worker make_file c$i $(($base + 320 + (40 * ($i - 24)))) --uninit >> $TMPFILE.cmd 74*6a54128fSAndroid Build Coastguard Worker echo "punch /c$i 0 $i" >> $TMPFILE.cmd 75*6a54128fSAndroid Build Coastguard Worker echo "ex /c$i" >> $TMPFILE.cmd2 76*6a54128fSAndroid Build Coastguard Workerdone 77*6a54128fSAndroid Build Coastguard Worker 78*6a54128fSAndroid Build Coastguard Workermake_file d $(($base + 640)) --uninit >> $TMPFILE.cmd 79*6a54128fSAndroid Build Coastguard Workerecho "punch /d 4 35" >> $TMPFILE.cmd 80*6a54128fSAndroid Build Coastguard Workerecho "ex /d" >> $TMPFILE.cmd2 81*6a54128fSAndroid Build Coastguard Worker 82*6a54128fSAndroid Build Coastguard Workermake_file e $(($base + 680)) --uninit >> $TMPFILE.cmd 83*6a54128fSAndroid Build Coastguard Workerecho "punch /e 19 20" >> $TMPFILE.cmd 84*6a54128fSAndroid Build Coastguard Workerecho "ex /e" >> $TMPFILE.cmd2 85*6a54128fSAndroid Build Coastguard Worker 86*6a54128fSAndroid Build Coastguard Workercat >> $TMPFILE.cmd << ENDL 87*6a54128fSAndroid Build Coastguard Workerwrite /dev/null f 88*6a54128fSAndroid Build Coastguard Workersif /f size 1024 89*6a54128fSAndroid Build Coastguard Workereo /f 90*6a54128fSAndroid Build Coastguard Workerset_bmap --uninit 0 9000 91*6a54128fSAndroid Build Coastguard Workerec 92*6a54128fSAndroid Build Coastguard Workersif /f blocks 2 93*6a54128fSAndroid Build Coastguard Workersetb 9000 94*6a54128fSAndroid Build Coastguard Workerfallocate /f 0 8999 95*6a54128fSAndroid Build Coastguard Workerpunch /f 1 8998 96*6a54128fSAndroid Build Coastguard WorkerENDL 97*6a54128fSAndroid Build Coastguard Workerecho "ex /f" >> $TMPFILE.cmd2 98*6a54128fSAndroid Build Coastguard Worker 99*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -f $TMPFILE.cmd $TMPFILE > /dev/null 2>&1 100*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -f $TMPFILE.cmd2 $TMPFILE >> $OUT.new 2>&1 101*6a54128fSAndroid Build Coastguard Worker 102*6a54128fSAndroid Build Coastguard Worker$FSCK -fy -N test_filesys $TMPFILE >> $OUT.new 2>&1 103*6a54128fSAndroid Build Coastguard Workerstatus=$? 104*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT.new 105*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT.new > $OUT 106*6a54128fSAndroid Build Coastguard Workerrm -f $TMPFILE $TMPFILE.cmd $TMPFILE.cmd2 $OUT.new 107*6a54128fSAndroid Build Coastguard Worker 108*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP 109*6a54128fSAndroid Build Coastguard Workerstatus=$? 110*6a54128fSAndroid Build Coastguard Worker 111*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then 112*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: ok" 113*6a54128fSAndroid Build Coastguard Worker touch $test_name.ok 114*6a54128fSAndroid Build Coastguard Workerelse 115*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: failed" 116*6a54128fSAndroid Build Coastguard Worker diff $DIFF_OPTS $EXP $OUT > $test_name.failed 117*6a54128fSAndroid Build Coastguard Worker rm -f $test_name.tmp 118*6a54128fSAndroid Build Coastguard Workerfi 119*6a54128fSAndroid Build Coastguard Worker 120*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP 121