diff mbox series

[2/2] common/rc: fix input value to _scratch_mkfs_sized

Message ID 20220627140827.23775-3-lan@suse.com (mailing list archive)
State New, archived
Headers show
Series Fix input value to _scratch_mkfs_sized | expand

Commit Message

An Long June 27, 2022, 2:08 p.m. UTC
_scratch_mkfs_sized only receive integer number of bytes as a valid
input. But if the MKFS_OPTIONS variable exists, it will use the value of
block size in MKFS_OPTIONS to override input. In case of
MKFS_OPTIONS="-b 4k", would result in blocksize=4 but not 4096. This
will give errors to ext2/3/4 etc, and brings potential bugs to xfs or
btrfs.

This patch depends on patch ("common/config: add _check_mkfs_block_options").

Signed-off-by: An Long <lan@suse.com>
---
 common/rc | 16 +---------------
 1 file changed, 1 insertion(+), 15 deletions(-)
diff mbox series

Patch

diff --git a/common/rc b/common/rc
index 3c072c16..8b8c3b51 100644
--- a/common/rc
+++ b/common/rc
@@ -1036,21 +1036,7 @@  _scratch_mkfs_sized()
 	local blocksize=$2
 	local def_blksz
 
-	case $FSTYP in
-	xfs)
-		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?size= ?+([0-9]+).*/\1/p'`
-		;;
-	btrfs)
-		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-s ?+([0-9]+).*/\1/p'`
-		;;
-	ext2|ext3|ext4|ext4dev|udf|reiser4|ocfs2|reiserfs)
-		def_blksz=`echo $MKFS_OPTIONS | sed -rn 's/.*-b ?+([0-9]+).*/\1/p'`
-		;;
-	jfs)
-		def_blksz=4096
-		;;
-	esac
-
+	[ -n "$FS_BLOCK_SIZE" ] && def_blksz=$FS_BLOCK_SIZE
 	[ -n "$def_blksz" ] && blocksize=$def_blksz
 	[ -z "$blocksize" ] && blocksize=4096