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 } 20ENDL 21 22echo "tune2fs dangerous prompts test" > $OUT 23 24MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4h -U 6fc3daa4-180d-4f2b-a6f2-f7a5efb79bcf $TMPFILE 524288 >> $OUT 2>&1 25 26# trigger a filesystem check 27$DEBUGFS -w -R 'ssv mtime now' $TMPFILE > /dev/null 2>&1 28$DEBUGFS -w -R 'ssv lastcheck 20000' $TMPFILE > /dev/null 2>&1 29 30# add mcsum 31echo "tune2fs -O metadata_csum test.img" >> $OUT 32$TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 33status=$? 34echo Exit status is $status >> $OUT 35 36# check fs 37$FSCK -f -y -N test_filesys $TMPFILE > /dev/null 2>&1 38 39# add mcsum 40echo "tune2fs -O metadata_csum test.img" >> $OUT 41$TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 42status=$? 43echo Exit status is $status >> $OUT 44 45MKE2FS_CONFIG=$CONF $MKE2FS -F -T ext4h -U 6fc3daa4-180d-4f2b-a6f2-f7a5efb79bcf $TMPFILE 524288 >> $OUT 2>&1 46 47# dump and check 48$DUMPE2FS $TMPFILE 2> /dev/null | grep '^Group 0:' -B99 -A20 | sed -f $cmd_dir/filter.sed > $OUT.before 49$FSCK $FSCK_OPT -f -N test_filesys $TMPFILE >> $OUT 2>&1 50status=$? 51echo Exit status is $status >> $OUT 52 53# add mcsum 54echo "tune2fs -O metadata_csum test.img" >> $OUT 55echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 56status=$? 57echo Exit status is $status >> $OUT 58 59# change inode size 60echo "tune2fs -I 512 test.img" >> $OUT 61echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -I 512 $TMPFILE >> $OUT 2>&1 62status=$? 63echo Exit status is $status >> $OUT 64 65# change uuid 66echo "tune2fs -U random test.img" >> $OUT 67echo 'n' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -U random $TMPFILE >> $OUT 2>&1 68status=$? 69echo Exit status is $status >> $OUT 70 71# check 72$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 73 74# dump and check 75$DUMPE2FS $TMPFILE 2> /dev/null | grep '^Group 0:' -B99 -A20 | sed -f $cmd_dir/filter.sed > $OUT.after 76echo "Change in FS metadata:" >> $OUT 77diff -u $OUT.before $OUT.after | tail -n +3 >> $OUT 78$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1 79status=$? 80echo Exit status is $status >> $OUT 81 82$DUMPE2FS $TMPFILE 2> /dev/null | egrep '^(Filesystem features:|Filesystem UUID:|Inode size:)' > $OUT.before 83 84# add mcsum 85echo "tune2fs -O metadata_csum test.img" >> $OUT 86echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -O metadata_csum $TMPFILE >> $OUT 2>&1 87status=$? 88echo Exit status is $status >> $OUT 89$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 90 91# change inode size 92echo "tune2fs -I 512 test.img" >> $OUT 93echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -I 512 $TMPFILE >> $OUT 2>&1 94status=$? 95echo Exit status is $status >> $OUT 96 97# change uuid 98echo "tune2fs -U f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0 test.img" >> $OUT 99echo 'y' | TUNE2FS_FORCE_PROMPT=1 $TUNE2FS -U f0f0f0f0-f0f0-f0f0-f0f0-f0f0f0f0f0f0 $TMPFILE >> $OUT 2>&1 100status=$? 101echo Exit status is $status >> $OUT 102 103# check 104$FSCK -yD -N test_filesys $TMPFILE >> $OUT 2>&1 105 106# dump and check 107$DUMPE2FS $TMPFILE 2> /dev/null | egrep '^(Filesystem features:|Filesystem UUID:|Inode size:)' > $OUT.after 108echo "Change in FS metadata:" >> $OUT 109diff -u $OUT.before $OUT.after | tail -n +3 >> $OUT 110$FSCK $FSCK_OPT -N test_filesys $TMPFILE >> $OUT 2>&1 111status=$? 112echo Exit status is $status >> $OUT 113 114rm $TMPFILE $OUT.before $OUT.after $CONF 115 116# 117# Do the verification 118# 119 120sed -f $cmd_dir/filter.sed -e 's/test_filesys:.*//g' < $OUT > $OUT.new 121mv $OUT.new $OUT 122 123cmp -s $OUT $EXP 124status=$? 125 126if [ "$status" = 0 ] ; then 127 echo "$test_name: $test_description: ok" 128 touch $test_name.ok 129else 130 echo "$test_name: $test_description: failed" 131 diff $DIFF_OPTS $EXP $OUT > $test_name.failed 132fi 133 134unset IMAGE FSCK_OPT OUT EXP CONF 135