Add xfsdump support for the security extended attributes namespace.
[xfstests-dev.git] / 062
diff --git a/062 b/062
index e6dbfc809f6b0ed4726c15a1c5ca7decb95c6856..63014d37701e1df0e8ef3907320f3430fec51fda 100755 (executable)
--- a/062
+++ b/062
@@ -1,12 +1,11 @@
 #! /bin/sh
 # XFS QA Test No. 062
-# $Id: 1.1 $
 #
 # Exercises the getfattr/setfattr tools
 # Derived from tests originally written by Andreas Gruenbacher for ext2
 #
 #-----------------------------------------------------------------------
-# Copyright (c) 2001 Silicon Graphics, Inc.  All Rights Reserved.
+# Copyright (c) 2001-2002 Silicon Graphics, Inc.  All Rights Reserved.
 # 
 # This program is free software; you can redistribute it and/or modify it
 # under the terms of version 2 of the GNU General Public License as
@@ -66,7 +65,7 @@ _filter_scratch()
 
 getfattr()
 {
-       /usr/bin/getfattr -adl $@ 2>&1 | _filter_scratch
+       /usr/bin/getfattr --absolute-names -dh $@ 2>&1 | _filter_scratch
 }
 
 setfattr()
@@ -92,52 +91,57 @@ _require_scratch
 rm -f $tmp.backup1 $tmp.backup2 $seq.full
 
 # real QA test starts here
-mkfs_xfs -f $SCRATCH_DEV | _filter_mkfs 2>$tmp.mkfs
-mount -t xfs $SCRATCH_DEV $SCRATCH_MNT || _fail "mount failed"
+_scratch_mkfs_xfs | _filter_mkfs 2>$tmp.mkfs
+_scratch_mount || _fail "mount failed"
 _create_test_bed
 
-for nsp in user xfsroot; do
+if [ "$USE_ATTR_SECURE" = yes ]; then
+    ATTR_MODES="user security trusted"
+else
+    ATTR_MODES="user trusted"
+fi
+for nsp in $ATTR_MODES; do
        for inode in reg dir lnk dev/b dev/c dev/p; do
 
                echo; echo "=== TYPE $inode; NAMESPACE $nsp"; echo
 
                echo "*** set/get one initially empty attribute"
-               setfattr -l -n $nsp.name $SCRATCH_MNT/$inode
-               getfattr -r $nsp $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name $SCRATCH_MNT/$inode
+               getfattr -m $nsp $SCRATCH_MNT/$inode
 
                echo "*** overwrite empty, set several new attributes"
-               setfattr -l -n $nsp.name -v 0xbabe $SCRATCH_MNT/$inode
-               setfattr -l -n $nsp.name2 -v 0xdeadbeef $SCRATCH_MNT/$inode
-               setfattr -l -n $nsp.name3 -v 0xdeface $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name -v 0xbabe $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name2 -v 0xdeadbeef $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name3 -v 0xdeface $SCRATCH_MNT/$inode
 
                echo "*** fetch several attribute names and values (hex)"
-               getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e hex $SCRATCH_MNT/$inode
 
                echo "*** fetch several attribute names and values (base64)"
-               getfattr -r $nsp -e base64 $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e base64 $SCRATCH_MNT/$inode
 
                echo "*** shrink value of an existing attribute"
-               setfattr -l -n $nsp.name2 -v 0xdeaf $SCRATCH_MNT/$inode
-               getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name2 -v 0xdeaf $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e hex $SCRATCH_MNT/$inode
 
                echo "*** grow value of existing attribute"
-               setfattr -l -n $nsp.name2 -v 0xdecade $SCRATCH_MNT/$inode
-               getfattr -r $nsp -e hex $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name2 -v 0xdecade $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e hex $SCRATCH_MNT/$inode
 
                echo "*** set an empty value for second attribute"
-               setfattr -l -n $nsp.name2 $SCRATCH_MNT/$inode
-               getfattr -r $nsp -n $nsp.name2 $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name2 $SCRATCH_MNT/$inode
+               getfattr -m $nsp -n $nsp.name2 $SCRATCH_MNT/$inode
 
                echo "*** overwrite empty value"
