1FSCK_OPT=-fn 2OUT=$test_name.log 3EXP=$test_dir/expect 4CONF=$TMPFILE.conf 5 6cat > $CONF << ENDL 7[fs_types] 8 ext4h = { 9 features = has_journal,extent,huge_file,^flex_bg,uninit_bg,dir_nlink,extra_isize,sparse_super,filetype,dir_index,ext_attr,resize_inode,64bit 10 blocksize = 1024 11 inode_size = 256 12 make_hugefiles = true 13 hugefiles_dir = / 14 hugefiles_slack = 32M 15 hugefiles_name = aaaaa 16 hugefiles_digits = 4 17 hugefiles_size = 1M 18 zero_hugefiles = false 19 } 20 ext4m = { 21 features = has_journal,extent,huge_file,^flex_bg,uninit_bg,dir_nlink,extra_isize,sparse_super,filetype,dir_index,ext_attr,resize_inode,64bit,metadata_csum 22 blocksize = 1024 23 inode_size = 256 24 make_hugefiles = true 25 hugefiles_dir = / 26 hugefiles_slack = 32M 27 hugefiles_name = aaaaa 28 hugefiles_digits = 4 29 hugefiles_size = 1M 30 zero_hugefiles = false 31 } 32ENDL 33 34echo "tune2fs dangerous prompts test" > $OUT 35 36MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4h -o Linux -U 6fc3daa4-180d-4f2b-a6f2-f7a5efb79bcf $TMPFILE 524288 >> $OUT 2>&1 37 38# trigger a filesystem check 39$DEBUGFS -w -R 'ssv mtime now' $TMPFILE > /dev/null 2>&1 40$DEBUGFS -w -R 'ssv lastcheck 20000' $TMPFILE > /dev/null 2>&1 41 42# add mcsum 43echo "tune2fs -O metadata_csum test.img" >> $OUT 44$TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 45status=$? 46echo Exit status is $status >> $OUT 47 48# check fs 49$FSCK -f -y -N test_filesys $TMPFILE > /dev/null 2>&1 50 51# add mcsum 52echo "tune2fs -O metadata_csum test.img" >> $OUT 53$TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 54status=$? 55echo Exit status is $status >> $OUT 56 57MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4h -o Linux -U 6fc3daa4-180d-4f2b-a6f2-f7a5efb79bcf $TMPFILE 524288 >> $OUT 2>&1 58 59# dump and check 60$DUMPE2FS $TMPFILE 2> /dev/null | grep '^Group 0:' -B99 -A20 | sed -f $cmd_dir/filter.sed > $OUT.before 61$FSCK $FSCK_OPT -f -N test_filesys $TMPFILE >> $OUT 2>&1 62status=$? 63echo Exit status is $status >> $OUT 64 65# add mcsum 66echo "tune2fs -O metadata_csum test.img" >> $OUT 67echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 68status=$? 69echo Exit status is $status >> $OUT 70 71# change inode size 72echo "tune2fs -I 512 test.img" >> $OUT 73echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -I 512 $TMPFILE >> $OUT 2>&1 74status=$? 75echo Exit status is $status >> $OUT 76 77# check 78$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 79 80# dump and check 81$DUMPE2FS $TMPFILE 2> /dev/null | grep '^Group 0:' -B99 -A20 | sed -f $cmd_dir/filter.sed > $OUT.after 82echo "Change in FS metadata:" >> $OUT 83diff -u $OUT.before $OUT.after | tail -n +3 >> $OUT 84$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1 85status=$? 86echo Exit status is $status >> $OUT 87 88$DUMPE2FS $TMPFILE 2> /dev/null | egrep '^(Filesystem features:|Filesystem UUID:|Inode size:)' > $OUT.before 89 90# add mcsum 91echo "tune2fs -O metadata_csum test.img" >> $OUT 92echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 93status=$? 94echo Exit status is $status >> $OUT 95$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 96 97# change inode size 98echo "tune2fs -I 512 test.img" >> $OUT 99echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -I 512 $TMPFILE >> $OUT 2>&1 100status=$? 101echo Exit status is $status >> $OUT 102 103# change uuid 104echo "tune2fs -U f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0 test.img" >> $OUT 105echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -U f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0 $TMPFILE >> $OUT 2>&1 106status=$? 107echo Exit status is $status >> $OUT 108 109# check 110$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 111 112# dump and check 113$DUMPE2FS $TMPFILE 2> /dev/null | egrep '^(Filesystem features:|Filesystem UUID:|Inode size:)' > $OUT.after 114echo "Change in FS metadata:" >> $OUT 115diff -u $OUT.before $OUT.after | tail -n +3 >> $OUT 116$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1 117status=$? 118echo Exit status is $status >> $OUT 119 120echo " " >> $OUT 121echo "Testing with metadata checksum enabled" >> $OUT 122 123MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4m -o Linux -U 6fc3daa4-180d-4f2b-a6f2-f7a5efb79bcf $TMPFILE 524288 >> $OUT 2>&1 124$DUMPE2FS $TMPFILE 2> /dev/null | grep '^Group 0:' -B99 -A20 | sed -f $cmd_dir/filter.sed > $OUT.before 125$FSCK $FSCK_OPT -f -N test_filesys $TMPFILE >> $OUT 2>&1 126status=$? 127echo Exit status is $status >> $OUT 128 129# change uuid 130echo "tune2fs -U random test.img" >> $OUT 131echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -U random $TMPFILE >> $OUT 2>&1 132status=$? 133echo Exit status is $status >> $OUT 134 135rm $TMPFILE $OUT.before $OUT.after $CONF 136 137# 138# Do the verification 139# 140 141sed -f $cmd_dir/filter.sed -e 's/test_filesys:.*//g' < $OUT > $OUT.new 142mv $OUT.new $OUT 143 144cmp -s $OUT $EXP 145status=$? 146 147if [ "$status" = 0 ] ; then 148 echo "$test_name: $test_description: ok" 149 touch $test_name.ok 150else 151 echo "$test_name: $test_description: failed" 152 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 153fi 154 155unset IMAGE FSCK_OPT OUT EXP CONF 156