diff mbox

stat_test: Fix stx_attributes check

Message ID 1495317973-24072-1-git-send-email-richard@nod.at (mailing list archive)
State New, archived
Headers show

Commit Message

Richard Weinberger May 20, 2017, 10:06 p.m. UTC
I found that this test succeeds on UBIFS:
stat_test /mnt/foo attr=+compressed attr=-compressed

Since stx_attributes can hold many flags, check the flags
correctly with the & operator.

Signed-off-by: Richard Weinberger <richard@nod.at>
---
 src/stat_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Darrick J. Wong May 23, 2017, 3:18 a.m. UTC | #1
On Sun, May 21, 2017 at 12:06:13AM +0200, Richard Weinberger wrote:
> I found that this test succeeds on UBIFS:
> stat_test /mnt/foo attr=+compressed attr=-compressed
> 
> Since stx_attributes can hold many flags, check the flags
> correctly with the & operator.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>

Looks ok to /me/...
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>

--D

> ---
>  src/stat_test.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/src/stat_test.c b/src/stat_test.c
> index 3dc44bbdb71d..fc87ed5c6e8f 100644
> --- a/src/stat_test.c
> +++ b/src/stat_test.c
> @@ -621,10 +621,10 @@ static void check_attribute(const struct statx *stx, char *arg)
>  
>  	attr = p->attr_flag;
>  	if (set) {
> -		check(stx->stx_attributes && attr,
> +		check((stx->stx_attributes & attr) == attr,
>  		      "Attribute %s should be set\n", arg);
>  	} else {
> -		check(~stx->stx_attributes && attr,
> +		check((stx->stx_attributes & attr) == 0,
>  		      "Attribute %s should be unset\n", arg);
>  	}
>  }
> -- 
> 2.7.3
> 
--
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
diff mbox

Patch

diff --git a/src/stat_test.c b/src/stat_test.c
index 3dc44bbdb71d..fc87ed5c6e8f 100644
--- a/src/stat_test.c
+++ b/src/stat_test.c
@@ -621,10 +621,10 @@  static void check_attribute(const struct statx *stx, char *arg)
 
 	attr = p->attr_flag;
 	if (set) {
-		check(stx->stx_attributes && attr,
+		check((stx->stx_attributes & attr) == attr,
 		      "Attribute %s should be set\n", arg);
 	} else {
-		check(~stx->stx_attributes && attr,
+		check((stx->stx_attributes & attr) == 0,
 		      "Attribute %s should be unset\n", arg);
 	}
 }