1*6a54128fSAndroid Build Coastguard Worker#!/bin/sh 2*6a54128fSAndroid Build Coastguard WorkerOPTS="-O bigalloc -C 8192" 3*6a54128fSAndroid Build Coastguard WorkerSIZE=4096 4*6a54128fSAndroid Build Coastguard WorkerIMG=/tmp/foo.img 5*6a54128fSAndroid Build Coastguard WorkerTMP=$(mktemp) 6*6a54128fSAndroid Build Coastguard WorkerSIZE_A=15000 7*6a54128fSAndroid Build Coastguard WorkerSIZE_B=5000 8*6a54128fSAndroid Build Coastguard WorkerSIZE_C=20000 9*6a54128fSAndroid Build Coastguard Worker 10*6a54128fSAndroid Build Coastguard WorkerDEBUGFS=./debugfs/debugfs 11*6a54128fSAndroid Build Coastguard WorkerMKE2FS=./misc/mke2fs 12*6a54128fSAndroid Build Coastguard WorkerFSCK=./e2fsck/e2fsck 13*6a54128fSAndroid Build Coastguard Worker 14*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$IMG bs=1k count=$SIZE 15*6a54128fSAndroid Build Coastguard Workerecho $MKE2FS -F -t ext4 -L test $OPTS test.img $SIZE 16*6a54128fSAndroid Build Coastguard Worker$MKE2FS -F -t ext4 -L test $OPTS $IMG $SIZE 17*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$TMP bs=$SIZE_A count=1 >& /dev/null 18*6a54128fSAndroid Build Coastguard Workerecho Writing $SIZE_A bytes to a 19*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -R "write $TMP a" $IMG 20*6a54128fSAndroid Build Coastguard WorkerBLKS=$(./debugfs/debugfs -R "blocks a" $IMG) 21*6a54128fSAndroid Build Coastguard Workercp /dev/null $TMP 22*6a54128fSAndroid Build Coastguard Workerecho "Releasing blocks $BLKS" 23*6a54128fSAndroid Build Coastguard Workerfor i in $BLKS ; do echo "freeb $i" >> $TMP; done 24*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w $IMG < $TMP >& /dev/null 25*6a54128fSAndroid Build Coastguard Worker 26*6a54128fSAndroid Build Coastguard Workerecho Writing $SIZE_B bytes to b 27*6a54128fSAndroid Build Coastguard Workerdd if=/dev/zero of=$TMP bs=$SIZE_B count=1 >& /dev/null 28*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w -R "write $TMP b" $IMG 29*6a54128fSAndroid Build Coastguard Workerif [ -n "$SIZE_C" ]; then 30*6a54128fSAndroid Build Coastguard Worker BLKS=$(./debugfs/debugfs -R "blocks b" $IMG) 31*6a54128fSAndroid Build Coastguard Worker cp /dev/null $TMP 32*6a54128fSAndroid Build Coastguard Worker echo "Releasing blocks $BLKS" 33*6a54128fSAndroid Build Coastguard Worker for i in $BLKS ; do echo "freeb $i" >> $TMP; done 34*6a54128fSAndroid Build Coastguard Worker $DEBUGFS -w $IMG < $TMP >& /dev/null 35*6a54128fSAndroid Build Coastguard Worker 36*6a54128fSAndroid Build Coastguard Worker echo Writing $SIZE_C bytes to c 37*6a54128fSAndroid Build Coastguard Worker dd if=/dev/zero of=$TMP bs=$SIZE_C count=1 >& /dev/null 38*6a54128fSAndroid Build Coastguard Worker $DEBUGFS -w -R "write $TMP c" $IMG 39*6a54128fSAndroid Build Coastguard Workerfi 40*6a54128fSAndroid Build Coastguard Workerecho "set_inode_field a mtime 201107040000" > $TMP 41*6a54128fSAndroid Build Coastguard Workerecho "set_inode_field b mtime 201107050000" >> $TMP 42*6a54128fSAndroid Build Coastguard Workerif [ -n "$SIZE_C" ]; then 43*6a54128fSAndroid Build Coastguard Worker echo "set_inode_field c mtime 201107060000" >> $TMP 44*6a54128fSAndroid Build Coastguard Workerfi 45*6a54128fSAndroid Build Coastguard Worker$DEBUGFS -w $IMG < $TMP >& /dev/null 46*6a54128fSAndroid Build Coastguard Worker 47*6a54128fSAndroid Build Coastguard Worker$FSCK -fy $IMG 48*6a54128fSAndroid Build Coastguard Workerrm $TMP 49*6a54128fSAndroid Build Coastguard Worker 50