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