[v2,1/4] common: Check for fiemap range argument support
diff mbox

Message ID 1509459096-7585-1-git-send-email-nborisov@suse.com
State New
Headers show

Commit Message

Nikolay Borisov Oct. 31, 2017, 2:11 p.m. UTC
Signed-off-by: Nikolay Borisov <nborisov@suse.com>
---
 common/rc | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Eryu Guan Nov. 2, 2017, 3:16 a.m. UTC | #1
On Tue, Oct 31, 2017 at 04:11:33PM +0200, Nikolay Borisov wrote:
> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
> ---
>  common/rc | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/common/rc b/common/rc
> index e2a8229..673f9ef 100644
> --- a/common/rc
> +++ b/common/rc
> @@ -2053,8 +2053,15 @@ _require_xfs_io_command()
>  			-c "$command 4k 8k" $testfile 2>&1`
>  		;;
>  	"fiemap")
> +		if [ ! -z "$param" ]
> +		then
> +			$XFS_IO_PROG -c "help fiemap" | head -n 1 | grep -q "[offset [len]]" || \
                                                                            ^^^^^^^^^^^^^^^^
this doesn't look correct to me, the "bracket expression" is a
"Character Classes", grep matches any single char in the char set. A
quick test shows it only matches the last two chars, that's "n]"

$ echo "[offset len]" | grep  "[offset [len]]"
[offset len]
          ^^ highlighted

fgrep should work, or grep -q "\[offset \[len\]\]"

But now the fiemap check in _require_xfs_io_command checks range support
on whatever $param it takes, even the '[-al] [-n nx]' param that have
nothing to do with range.

Thanks,
Eryu

> +				_notrun "xfs_io $command range param support is missing"
> +		fi
> +
>  		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
>  			-c "fiemap -v $param" $testfile 2>&1`
> +
>  		param_checked=1
>  		;;
>  	"flink" )
> -- 
> 2.7.4
> 
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Nikolay Borisov Nov. 2, 2017, 6:59 a.m. UTC | #2
On  2.11.2017 05:16, Eryu Guan wrote:
> On Tue, Oct 31, 2017 at 04:11:33PM +0200, Nikolay Borisov wrote:
>> Signed-off-by: Nikolay Borisov <nborisov@suse.com>
>> ---
>>  common/rc | 7 +++++++
>>  1 file changed, 7 insertions(+)
>>
>> diff --git a/common/rc b/common/rc
>> index e2a8229..673f9ef 100644
>> --- a/common/rc
>> +++ b/common/rc
>> @@ -2053,8 +2053,15 @@ _require_xfs_io_command()
>>  			-c "$command 4k 8k" $testfile 2>&1`
>>  		;;
>>  	"fiemap")
>> +		if [ ! -z "$param" ]
>> +		then
>> +			$XFS_IO_PROG -c "help fiemap" | head -n 1 | grep -q "[offset [len]]" || \
>                                                                             ^^^^^^^^^^^^^^^^
> this doesn't look correct to me, the "bracket expression" is a
> "Character Classes", grep matches any single char in the char set. A
> quick test shows it only matches the last two chars, that's "n]"
> 
> $ echo "[offset len]" | grep  "[offset [len]]"
> [offset len]
>           ^^ highlighted
> 
> fgrep should work, or grep -q "\[offset \[len\]\]"
> 
> But now the fiemap check in _require_xfs_io_command checks range support
> on whatever $param it takes, even the '[-al] [-n nx]' param that have
> nothing to do with range.

Fair enough, my testing shows that something like that ought to work:
grep "[[:digit:]]\+[bskmgtpe]\? [[:digit:]]\+[bskmgtpe]\?$" to match
only the last two numbers

> 
> Thanks,
> Eryu
> 
>> +				_notrun "xfs_io $command range param support is missing"
>> +		fi
>> +
>>  		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
>>  			-c "fiemap -v $param" $testfile 2>&1`
>> +
>>  		param_checked=1
>>  		;;
>>  	"flink" )
>> -- 
>> 2.7.4
>>
> 
--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Patch
diff mbox

diff --git a/common/rc b/common/rc
index e2a8229..673f9ef 100644
--- a/common/rc
+++ b/common/rc
@@ -2053,8 +2053,15 @@  _require_xfs_io_command()
 			-c "$command 4k 8k" $testfile 2>&1`
 		;;
 	"fiemap")
+		if [ ! -z "$param" ]
+		then
+			$XFS_IO_PROG -c "help fiemap" | head -n 1 | grep -q "[offset [len]]" || \
+				_notrun "xfs_io $command range param support is missing"
+		fi
+
 		testio=`$XFS_IO_PROG -F -f -c "pwrite 0 20k" -c "fsync" \
 			-c "fiemap -v $param" $testfile 2>&1`
+
 		param_checked=1
 		;;
 	"flink" )