]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
common/rc: introduce _check_f2fs_filesystem()
authorChao Yu <chao@kernel.org>
Tue, 25 Mar 2025 12:58:23 +0000 (20:58 +0800)
committerZorro Lang <zlang@kernel.org>
Fri, 28 Mar 2025 01:05:05 +0000 (09:05 +0800)
_check_generic_filesystem() will fail the test once it detects
corruption, let's introduce _check_f2fs_filesystem() to just check
filesystem w/ --dry-run option, and return the error number, then
let caller to decide whether the corruption is as expected or not.

Cc: Jaegeuk Kim <jaegeuk@kernel.org>
Signed-off-by: Chao Yu <chao@kernel.org>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc

index e954e7fd2df218b1b2b90db2ffada74e76775928..3b4c2255b482011b33089778a98f021879709314 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -3519,6 +3519,50 @@ _check_generic_filesystem()
     return 0
 }
 
+_check_f2fs_filesystem()
+{
+    local device=$1
+
+    # If type is set, we're mounted
+    local type=`_fs_type $device`
+    local ok=1
+
+    if [ "$type" = "f2fs" ]
+    then
+        # mounted ...
+        local mountpoint=`_umount_or_remount_ro $device`
+    fi
+
+    $F2FS_FSCK_PROG --dry-run $device >$tmp.fsck.f2fs 2>&1
+    if [ $? -ne 0 ];then
+        _log_err "_check_f2fs_filesystem: filesystem on $device is inconsistent"
+        echo "*** fsck.f2fs output ***" >>$seqres.full
+        cat $tmp.fsck.f2fs              >>$seqres.full
+        echo "*** end fsck.f2fs output" >>$seqres.full
+
+    ok=0
+    fi
+    rm -f $tmp.fsck.f2fs
+
+    if [ $ok -eq 0 ]
+    then
+        echo "*** mount output ***"            >>$seqres.full
+        _mount                                 >>$seqres.full
+        echo "*** end mount output"            >>$seqres.full
+    elif [ "$type" = "f2fs" ]
+    then
+       # was mounted ...
+       _mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+       ok=$?
+    fi
+
+    if [ $ok -eq 0 ]; then
+       return 1
+    fi
+
+    return 0
+}
+
 # Filter the knowen errors the UDF Verifier reports.
 _udf_test_known_error_filter()
 {
@@ -3623,6 +3667,9 @@ _check_test_fs()
     ubifs)
        # there is no fsck program for ubifs yet
        ;;
+    f2fs)
+        _check_f2fs_filesystem $TEST_DEV
+        ;;
     *)
        _check_generic_filesystem $TEST_DEV
        ;;
@@ -3679,6 +3726,9 @@ _check_scratch_fs()
     ubifs)
        # there is no fsck program for ubifs yet
        ;;
+    f2fs)
+        _check_f2fs_filesystem $device
+        ;;
     *)
        _check_generic_filesystem $device
        ;;