[PATCH v2 2/4] common/rc: fix _require_xfs_io_command with digits in argument

Eric Biggers
2023-11-21T22:39:36Z

'_require_xfs_io_command set_encpolicy -s' does not work as expected
because the following in the output of 'xfs_io -c "help set_encpolicy"':

-s LOG2_DUSIZE -- log2 of data unit size

... does not match the regex:

"^ -s ([a-zA-Z_]+ )?--"

... because the 2 in the argument name LOG2_DUSIZE is not matched. Fix
the regex to support digits in the argument name.

Signed-off-by: Eric Biggers <ebiggers@google.com>
---
common/rc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/common/rc b/common/rc
index cc92fe06..dab672d8 100644
--- a/common/rc
+++ b/common/rc
@@ -2719,21 +2719,21 @@ _require_xfs_io_command()
echo $testio | grep -q "foreign file active" && \
_notrun "xfs_io $command $param_checked not supported on $FSTYP"
echo $testio | grep -q "Function not implemented" && \
_notrun "xfs_io $command $param_checked support is missing (missing syscall?)"
echo $testio | grep -q "unknown flag" && \
_notrun "xfs_io $command $param_checked support is missing (unknown flag)"

[ -n "$param" ] || return

if [ -z "$param_checked" ]; then
- $XFS_IO_PROG -c "help $command" | grep -E -q "^ $param ([a-zA-Z_]+ )?--" || \
+ $XFS_IO_PROG -c "help $command" | grep -E -q "^ $param ([a-zA-Z0-9_]+ )?--" || \
_notrun "xfs_io $command doesn't support $param"
else
# xfs_io could result in "command %c not supported" if it was
# built on kernels not supporting pwritev2() calls
echo $testio | grep -q "\(invalid option\|not supported\)" && \
_notrun "xfs_io $command doesn't support $param"
fi

# On XFS, ioctl(FSSETXATTR)(called by xfs_io -c "chattr") maskes off unsupported
# or invalid flags silently so need to check these flags by extra ioctl(FSGETXATTR)
--
2.42.1