Skip to contentSkip to conversation

common/xfs: use whole-word matching for _require_xfsrestore_xflag

PATCH In review Darrick J. Wong 2 participants 2 messages Feb 7, 2023 – Feb 9, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 common/xfs: use whole-word matching for _require_xfsrestore_xflag

From: Darrick J. Wong <[email protected]>

On my system, the path to the xfsrestore binary is:

/code/xfsdump/build-x86_64/restore/xfsrestore

The grep command in _require_xfsrestore_xflag matches on the "build-x86" part, even though my version of xfsrestore does not actually have a -x flag. Fix the string parsing to match entire words so that we only look for -x in the help output.

(Maybe someone should patch xfsrestore -h to report basename(argv[0]) instead of argv[0]...)

Fixes 1ffa16c573 ("xfs: test for fixing wrong root inode number in dump")
---
 common/xfs |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/xfs +1 -1
index ba59889c3b..97c049e2ca 100644
@@ -1529,7 +1529,7 @@ _xfs_filter_mkfs()
 
 _require_xfsrestore_xflag()
 {
-	$XFSRESTORE_PROG -h 2>&1 | grep -q -e '-x' || \
+	$XFSRESTORE_PROG -h 2>&1 | grep -q -w -e '-x' || \
 			_notrun 'xfsrestore does not support -x flag.'
 }
 
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Darrick J. Wong

From: Darrick J. Wong <[email protected]>

On my system, the path to the xfsrestore binary is:

/code/xfsdump/build-x86_64/restore/xfsrestore

The grep command in _require_xfsrestore_xflag matches on the "build-x86" part, even though my version of xfsrestore does not actually have a -x flag. Fix the string parsing to match entire words so that we only look for -x in the help output.

Quoted 6 lines

(Maybe someone should patch xfsrestore -h to report basename(argv[0]) instead of argv[0]...)

Fixes 1ffa16c573 ("xfs: test for fixing wrong root inode number in dump")

---

Good to me,

Quoted 17 lines
 common/xfs |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
common/xfs +1 -1
index ba59889c3b..97c049e2ca 100644
@@ -1529,7 +1529,7 @@ _xfs_filter_mkfs()
 
 _require_xfsrestore_xflag()
 {
-	$XFSRESTORE_PROG -h 2>&1 | grep -q -e '-x' || \
+	$XFSRESTORE_PROG -h 2>&1 | grep -q -w -e '-x' || \
 			_notrun 'xfsrestore does not support -x flag.'
 }