Home | History | Annotate | Download | only in genext2fs
      1 #!/bin/sh
      2 
      3 # These routines contain the filesystem generation code.
      4 # This code is sourced by the other scripts so that digest
      5 # generation is consistent.
      6 
      7 # dgen - Exercises the -d directory option of genext2fs
      8 # Creates an image with a file of given size
      9 # Usage: dgen file-size number-of-blocks 
     10 dgen () {
     11 	size=$1; blocks=$2
     12 	rm -rf test
     13 	mkdir -p test
     14 	cd test
     15 	if [ x$size = x0 ]; then
     16 		> file.$1
     17 	else
     18 		dd if=/dev/zero of=file.$1 bs=$size count=1 2>/dev/null
     19 	fi
     20         chmod 777 file.$1
     21 	TZ=UTC-11 touch -t 200502070321.43 file.$1 .
     22 	cd ..
     23 	./genext2fs -N 17 -b $blocks -d test -f -q ext2.img 
     24 }
     25 
     26 # fgen - Exercises the -f spec-file option of genext2fs
     27 # Creates an image with the devices mentioned in the given spec file 
     28 # Usage: fgen spec-file number-of-blocks 
     29 fgen () {
     30 	fname=$1; blocks=$2; 
     31 	mkdir -p test
     32 	cp $fname test
     33 	TZ=UTC-11 touch -t 200502070321.43 test/$fname
     34 	./genext2fs -N 92 -b $blocks -D test/$fname -f ext2.img
     35 }
     36 
     37 # gen_cleanup - Remove the files generated by the above functions
     38 # Usage: gen_cleanup
     39 gen_cleanup () {
     40 	rm -rf ext2.img test
     41 }
     42 
     43 # calc_digest - Return the MD5 digest of the test image
     44 # Usage: calc_digest
     45 calc_digest () {
     46 	digest=`md5sum ext2.img 2>/dev/null | cut -f 1 -d " "`
     47 	if [ x$digest != x ] ; then
     48  		echo $digest
     49 	else
     50 		digest=`md5 ext2.img 2>/dev/null | cut -f 4 -d " "`
     51 		echo $digest
     52 	fi
     53 }
     54 
     55 LC_ALL=C
     56 export LC_ALL
     57