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