From 2fb1c931a6090f646afa44e4ce3f1f9815af9067 Mon Sep 17 00:00:00 2001 From: Eric Sandeen Date: Fri, 27 Jan 2012 12:28:20 -0600 Subject: [PATCH] 062: Sort recursive getfattr output Test 062 was made "generic" a while back, but it fails on any filesystem which returns getfattr -R results (aka readdir results) in something other than inode-order. With a little awk-fu we can sort the records from getfattr -R so that the output is the same for xfs as well as ext4, etc. Also filter out lost+found which extN creates at mkfs time, but some other filesystems do not. Signed-off-by: Eric Sandeen Reviewed-by: Christoph Hellwig --- 062 | 8 ++--- 062.out | 90 ++++++++++++++++++++++++++--------------------------- common.attr | 7 +++++ 3 files changed, 56 insertions(+), 49 deletions(-) diff --git a/062 b/062 index f666e1bc..9800e33b 100755 --- a/062 +++ b/062 @@ -67,7 +67,7 @@ _create_test_bed() mknod $SCRATCH_MNT/dev/c c 0 0 mknod $SCRATCH_MNT/dev/p p # sanity check - find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch + find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch | grep -v "lost+found" } # real QA test starts here @@ -160,18 +160,18 @@ _extend_test_bed() # whack a symlink in the middle, just to be difficult ln -s $SCRATCH_MNT/here/up $SCRATCH_MNT/descend/and # dump out our new starting point - find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch + find $SCRATCH_MNT | LC_COLLATE=POSIX sort | _filter_scratch | grep -v "lost+found" } _extend_test_bed echo echo "*** directory descent with us following symlinks" -getfattr -h -L -R -m '.' -e hex $SCRATCH_MNT +getfattr -h -L -R -m '.' -e hex $SCRATCH_MNT | _sort_getfattr_output echo echo "*** directory descent without following symlinks" -getfattr -h -P -R -m '.' -e hex $SCRATCH_MNT +getfattr -h -P -R -m '.' -e hex $SCRATCH_MNT | _sort_getfattr_output # diff --git a/062.out b/062.out index 699254a3..8cc3c655 100644 --- a/062.out +++ b/062.out @@ -508,21 +508,21 @@ SCRATCH_MNT/lnk SCRATCH_MNT/reg *** directory descent with us following symlinks -# file: SCRATCH_MNT/reg -trusted.name=0xbabe -trusted.name3=0xdeface -user.name=0xbabe -user.name3=0xdeface +# file: SCRATCH_MNT/descend +user.1=0x3233 +user.x=0x797a -# file: SCRATCH_MNT/dir -trusted.name=0xbabe -trusted.name3=0xdeface -user.name=0xbabe -user.name3=0xdeface +# file: SCRATCH_MNT/descend/and/ascend +trusted.9=0x3837 +trusted.a=0x6263 -# file: SCRATCH_MNT/lnk -trusted.name=0xbabe -trusted.name3=0xdeface +# file: SCRATCH_MNT/descend/down +user.1=0x3233 +user.x=0x797a + +# file: SCRATCH_MNT/descend/down/here +user.1=0x3233 +user.x=0x797a # file: SCRATCH_MNT/dev/b trusted.name=0xbabe @@ -536,6 +536,12 @@ trusted.name3=0xdeface trusted.name=0xbabe trusted.name3=0xdeface +# file: SCRATCH_MNT/dir +trusted.name=0xbabe +trusted.name3=0xdeface +user.name=0xbabe +user.name3=0xdeface + # file: SCRATCH_MNT/here trusted.9=0x3837 trusted.a=0x6263 @@ -548,6 +554,18 @@ trusted.a=0x6263 trusted.9=0x3837 trusted.a=0x6263 +# file: SCRATCH_MNT/lnk +trusted.name=0xbabe +trusted.name3=0xdeface + +# file: SCRATCH_MNT/reg +trusted.name=0xbabe +trusted.name3=0xdeface +user.name=0xbabe +user.name3=0xdeface + + +*** directory descent without following symlinks # file: SCRATCH_MNT/descend user.1=0x3233 user.x=0x797a @@ -560,28 +578,6 @@ user.x=0x797a user.1=0x3233 user.x=0x797a -# file: SCRATCH_MNT/descend/and/ascend -trusted.9=0x3837 -trusted.a=0x6263 - - -*** directory descent without following symlinks -# file: SCRATCH_MNT/reg -trusted.name=0xbabe -trusted.name3=0xdeface -user.name=0xbabe -user.name3=0xdeface - -# file: SCRATCH_MNT/dir -trusted.name=0xbabe -trusted.name3=0xdeface -user.name=0xbabe -user.name3=0xdeface - -# file: SCRATCH_MNT/lnk -trusted.name=0xbabe -trusted.name3=0xdeface - # file: SCRATCH_MNT/dev/b trusted.name=0xbabe trusted.name3=0xdeface @@ -594,6 +590,12 @@ trusted.name3=0xdeface trusted.name=0xbabe trusted.name3=0xdeface +# file: SCRATCH_MNT/dir +trusted.name=0xbabe +trusted.name3=0xdeface +user.name=0xbabe +user.name3=0xdeface + # file: SCRATCH_MNT/here trusted.9=0x3837 trusted.a=0x6263 @@ -606,17 +608,15 @@ trusted.a=0x6263 trusted.9=0x3837 trusted.a=0x6263 -# file: SCRATCH_MNT/descend -user.1=0x3233 -user.x=0x797a - -# file: SCRATCH_MNT/descend/down -user.1=0x3233 -user.x=0x797a +# file: SCRATCH_MNT/lnk +trusted.name=0xbabe +trusted.name3=0xdeface -# file: SCRATCH_MNT/descend/down/here -user.1=0x3233 -user.x=0x797a +# file: SCRATCH_MNT/reg +trusted.name=0xbabe +trusted.name3=0xdeface +user.name=0xbabe +user.name3=0xdeface diff --git a/common.attr b/common.attr index 37d09279..7f1ddf06 100644 --- a/common.attr +++ b/common.attr @@ -176,5 +176,12 @@ _require_attrs() rm -f $TEST_DIR/syscalltest.out } +# getfattr -R returns info in readdir order which varies from fs to fs. +# This sorts the output by filename +_sort_getfattr_output() +{ + awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS='' +} + # make sure this script returns success /bin/true -- 2.47.3