1FSCK_OPT=-yf 2 3TMPFILE=$test_name.tmp 4> $TMPFILE 5 6stat -f $TMPFILE | grep -q "Type: tmpfs" 7if [ $? = 0 ]; then 8 rm -f $TMPFILE 9 echo "$test_name: $test_description: skipped for tmpfs (no O_DIRECT)" 10 return 0 11fi 12 13echo "make the test image ..." > $test_name.log 14$MKE2FS -q -F -o Linux -b 4096 -O mmp -E mmp_update_interval=1 $TMPFILE 100 >> $test_name.log 2>&1 15status=$? 16if [ "$status" != 0 ] ; then 17 echo "mke2fs -O mmp failed" > $test_name.failed 18 echo "$test_name: $test_description: failed" 19 return $status 20fi 21 22kill_debugfs() { 23 trap 0 24 PID=$(ps -o pid,command | grep -v awk | 25 awk "/debugfs -w $TMPFILE/ { print \$1 }") 26 [ "x$PID" != "x" ] && kill -9 $PID 27} 28 29# this will cause debugfs to create the $test_name.mark file once it has 30# passed the MMP startup, then continue reading input until it is killed 31MARKFILE=$test_name.new 32rm -f $MARKFILE 33trap kill_debugfs EXIT 34echo "set mmp sequence to EXT2_MMP_SEQ_FSCK..." >> $test_name.log 35( { echo dump_mmp; echo "dump_inode <2> $MARKFILE"; cat /dev/zero; } | 36 $DEBUGFS -w $TMPFILE >> $test_name.log 2>&1 & ) > /dev/null 2>&1 & 37echo "wait until debugfs has started ..." >> $test_name.log 38while [ ! -e $MARKFILE ]; do 39 sleep 1 40done 41rm -f $MARKFILE 42echo "kill debugfs abruptly (simulates e2fsck failure) ..." >> $test_name.log 43kill_debugfs 44 45 46echo "e2fsck (should fail mmp_seq = EXT2_MMP_SEQ_FSCK) ..." >> $test_name.log 47$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1 48status=$? 49if [ "$status" = 0 ] ; then 50 echo "e2fsck with MMP as EXT2_MMP_SEQ_FSCK ran!" > $test_name.failed 51 echo "$test_name: $test_description: failed" 52 return 1 53fi 54 55echo "clear mmp_seq with tune2fs ..." >> $test_name.log 56$TUNE2FS -f -E clear_mmp $TMPFILE >> $test_name.log 2>&1 57status=$? 58if [ "$status" != 0 ] ; then 59 echo "tune2fs clearing EXT2_MMP_SEQ_FSCK failed" > $test_name.failed 60 echo "$test_name: $test_description: failed" 61 return 1 62fi 63 64echo "run e2fsck again (should pass with clean mmp_seq) ..." >> $test_name.log 65$FSCK $FSCK_OPT $TMPFILE >> $test_name.log 2>&1 66status=$? 67if [ "$status" != 0 ] ; then 68 echo "e2fsck after clearing EXT2_MMP_SEQ_FSCK failed"> $test_name.failed 69 echo "$test_name: $test_description: failed" 70 return $status 71fi 72 73echo "$test_name: $test_description: ok" 74rm -f $TMPFILE 75