| #!/bin/sh |
| |
| # These routines contain the filesystem generation code. |
| # This code is sourced by the other scripts so that digest |
| # generation is consistent. |
| |
| # dgen - Exercises the -d directory option of genext2fs |
| # Creates an image with a file of given size |
| # Usage: dgen file-size number-of-blocks |
| dgen () { |
| size=$1; blocks=$2 |
| rm -rf test |
| mkdir -p test |
| cd test |
| if [ x$size = x0 ]; then |
| > file.$1 |
| else |
| dd if=/dev/zero of=file.$1 bs=$size count=1 2>/dev/null |
| fi |
| chmod 777 file.$1 |
| TZ=UTC-11 touch -t 200502070321.43 file.$1 . |
| cd .. |
| ./genext2fs -N 17 -b $blocks -d test -f -q ext2.img |
| } |
| |
| # fgen - Exercises the -f spec-file option of genext2fs |
| # Creates an image with the devices mentioned in the given spec file |
| # Usage: fgen spec-file number-of-blocks |
| fgen () { |
| fname=$1; blocks=$2; |
| mkdir -p test |
| cp $fname test |
| TZ=UTC-11 touch -t 200502070321.43 test/$fname |
| ./genext2fs -N 92 -b $blocks -D test/$fname -f ext2.img |
| } |
| |
| # gen_cleanup - Remove the files generated by the above functions |
| # Usage: gen_cleanup |
| gen_cleanup () { |
| rm -rf ext2.img test |
| } |
| |
| # calc_digest - Return the MD5 digest of the test image |
| # Usage: calc_digest |
| calc_digest () { |
| digest=`md5sum ext2.img 2>/dev/null | cut -f 1 -d " "` |
| if [ x$digest != x ] ; then |
| echo $digest |
| else |
| digest=`md5 ext2.img 2>/dev/null | cut -f 4 -d " "` |
| echo $digest |
| fi |
| } |
| |
| LC_ALL=C |
| export LC_ALL |