1*6a54128fSAndroid Build Coastguard WorkerFSCK_OPT=-fn 2*6a54128fSAndroid Build Coastguard WorkerOUT=$test_name.log 3*6a54128fSAndroid Build Coastguard WorkerEXP=$test_dir/expect 4*6a54128fSAndroid Build Coastguard WorkerCONF=$TMPFILE.conf 5*6a54128fSAndroid Build Coastguard Worker 6*6a54128fSAndroid Build Coastguard Workeros=$(uname -s) 7*6a54128fSAndroid Build Coastguard Workerif [ "$os" = "Darwin" -o "$os" = "GNU" -o "FreeBSD" ]; then 8*6a54128fSAndroid Build Coastguard Worker # creates a 44GB filesystem 9*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: skipped for $os" 10*6a54128fSAndroid Build Coastguard Worker return 0 11*6a54128fSAndroid Build Coastguard Workerfi 12*6a54128fSAndroid Build Coastguard Worker 13*6a54128fSAndroid Build Coastguard Workercat > $CONF << ENDL 14*6a54128fSAndroid Build Coastguard Worker[fs_types] 15*6a54128fSAndroid Build Coastguard Worker hugefile = { 16*6a54128fSAndroid Build Coastguard Worker features = extent,huge_file,flex_bg,uninit_bg,dir_nlink,extra_isize,^resize_inode,sparse_super2 17*6a54128fSAndroid Build Coastguard Worker hash_alg = half_md4 18*6a54128fSAndroid Build Coastguard Worker num_backup_sb = 0 19*6a54128fSAndroid Build Coastguard Worker packed_meta_blocks = 1 20*6a54128fSAndroid Build Coastguard Worker make_hugefiles = 1 21*6a54128fSAndroid Build Coastguard Worker inode_ratio = 4194304 22*6a54128fSAndroid Build Coastguard Worker hugefiles_dir = /store 23*6a54128fSAndroid Build Coastguard Worker hugefiles_name = big-data 24*6a54128fSAndroid Build Coastguard Worker hugefiles_digits = 0 25*6a54128fSAndroid Build Coastguard Worker hugefiles_size = 0 26*6a54128fSAndroid Build Coastguard Worker hugefiles_align = 256M 27*6a54128fSAndroid Build Coastguard Worker num_hugefiles = 1 28*6a54128fSAndroid Build Coastguard Worker zero_hugefiles = false 29*6a54128fSAndroid Build Coastguard Worker flex_bg_size = 262144 30*6a54128fSAndroid Build Coastguard Worker } 31*6a54128fSAndroid Build Coastguard WorkerENDL 32*6a54128fSAndroid Build Coastguard Worker 33*6a54128fSAndroid Build Coastguard Workerecho "mke2fs -F -T hugefile test.img 4T" > $OUT 34*6a54128fSAndroid Build Coastguard WorkerMKE2FS_CONFIG=$CONF $MKE2FS -F -T hugefile $TMPFILE 4T >> $OUT 2>&1 35*6a54128fSAndroid Build Coastguard Workerrm -f $CONF 36*6a54128fSAndroid Build Coastguard Worker 37*6a54128fSAndroid Build Coastguard Worker# check the file system if we get this far, we succeeded... 38*6a54128fSAndroid Build Coastguard Worker$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1 39*6a54128fSAndroid Build Coastguard Workerstatus=$? 40*6a54128fSAndroid Build Coastguard Workerecho Exit status is $status >> $OUT 41*6a54128fSAndroid Build Coastguard Worker 42*6a54128fSAndroid Build Coastguard Workerecho 'debugfs -R "extents /store/big-data" test.img' >> $OUT 43*6a54128fSAndroid Build Coastguard Worker 44*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -R "extents /store/big-data" $TMPFILE 2>&1 | tr / " " | tr -d - | awk ' 45*6a54128fSAndroid Build Coastguard WorkerBEGIN { 46*6a54128fSAndroid Build Coastguard Worker expected_logical_start = 0; 47*6a54128fSAndroid Build Coastguard Worker expected_physical_start = 0; 48*6a54128fSAndroid Build Coastguard Worker} 49*6a54128fSAndroid Build Coastguard Worker{ 50*6a54128fSAndroid Build Coastguard Worker if (NR != 1) { 51*6a54128fSAndroid Build Coastguard Worker level = $1; 52*6a54128fSAndroid Build Coastguard Worker total_levels = $2; 53*6a54128fSAndroid Build Coastguard Worker 54*6a54128fSAndroid Build Coastguard Worker if (level == total_levels) { 55*6a54128fSAndroid Build Coastguard Worker logical_start=$5; 56*6a54128fSAndroid Build Coastguard Worker logical_end=$6; 57*6a54128fSAndroid Build Coastguard Worker physical_start=$7; 58*6a54128fSAndroid Build Coastguard Worker physical_end=$8; 59*6a54128fSAndroid Build Coastguard Worker len = $9; 60*6a54128fSAndroid Build Coastguard Worker 61*6a54128fSAndroid Build Coastguard Worker if (logical_end + 1 - logical_start != len) { 62*6a54128fSAndroid Build Coastguard Worker print logical_end + 1 - logical_start, len; 63*6a54128fSAndroid Build Coastguard Worker print "UNEXPECTED LENGTH for extent", $0; 64*6a54128fSAndroid Build Coastguard Worker } 65*6a54128fSAndroid Build Coastguard Worker if (physical_end + 1 - physical_start != len) { 66*6a54128fSAndroid Build Coastguard Worker print physical_end + 1 - physical_start, len; 67*6a54128fSAndroid Build Coastguard Worker print "UNEXPECTED LENGTH for extent", $0; 68*6a54128fSAndroid Build Coastguard Worker } 69*6a54128fSAndroid Build Coastguard Worker 70*6a54128fSAndroid Build Coastguard Worker if (logical_start != expected_logical_start) { 71*6a54128fSAndroid Build Coastguard Worker print "UNEXPECTED LOGICAL DISCONTINUITY between extents:"; 72*6a54128fSAndroid Build Coastguard Worker print "\t", prev; 73*6a54128fSAndroid Build Coastguard Worker print "\t", $0; 74*6a54128fSAndroid Build Coastguard Worker } 75*6a54128fSAndroid Build Coastguard Worker if (physical_start != expected_physical_start && 76*6a54128fSAndroid Build Coastguard Worker expected_logical_start != 0) { 77*6a54128fSAndroid Build Coastguard Worker print "PHYSICAL DISCONTINUITY between extents:"; 78*6a54128fSAndroid Build Coastguard Worker print "\t", prev; 79*6a54128fSAndroid Build Coastguard Worker print "\t", $0; 80*6a54128fSAndroid Build Coastguard Worker } 81*6a54128fSAndroid Build Coastguard Worker 82*6a54128fSAndroid Build Coastguard Worker expected_logical_start = logical_end + 1; 83*6a54128fSAndroid Build Coastguard Worker expected_physical_start = physical_end + 1; 84*6a54128fSAndroid Build Coastguard Worker } 85*6a54128fSAndroid Build Coastguard Worker } 86*6a54128fSAndroid Build Coastguard Worker prev=$0; 87*6a54128fSAndroid Build Coastguard Worker} 88*6a54128fSAndroid Build Coastguard WorkerEND { 89*6a54128fSAndroid Build Coastguard Worker print "Last logical block:", expected_logical_start-1; 90*6a54128fSAndroid Build Coastguard Worker print "Last physical block:", expected_physical_start-1; 91*6a54128fSAndroid Build Coastguard Worker} 92*6a54128fSAndroid Build Coastguard Worker' >> $OUT 2>&1 93*6a54128fSAndroid Build Coastguard Worker 94*6a54128fSAndroid Build Coastguard Workerrm $TMPFILE 95*6a54128fSAndroid Build Coastguard Worker 96*6a54128fSAndroid Build Coastguard Worker# 97*6a54128fSAndroid Build Coastguard Worker# Do the verification 98*6a54128fSAndroid Build Coastguard Worker# 99*6a54128fSAndroid Build Coastguard Worker 100*6a54128fSAndroid Build Coastguard Workersed -f $cmd_dir/filter.sed $OUT > $OUT.new 101*6a54128fSAndroid Build Coastguard Workermv $OUT.new $OUT 102*6a54128fSAndroid Build Coastguard Worker 103*6a54128fSAndroid Build Coastguard Workercmp -s $OUT $EXP 104*6a54128fSAndroid Build Coastguard Workerstatus=$? 105*6a54128fSAndroid Build Coastguard Worker 106*6a54128fSAndroid Build Coastguard Workerif [ "$status" = 0 ] ; then 107*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: ok" 108*6a54128fSAndroid Build Coastguard Worker touch $test_name.ok 109*6a54128fSAndroid Build Coastguard Workerelse 110*6a54128fSAndroid Build Coastguard Worker echo "$test_name: $test_description: failed" 111*6a54128fSAndroid Build Coastguard Worker diff $DIFF_OPTS $EXP $OUT > $test_name.failed 112*6a54128fSAndroid Build Coastguard Workerfi 113*6a54128fSAndroid Build Coastguard Worker 114*6a54128fSAndroid Build Coastguard Workerunset IMAGE FSCK_OPT OUT EXP CONF 115