Skip to contentSkip to conversation

fstests: Fix checking of UDF filesystems

PATCH Superseded Jan Kara 2 participants 5 messages Jan 20, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Jan Kara

author
#0 lore raw

v2 cover fstests: Fix checking of UDF filesystems

Hello,

these two patches fix the usage of udf_test program in _check_udf_filesystem so that it can reliably check udf filesystems. It provides it proper arguments and also unmounts the filesystem prior to running the check.

Changes since v1:
* Added Reviewed-by tag
* Accept also --blocksize version of the option

Honza
Previous versions:

author
#1 lore raw

PATCH v2 1/2 common: Provide blocksize and ecclength to udf fsck

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +6 -2
index 8060c03b7d18..bf3effa4c1ed 100644
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'`
+    if [ -z "$blksz" ]; then
+	blksz=512
+    fi
+    local opt_arg="-ecclength 1 -blocksize $blksz"
     if [ $# -eq 2 ]; then
-	opt_arg="-lastvalidblock $(( $2 - 1 ))"
+	opt_arg+=" -lastvalidblock $(( $2 - 1 ))"
     fi
 
     rm -f $seqres.checkfs
Signature · 1 line
2.35.3
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] common: Provide blocksize and ecclength to udf fsck

Quoted 19 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +1 -1
index 8060c03b7d18..bf3effa4c1ed 100644
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'`

common/rc _check_udf_filesystem() · line 3087

Quoted 10 lines
common/rc +5 -1
+    if [ -z "$blksz" ]; then
+	blksz=512
+    fi
+    local opt_arg="-ecclength 1 -blocksize $blksz"
     if [ $# -eq 2 ]; then
-	opt_arg="-lastvalidblock $(( $2 - 1 ))"
+	opt_arg+=" -lastvalidblock $(( $2 - 1 ))"
     fi
 
     rm -f $seqres.checkfs

Looks fine - I suppose it's safe to assume the --media-type=hd default blksz value.

author
#3 lore raw

Re: [PATCH v2 1/2] common: Provide blocksize and ecclength to udf fsck

Quoted 30 lines · David Disseldorp
Quoted 28 lines · Jan Kara

udf_test program used for verifying filesystem is not able to determine filesystem blocksize. Provide it in the options together with disabling ecclength as it is not used on harddrives.

---
 common/rc | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
common/rc +6 -2
index 8060c03b7d18..bf3effa4c1ed 100644
@@ -3075,9 +3075,13 @@ _check_udf_filesystem()
     fi
 
     local device=$1
-    local opt_arg=""
+    local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'`
+    if [ -z "$blksz" ]; then
+	blksz=512
+    fi
+    local opt_arg="-ecclength 1 -blocksize $blksz"
     if [ $# -eq 2 ]; then
-	opt_arg="-lastvalidblock $(( $2 - 1 ))"
+	opt_arg+=" -lastvalidblock $(( $2 - 1 ))"
     fi
 
Quoted 5 lines

common/rc _check_udf_filesystem() · line 3087

Quoted 1 line
common/rc +0 -0
     rm -f $seqres.checkfs

Looks fine - I suppose it's safe to assume the --media-type=hd default blksz value.

Thanks for review! Yeah, I didn't really find a value in trying to handle anything else. If a real usecase comes, we can always tweak this.

Honza

Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR
author
#4 lore raw

PATCH v2 2/2 common: Unmount udf filesystem prior checking

In reply to Jan Kara

_check_udf_filesystem forgot to unmount the filesystem prior to checking it. That was leading to check failures.

---
 common/rc | 10 ++++++++++
 1 file changed, 10 insertions(+)
common/rc +10 -0
index bf3effa4c1ed..7f80afe7aeec 100644
@@ -3074,6 +3074,12 @@ _check_udf_filesystem()
 	return
     fi
 
+    # Is the filesystem mounted?
+    local type=`_fs_type $device`
+    if [ "$type" = "$FSTYP" ]; then
+	local mountpoint=`_umount_or_remount_ro $device`
+    fi
+
     local device=$1
     local blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*(-b|--blocksize)[ =]?+([0-9]+).*/\2/p'`
     if [ -z "$blksz" ]; then
@@ -3090,6 +3096,10 @@ _check_udf_filesystem()
 	_udf_test_known_error_filter | \
 	grep -E -iv "Error count:.*[0-9]+.*total occurrences:.*[0-9]+|Warning count:.*[0-9]+.*total occurrences:.*[0-9]+" && \
         echo "Warning UDF Verifier reported errors see $seqres.checkfs." && return 1
+    # Remount the filesystem
+    if [ "$type" = "$FSTYP" ]; then
+	_mount_or_remount_rw "$MOUNT_OPTIONS" $device $mountpoint
+    fi
     return 0
 }
 
Signature · 1 line
2.35.3