Skip to contentSkip to conversation

generic/740: set env for mkfs.exfat and mkfs.ntfs

PATCH In review David Timber 2 participants 2 messages Jun 16 – Jun 17

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 generic/740: set env for mkfs.exfat and mkfs.ntfs

Foreign filesystem detection is added in exfatprogs version 1.4.1. To maintain backward compatibility, mkfs.exfat refuses to format the device only when it's run from terminal with a tty associated to it.

This is similar to how e2fsprogs work around the issue. However, with exfatprogs, this behaviour can be overridden with the special environment variable EXFAT_TTY_OVERRIDE to simulate shell invocation by user.

mkfs.ntfs from NTFS-3G userland package refuses to format the target if it's backed by a "real" device but not a partition to maintain compatibility with Windows. When formatting the scratch device in NTFS for testing, this behaviour has to be overridden so that any type of blockdev can be used as a scratch device.

---
 tests/generic/740 | 22 +++++++++++++++++++---
 1 file changed, 19 insertions(+), 3 deletions(-)
tests/generic/740 +19 -3
index ce55200f..89822480 100755
@@ -28,6 +28,20 @@ _require_block_device "${SCRATCH_DEV}"
 # not all the FS support zoned block device
 _require_non_zoned_device "${SCRATCH_DEV}"
 
+mkfs_preop=""
+mkfs_preargs=""
+mkfs_postargs=""
+
+case "$FSTYP" in
+	exfat)
+		# Some fsprogs were slow to implement foreign fs detection.
+		# For backward compatibility, mkfs.exfat refuses to format only
+		# when run from a tty. This env var should override the
+		# behaviour if supported.
+		mkfs_preop="EXFAT_TTY_OVERRIDE=1"
+		;;
+esac
+
 echo "Silence is golden."
 for fs in `echo ${MKFS_PROG}.* | sed -e "s:${MKFS_PROG}.::g"`
 do
@@ -60,8 +74,10 @@ do
 		postargs=2000
 		;;
 	ntfs)
-		# "quick" format that doesn't zero the entire device
-		postargs="--quick"
+		# "quick" format that doesn't zero the entire device. Use -F so
+		# that NTFS-3G mkfs formats the volume even if the scratch
+		# blockdev is not a partition.
+		postargs="-QF"
 		;;
 	reiser4)
 		preop="echo y |"
@@ -83,7 +99,7 @@ do
 		# next, ensure we don't overwrite it
 
 		echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
-		${MKFS_PROG} -t $FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
+		eval $mkfs_preop ${MKFS_PROG} -t $FSTYP $mkfs_preargs $SCRATCH_DEV $mkfs_postargs >>$seqres.full 2>&1
 
 		[ $? -eq 0 ] && echo "Failed - overwrote fs type ${fs}!"
 	else
Signature · 1 line
2.54.0
#1 lore raw

tests/generic/740 _require_block_device "${SCRATCH_DEV}" · line 36

Quoted 2 lines · David Timber
tests/generic/740 +2 -0
+case "$FSTYP" in
+	exfat)

Please don't indent the matches in case statements (yes, we probably have a few legacy cases that do it, but copy the right ones :))

tests/generic/740 _require_block_device "${SCRATCH_DEV}" · line 40

Quoted 4 lines
tests/generic/740 +4 -0
+		# Some fsprogs were slow to implement foreign fs detection.
+		# For backward compatibility, mkfs.exfat refuses to format only
+		# when run from a tty. This env var should override the
+		# behaviour if supported.

I don't get the 'Some fsprogs' part here. Maybe just drop that line?

tests/generic/740 do · line 80

Quoted 7 lines
tests/generic/740 +4 -2
 	ntfs)
-		# "quick" format that doesn't zero the entire device
-		postargs="--quick"
+		# "quick" format that doesn't zero the entire device. Use -F so
+		# that NTFS-3G mkfs formats the volume even if the scratch
+		# blockdev is not a partition.
+		postargs="-QF"

Why does this switch from the long to the short form quick argument?

tests/generic/740 do · line 102

Quoted 3 lines
tests/generic/740 +1 -1
 		echo "=== Attempting $FSTYP overwrite of $fs..." >>$seqres.full
-		${MKFS_PROG} -t $FSTYP $SCRATCH_DEV >>$seqres.full 2>&1
+		eval $mkfs_preop ${MKFS_PROG} -t $FSTYP $mkfs_preargs $SCRATCH_DEV $mkfs_postargs >>$seqres.full 2>&1

Maybe add a line break to keep the line at a reasonable length.

Also in doubt split the exfat and ntfs changes as they seem entirely unrelated.