-               setfattr -l -n $nsp.name2 -v 0xcafe $SCRATCH_MNT/$inode
-               getfattr -r $nsp -e hex -n $nsp.name2 $SCRATCH_MNT/$inode
+               setfattr -h -n $nsp.name2 -v 0xcafe $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e hex -n $nsp.name2 $SCRATCH_MNT/$inode
 
                echo "*** remove attribute"
-               setfattr -l -x $nsp.name2 $SCRATCH_MNT/$inode
-               getfattr -r $nsp -e text -n $nsp.name2 $SCRATCH_MNT/$inode
+               setfattr -h -x $nsp.name2 $SCRATCH_MNT/$inode
+               getfattr -m $nsp -e hex -n $nsp.name2 $SCRATCH_MNT/$inode
 
                echo "*** final list (strings, type=$inode, nsp=$nsp)"
-               getfattr -r '^user|^xfsroot' -e text $SCRATCH_MNT/$inode
+               getfattr -m '.' -e hex $SCRATCH_MNT/$inode
        done
 done
 
@@ -155,8 +159,8 @@ _extend_test_bed()
        mkdir -p $SCRATCH_MNT/descend/down/here
        find $SCRATCH_MNT/descend | xargs setfattr -n user.x -v yz
        find $SCRATCH_MNT/descend | xargs setfattr -n user.1 -v 23
-       find $SCRATCH_MNT/here | xargs setfattr -n xfsroot.a -v bc
-       find $SCRATCH_MNT/here | xargs setfattr -n xfsroot.9 -v 87
+       find $SCRATCH_MNT/here | xargs setfattr -n trusted.a -v bc
+       find $SCRATCH_MNT/here | xargs setfattr -n trusted.9 -v 87
        # 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
@@ -166,20 +170,12 @@ _extend_test_bed()
 _extend_test_bed
 
 echo
-echo "*** forward directory descent with us following symlinks"
-getfattr -L -R -r '^user|^xfsroot' -e hex $SCRATCH_MNT
-
-echo
-echo "*** reverse directory descent with us following symlinks"
-getfattr -L -R -5 -r '^user|^xfsroot' -e hex $SCRATCH_MNT
-
-echo
-echo "*** forward directory descent without following symlinks"
-getfattr -P -R -r '^user|^xfsroot' -e hex $SCRATCH_MNT
+echo "*** directory descent with us following symlinks"
+getfattr -h -L -R -m '.' -e hex $SCRATCH_MNT
 
 echo
-echo "*** reverse directory descent without following symlinks"
-getfattr -P -R -5 -r '^user|^xfsroot' -e hex $SCRATCH_MNT
+echo "*** directory descent without following symlinks"
+getfattr -h -P -R -m '.' -e hex $SCRATCH_MNT
 
 
 # 
@@ -190,7 +186,7 @@ echo; echo
 _backup()
 {
        # NB: no filtering of scratch here... (need to restore too)
-       /usr/bin/getfattr -adl -R -r '^user|^system' $SCRATCH_MNT >$1
+       /usr/bin/getfattr --absolute-names -dh -R -m '.' $SCRATCH_MNT >$1
        echo BACKUP $1 >>$seq.full
        cat $1 >> $seq.full
        [ ! -s $1 ] && echo "warning: $1 (backup file) is empty"
@@ -202,18 +198,18 @@ _backup $tmp.backup1
 echo "*** clear out the scratch device"
 rm -fr $SCRATCH_MNT/*
 echo "AFTER REMOVE" >>$seq.full
-getfattr -L -R -r '^user|^xfsroot' $SCRATCH_MNT >>$seq.full
+getfattr -L -R -m '.' $SCRATCH_MNT >>$seq.full
 
 echo "*** reset test bed with no extended attributes"
 _create_test_bed
 _extend_test_bed
 
 echo "*** restore everything"
-setfattr -lB $tmp.backup1
+setfattr -h --restore=$tmp.backup1
 _backup $tmp.backup2
 
 echo "AFTER RESTORE" >>$seq.full
-getfattr -L -R -r '^user|^xfsroot' $SCRATCH_MNT >>$seq.full
+getfattr -L -R -m '.' $SCRATCH_MNT >>$seq.full
 
 echo "*** compare before and after backups"
 diff $tmp.backup1 $tmp.backup2