#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
+# Copyright (c) 2017 Google, Inc. All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
#-----------------------------------------------------------------------
#
-seqfull=$0
seq=`basename $0`
seqres=$RESULT_DIR/$seq
echo "QA output created by $seq"
here=`pwd`
tmp=/tmp/$$
status=1 # failure is the default!
-TARGET_DIR=
trap "_cleanup; exit \$status" 0 1 2 3 15
+file=$TEST_DIR/foo
+
_cleanup()
{
- rm -f $tmp.*
- cd $TARGET_DIR
- rm -f foo
+ rm -f $tmp.* $file
+}
+
+getfattr()
+{
+ $GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
}
-_umount_and_mount()
+setfattr()
{
- cd /
- umount $TARGET_DIR
- if [ "$FSTYP" == "xfs" ]; then
- _test_mount
- else
- _scratch_mount
- fi
-
- cd $TARGET_DIR
+ $SETFATTR_PROG "$@" |& _filter_test_dir
}
# get standard environment, filters and checks
. ./common/rc
+. ./common/attr
. ./common/filter
-# link correct .out file
-# This is done bacause udf and xfs print attrs in different orders.
-rm -rf $seqfull.out
-if [ "$FSTYP" == "xfs" ]; then
- ln -s $seq.out.xfs $seqfull.out
-else
- ln -s $seq.out.udf $seqfull.out
-fi
-
# real QA test starts here
_supported_fs generic
-_supported_os IRIX
+_supported_os Linux
_require_test
-_require_scratch
_require_attrs
-TARGET_DIR=$SCRATCH_MNT
-[ "$FSTYP" == "xfs" ] && TARGET_DIR=$TEST_DIR
-cd $TARGET_DIR
-
-echo "create file foo"
-rm -f foo
-touch foo
-
-echo "should be no EAs for foo:"
-${ATTR_PROG} -l foo
-
-echo "set EA <noise,woof>:"
-${ATTR_PROG} -s noise -V woof foo
-
-echo "set EA <colour,blue>:"
-${ATTR_PROG} -s colour -V blue foo
-
-echo "set EA <size,small>:"
-${ATTR_PROG} -s size -V small foo
-
-echo "list the EAs for foo: noise, colour, size"
-${ATTR_PROG} -l foo
+echo -e "\ncreate file foo"
+rm -f $file
+touch $file
-echo "check the list again for foo"
-${ATTR_PROG} -l foo
+echo -e "\nshould be no EAs for foo:"
+getfattr -d $file
-echo "unmount the FS and see if EAs are persistent"
-_umount_and_mount
+echo -e "\nset EA <noise,woof>:"
+setfattr -n user.noise -v woof $file
-echo "check the list again for foo after umount/mount"
-${ATTR_PROG} -l foo
+echo -e "\nset EA <colour,blue>:"
+setfattr -n user.colour -v blue $file
-echo "get the value of the noise EA"
-${ATTR_PROG} -g noise foo
+echo -e "\nset EA <size,small>:"
+setfattr -n user.size -v small $file
-echo "get the value of the colour EA which was removed earlier"
-${ATTR_PROG} -g colour foo
+echo -e "\nlist the EAs for foo: noise, colour, size"
+getfattr -d $file
-echo "get the value of the size EA"
-${ATTR_PROG} -g size foo
+echo -e "\ncheck the list again for foo"
+getfattr -d $file
-echo "remove the colour EA on foo"
-${ATTR_PROG} -r colour foo
+echo -e "\nunmount the FS and see if EAs are persistent"
+_test_cycle_mount
-echo "list EAs for foo: noise, size"
-${ATTR_PROG} -l foo
+echo -e "\ncheck the list again for foo after umount/mount"
+getfattr -d $file
-echo "get the value of the noise EA"
-${ATTR_PROG} -g noise foo
+echo -e "\nremove the colour EA on foo"
+setfattr -x user.colour $file
-echo "get the value of the colour EA which was removed earlier"
-${ATTR_PROG} -g colour foo
+echo -e "\nlist EAs for foo: noise, size"
+getfattr -d $file
-echo "get the value of the size EA"
-${ATTR_PROG} -g size foo
+echo -e "\nget the value of the noise EA"
+getfattr -n user.noise $file
-echo "list all the EAs again: noise, size"
-${ATTR_PROG} -l foo
+echo -e "\nget the value of the colour EA which was removed earlier"
+getfattr -n user.colour $file
-echo "change the value of the size EA from small to huge"
-${ATTR_PROG} -s size -V huge foo
+echo -e "\nget the value of the size EA"
+getfattr -n user.size $file
-echo "get the size EA which should now have value huge"
-${ATTR_PROG} -g size foo
+echo -e "\nlist all the EAs again: noise, size"
+getfattr -d $file
-echo "list EAs: noise, size"
-${ATTR_PROG} -l foo
+echo -e "\nchange the value of the size EA from small to huge"
+setfattr -n user.size -v huge $file
-echo "remove the size EA from foo"
-${ATTR_PROG} -r size foo
+echo -e "\nget the size EA which should now have value huge"
+getfattr -n user.size $file
-echo "list EAs: noise (size EA has been removed)"
-${ATTR_PROG} -l foo
+echo -e "\nlist EAs: noise, size"
+getfattr -d $file
-echo "get the noise EA: woof"
-${ATTR_PROG} -g noise foo
+echo -e "\nremove the size EA from foo"
+setfattr -x user.size $file
-echo "try removing non-existent EA named woof"
-${ATTR_PROG} -r woof foo
+echo -e "\nlist EAs: noise (size EA has been removed)"
+getfattr -d $file
-echo "try removing already removed EA size"
-${ATTR_PROG} -r size foo
+echo -e "\ntry removing non-existent EA named woof"
+setfattr -x user.woof $file
-echo "list EAs: noise"
-${ATTR_PROG} -l foo
+echo -e "\ntry removing already removed EA size"
+setfattr -x user.size $file
-echo "try removing already removed EA colour"
-${ATTR_PROG} -r colour foo
+echo -e "\nlist EAs: noise"
+getfattr -d $file
-echo "list EAs: noise"
-${ATTR_PROG} -l foo
+echo -e "\ntry removing already removed EA colour"
+setfattr -x user.colour $file
-echo "remove remaining EA noise"
-${ATTR_PROG} -r noise foo
+echo -e "\nlist EAs: noise"
+getfattr -d $file
-echo "list EAs: should be no EAs left now"
-${ATTR_PROG} -l foo
+echo -e "\nremove remaining EA noise"
+setfattr -x user.noise $file
-echo "unmount the FS and see if EAs are persistent"
-_umount_and_mount
+echo -e "\nlist EAs: should be no EAs left now"
+getfattr -d $file
-echo "list EAs: should still be no EAs left"
-${ATTR_PROG} -l foo
+echo -e "\nunmount the FS and see if EAs are persistent"
+_test_cycle_mount
-echo ""
-echo "*** Test out the root namespace ***"
-echo ""
+echo -e "\nlist EAs: should still be no EAs left"
+getfattr -d $file
-echo "set EA <root:colour,marone>:"
-${ATTR_PROG} -R -s colour -V marone foo
+echo -e "\n*** Test out the trusted namespace ***"
-echo "set EA <user:colour,beige>:"
-${ATTR_PROG} -s colour -V beige foo
+echo -e "\nset EA <trusted:colour,marone>:"
+setfattr -n trusted.colour -v marone $file
-echo "set EA <user:vomit,pizza>:"
-${ATTR_PROG} -s vomit -V pizza foo
+echo -e "\nset EA <user:colour,beige>:"
+setfattr -n user.colour -v beige $file
-echo "set EA <root:noise,whack>:"
-${ATTR_PROG} -R -s noise -V whack foo
+echo -e "\nset EA <user:vomit,pizza>:"
+setfattr -n user.vomit -v pizza $file
-echo "list root EAs: <root:colour,noise>:"
-${ATTR_PROG} -R -l foo
+echo -e "\nset EA <trusted:noise,whack>:"
+setfattr -n trusted.noise -v whack $file
-echo "list user EAs: <user:colour,vomit>:"
-${ATTR_PROG} -l foo
+echo -e "\nlist trusted EAs: <trusted:colour,noise>:"
+getfattr -d -m '^trusted\.' $file
-echo "get root EA colour: marone"
-${ATTR_PROG} -R -g colour foo
+echo -e "\nlist user EAs: <user:colour,vomit>:"
+getfattr -d $file
-echo "get root EA noise: whack"
-${ATTR_PROG} -R -g noise foo
+echo -e "\nget trusted EA colour: marone"
+getfattr -n trusted.colour $file
-echo "get root EA vomit which is a user EA => find nothing"
-${ATTR_PROG} -R -g vomit foo
+echo -e "\nget trusted EA noise: whack"
+getfattr -n trusted.noise $file
-echo ""
-echo "unmount the FS and see if EAs are persistent"
-echo ""
-_umount_and_mount
+echo -e "\nget trusted EA vomit which is a user EA => find nothing"
+getfattr -n trusted.vomit $file
-echo "get root EA colour: marone"
-${ATTR_PROG} -R -g colour foo
+echo -e "\nunmount the FS and see if EAs are persistent"
+_test_cycle_mount
-echo "get root EA noise: whack"
-${ATTR_PROG} -R -g noise foo
+echo -e "\nget trusted EA colour: marone"
+getfattr -n trusted.colour $file
-echo "get user EA vomit: pizza"
-${ATTR_PROG} -g vomit foo
+echo -e "\nget trusted EA noise: whack"
+getfattr -n trusted.noise $file
-echo "remove the root colour EA"
-${ATTR_PROG} -R -r colour foo
+echo -e "\nget user EA vomit: pizza"
+getfattr -n user.vomit $file
-echo "list root EAs: <root:noise>:"
-${ATTR_PROG} -R -l foo
+echo -e "\nremove the trusted colour EA"
+setfattr -x trusted.colour $file
-echo "list user EAs: <user:colour,vomit>:"
-${ATTR_PROG} -l foo
+echo -e "\nlist trusted EAs: <trusted:noise>:"
+getfattr -d -m '^trusted\.' $file
-echo "remove the final root EA noise"
-${ATTR_PROG} -R -r noise foo
+echo -e "\nlist user EAs: <user:colour,vomit>:"
+getfattr -d $file
-echo "list root EAs: none"
-${ATTR_PROG} -R -l foo
+echo -e "\nremove the final trusted EA noise"
+setfattr -x trusted.noise $file
-cd /
+echo -e "\nlist trusted EAs: none"
+getfattr -d -m '^trusted\.' $file
# success, all done
status=0