1#!/bin/sh 2 3resize_test () { 4 5rm -f $TMPFILE 6touch $TMPFILE 7 8# Verify that the $TMP filesystem handles $SIZE_2 sparse files. 9# If that fails, try the local filesystem instead. 10if truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then 11 > $TMPFILE 12else 13 rm $TMPFILE 14 export TMPFILE=$(TMPDIR=. mktemp -t $test_name.XXXXXX.tmp) 15 touch $TMPFILE 16 if ! truncate -s $SIZE_2 $TMPFILE 2> /dev/null; then 17 rm $TMPFILE 18 return 111 19 fi 20fi 21 22echo $MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 > $LOG 23$MKE2FS $FEATURES -qF $TMPFILE $SIZE_1 >> $LOG 24 25OUT_TMP=$(mktemp -t csum-tmp.XXXXXX) 26 27date > $OUT_TMP 28cat $E2FSCK >> $OUT_TMP 29echo $CRCSUM $OUT_TMP >> $LOG 2>&1 30CSUM_1=$($CRCSUM $OUT_TMP) 31echo Checksum is $CSUM_1 >> $LOG 32 33echo Setting up file system >> $LOG 34$DEBUGFS -w $TMPFILE >> $LOG 2>&1 << EOF 35mkdir test 36cd test 37write $OUT_TMP e2fsck 38ls /test 39stat /test/e2fsck 40quit 41EOF 42echo " " >> $LOG 43 44rm -f $OUT_TMP 45 46echo $FSCK -fy $TMPFILE >> $LOG 2>&1 47$FSCK -fy $TMPFILE >> $LOG 2>&1 48 49echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1 50if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 $TMPFILE $SIZE_2 >> $LOG 2>&1 51then 52 return 1 53fi 54 55echo $FSCK -fp $TMPFILE >> $LOG 2>&1 56if ! $FSCK -fp $TMPFILE >> $LOG 2>&1 57then 58 dumpe2fs $TMPFILE >> $LOG 59 return 1 60fi 61 62echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 63$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 64 65echo $CRCSUM $OUT_TMP >> $LOG 2>&1 66CSUM_2=$($CRCSUM $OUT_TMP) 67echo Checksum is $CSUM_2 >> $LOG 68 69if test "$CSUM_1" != "$CSUM_2" 70then 71 return 1 72fi 73 74echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 75if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 76then 77 return 1 78fi 79 80echo $FSCK -fp $TMPFILE >> $LOG 2>&1 81if ! $FSCK -fp $TMPFILE >> $LOG 2>&1 82then 83 dumpe2fs $TMPFILE >> $LOG 84 return 1 85fi 86 87echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 88$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 89 90echo $CRCSUM $OUT_TMP >> $LOG 2>&1 91CSUM_2=$($CRCSUM $OUT_TMP) 92echo Checksum is $CSUM_2 >> $LOG 93 94if test "$CSUM_1" != "$CSUM_2" 95then 96 return 1 97fi 98 99echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 100if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 101then 102 return 1 103fi 104 105echo $FSCK -fp $TMPFILE >> $LOG 2>&1 106if ! $FSCK -fp $TMPFILE >> $LOG 2>&1 107then 108 dumpe2fs $TMPFILE >> $LOG 109 return 1 110fi 111 112echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 113$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 114 115echo $CRCSUM $OUT_TMP >> $LOG 2>&1 116CSUM_2=$($CRCSUM $OUT_TMP) 117echo Checksum is $CSUM_2 >> $LOG 118 119if test "$CSUM_1" != "$CSUM_2" 120then 121 return 1 122fi 123 124echo $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 125if ! $RESIZE2FS $RESIZE2FS_OPTS -d 31 -M $TMPFILE $SIZE_2 >> $LOG 2>&1 126then 127 return 1 128fi 129 130echo $FSCK -fp $TMPFILE >> $LOG 2>&1 131if ! $FSCK -fp $TMPFILE >> $LOG 2>&1 132then 133 dumpe2fs $TMPFILE >> $LOG 134 return 1 135fi 136 137echo $DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 138$DEBUGFS -R "dump /test/e2fsck $OUT_TMP" $TMPFILE >> $LOG 2>&1 139 140echo $CRCSUM $OUT_TMP >> $LOG 2>&1 141CSUM_2=$($CRCSUM $OUT_TMP) 142echo Checksum is $CSUM_2 >> $LOG 143 144rm $OUT_TMP 145unset OUT_TMP 146 147if test "$CSUM_1" != "$CSUM_2" 148then 149 return 1 150fi 151 152rm $TMPFILE 153return 0 154 155} 156