Skip to contentSkip to conversation

_scratch_mkfs_geom(): Filter out 'k' suffix from fs block size

PATCH In review Chandan Babu R 2 participants 2 messages Feb 9, 2021

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 _scratch_mkfs_geom(): Filter out 'k' suffix from fs block size

If the original value of $MKFS_OPTIONS contained a block size value having 'k' as a suffix (e.g. -b size=4k), then the newly constructed value of $MKFS_OPTIONS will have 'k' suffixed to the value of $blocksize. $blocksize itself is specified in units of bytes. Hence having 'k' suffixed to this value will result in an incorrect block size.

This commit fixes the bug by conditionally filtering out the 'k' suffix from block size option present in the original value of $MKFS_OPTIONS.

---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/rc +1 -1
index 649b1cfd..0ec7fe1a 100644
@@ -1062,7 +1062,7 @@ _scratch_mkfs_geom()
     case $FSTYP in
     xfs)
 	if echo "$MKFS_OPTIONS" | egrep -q "b?size="; then
-		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b?size=)[0-9]+/\1$blocksize/")
+		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b?size=)[0-9]+k?/\1$blocksize/")
 	else
 		MKFS_OPTIONS+=" -b size=$blocksize"
 	fi
Signature · 1 line
2.29.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 19 lines · Chandan Babu R

If the original value of $MKFS_OPTIONS contained a block size value having 'k' as a suffix (e.g. -b size=4k), then the newly constructed value of $MKFS_OPTIONS will have 'k' suffixed to the value of $blocksize. $blocksize itself is specified in units of bytes. Hence having 'k' suffixed to this value will result in an incorrect block size.

This commit fixes the bug by conditionally filtering out the 'k' suffix from block size option present in the original value of $MKFS_OPTIONS.

---
 common/rc | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/rc +0 -0
index 649b1cfd..0ec7fe1a 100644

common/rc _scratch_mkfs_geom() · line 1065

Quoted 5 lines
common/rc +1 -1
@@ -1062,7 +1062,7 @@ _scratch_mkfs_geom()
     case $FSTYP in
     xfs)
 	if echo "$MKFS_OPTIONS" | egrep -q "b?size="; then
-		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b?size=)[0-9]+/\1$blocksize/")
+		MKFS_OPTIONS=$(echo "$MKFS_OPTIONS" | sed -r "s/(b?size=)[0-9]+k?/\1$blocksize/")

At first I wondered about the other suffixes but then realized that 's' doesn't actually work, so...

--D

Quoted 6 lines
common/rc +0 -0
 	else
 		MKFS_OPTIONS+=" -b size=$blocksize"
 	fi
Signature · 1 line
2.29.2