awk '{a[FNR]=$0}END{n = asort(a); for(i=1; i <= n; i++) print a[i]"\n"}' RS=''
}
+# Previously, when getfattr dumps values of all extended attributes, it prints
+# empty attr as 'user.name', but new getfattr (since attr-2.4.48) prints it as
+# 'user.name=""'. Filter out the ending '=""' so that both old and new getfattr
+# pints the same output.
+#
+# Note: This function returns the getfattr command result.
+_getfattr()
+{
+ $GETFATTR_PROG "$@" | sed -e 's/=\"\"//'
+ return ${PIPESTATUS[0]}
+}
+
# set maximum total attr space based on fs type
case "$FSTYP" in
xfs|udf|pvfs2|9p|ceph)
# Dump all xattrs to see whether nothing broke
for FILE in ${FNAMES[@]}; do
- $GETFATTR_PROG -h -d --absolute-names $SCRATCH_MNT/$FILE 2>/dev/null | \
+ _getfattr -h -d --absolute-names $SCRATCH_MNT/$FILE 2>/dev/null | \
_filter_scratch | sort
done
$SETFATTR_PROG -n $name $file
fi
- tmp=$($GETFATTR_PROG --absolute-names --only-values -n $name $file)
+ tmp=$(_getfattr --absolute-names --only-values -n $name $file)
[[ "$tmp" == "$value" ]] || echo "unexpected value returned: $tmp"
}
# List attributes on a file.
attr_list()
{
- $GETFATTR_PROG --absolute-names $1 | grep -v '^#'
+ _getfattr --absolute-names $1 | grep -v '^#'
}
# Removes an extended attribute from a file.
return $exit
}
-_getfattr()
+do_getfattr()
{
- $GETFATTR_PROG $* 2>$tmp.err >$tmp.out
+ _getfattr $* 2>$tmp.err >$tmp.out
exit=$?
_filter $tmp.out
_filter $tmp.err 1>&2
file=$1
echo " *** print attributes"
- if ! _getfattr -d -e text --absolute-names $file
+ if ! do_getfattr -d -e text --absolute-names $file
then
echo " !!! error return"
return 1
echo "*** check"
# don't print it all out...
-getfattr --absolute-names $testfile \
+_getfattr --absolute-names $testfile \
| tee -a $seqres.full \
| $AWK_PROG '
/^#/ { next }
setter_pid=$!
for ((i = 0; i < 1000; i++)); do
- $GETFATTR_PROG --absolute-names -n $xattr_name \
+ _getfattr --absolute-names -n $xattr_name \
$SCRATCH_MNT/$test_file | value_filter
done
getfattr()
{
- $GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch
+ _getfattr --absolute-names -dh $@ 2>&1 | _filter_scratch
}
setfattr()
# we *do* sort the output by path, since it otherwise would depend on
# readdir order, which on some filesystems may change after re-creating
# the files.
- $GETFATTR_PROG --absolute-names -dh -R -m '.' $SCRATCH_MNT | _sort_getfattr_output >$1
+ _getfattr --absolute-names -dh -R -m '.' $SCRATCH_MNT | _sort_getfattr_output >$1
echo BACKUP $1 >>$seqres.full
cat $1 >> $seqres.full
[ ! -s $1 ] && echo "warning: $1 (backup file) is empty"
# with the 3 xattrs that we had before deleting the second one and fsyncing the
# file.
echo "xattr names and values after first fsync log replay:"
-$GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
+_getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
# Now write some data to our file, fsync it, remove the first xattr, add a new
# hard link to our file and commit the fsync log by fsyncing some other new
# Now only the xattr with name user.attr3 should be set in our file.
echo "xattr names and values after second fsync log replay:"
-$GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
+_getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
status=0
exit
$SETFATTR_PROG -n trusted.name -v value $file
echo data2 >> $file
cat $file
-$GETFATTR_PROG -m '^trusted\.*' --absolute-names $file | filefilter
+_getfattr -m '^trusted\.*' --absolute-names $file | filefilter
echo "**** Verifying that chmod doesn't affect open file descriptors ****"
rm -f $file
getfattr()
{
- $GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
+ _getfattr --absolute-names "$@" |& _filter_test_dir
}
setfattr()
# Now call getfattr with --dump, which calls the listxattrs system call.
# It should list all the xattrs we have set before.
-$GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
+_getfattr --absolute-names --dump $SCRATCH_MNT/testfile | _filter_scratch
status=0
exit
# get standard environment, filters and checks
. ./common/rc
+. ./common/attr
# remove previous $seqres.full before test
rm -f $seqres.full
mkdir sub
$SETRICHACL_PROG --set 'everyone@:rwpxd:fd:allow' sub
stat -c %A+ sub
-$GETFATTR_PROG -m system\.richacl sub
+_getfattr -m system\.richacl sub
chmod 775 sub
stat -c %A+ sub
-$GETFATTR_PROG -m system\.richacl sub
+_getfattr -m system\.richacl sub
$GETRICHACL_PROG sub
touch sub/f
runfile="$tmp.getfattr"
touch $runfile
while [ -e $runfile ]; do
- $GETFATTR_PROG --absolute-names -n trusted.small $SCRATCH_MNT/file \
+ _getfattr --absolute-names -n trusted.small $SCRATCH_MNT/file \
> /dev/null || break
done &
getfattr_pid=$!
echo "Testing ${key} ($(hexbytes "${key}")) -> ${value}" >> $seqres.full
- actual_value="$($GETFATTR_PROG --absolute-names --only-values -n "user.${key}" "${testfile}")"
+ actual_value="$(_getfattr --absolute-names --only-values -n "user.${key}" "${testfile}")"
if [ "${actual_value}" != "${value}" ]; then
echo "Key ${key} has value ${actual_value}, expected ${value}."
fi
setf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
setf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
-$GETFATTR_PROG --absolute-names -d "${testfile}" >> $seqres.full
+_getfattr --absolute-names -d "${testfile}" >> $seqres.full
echo "Test files"
testf "french_caf\xc3\xa9.txt" "NFC"
testf "combmark_\xe1\x80\x9c\xe1\x80\xaf\xe1\x80\xad.txt" "combining marks"
echo "Uniqueness of keys?"
-crazy_keys="$($GETFATTR_PROG --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
+crazy_keys="$(_getfattr --absolute-names -d "${testfile}" | egrep -c '(french_|chinese_|greek_|arabic_|urk)')"
expected_keys=11
test "${crazy_keys}" -ne "${expected_keys}" && echo "Expected ${expected_keys} keys, saw ${crazy_keys}."
# were not lost and neither was the data we wrote.
_flakey_drop_and_remount
echo "File xattrs after power failure:"
-$GETFATTR_PROG --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
+_getfattr --absolute-names --dump $SCRATCH_MNT/foobar | _filter_scratch
echo "File data after power failure:"
od -t x1 $SCRATCH_MNT/foobar
$MOUNT_PROG -t overlay -o ro -o lowerdir=$upperdir:$lowerdir $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
# Dump trusted.overlay xattr, we should not see the "opaque" xattr
-$GETFATTR_PROG -d -m overlay $SCRATCH_MNT/testdir
+_getfattr -d -m overlay $SCRATCH_MNT/testdir
echo "Silence is golden"
# success, all done
$SETFATTR_PROG -n "trusted.overlayfsrz" -v "n" \
$SCRATCH_MNT/testf0 2>&1 | _filter_scratch
-$GETFATTR_PROG --absolute-names -n "trusted.overlayfsrz" \
+_getfattr --absolute-names -n "trusted.overlayfsrz" \
$SCRATCH_MNT/testf0 2>&1 | _filter_scratch
# {s,g}etfattr of "trusted.overlay.xxx" should fail.
$SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
sed -e 's/permitted/supported/g'
-$GETFATTR_PROG --absolute-names -n "trusted.overlay.fsz" \
+_getfattr --absolute-names -n "trusted.overlay.fsz" \
$SCRATCH_MNT/testf1 2>&1 | _filter_scratch | \
sed -e 's/permitted/supported/g'
mv $SCRATCH_MNT/test_file $impure_dir
test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
-impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
$upperdir/test_dir/impure_dir)
[[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
$here/src/t_dir_type $impure_dir $impure_subdir_st_ino
[[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
-impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
$upperdir/test_dir/impure_dir 2>/dev/null)
[[ -z $impure ]] || echo "Pure directory has impure xattr"
mv $SCRATCH_MNT/test_file $impure_dir
test_file_st_ino=$(stat -c '%i' $impure_dir/test_file)
-impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
$upperdir/test_dir/impure_dir)
[[ $impure == "y" ]] || echo "Impure directory missing impure xattr"
$here/src/t_dir_type $impure_dir $impure_subdir_st_ino
[[ $? != 0 ]] || echo "Directory's readdir cache has stale subdir entries"
-impure=$($GETFATTR_PROG --absolute-names --only-values -n 'trusted.overlay.impure' \
+impure=$(_getfattr --absolute-names --only-values -n 'trusted.overlay.impure' \
$upperdir/test_dir/impure_dir 2>/dev/null)
[[ -z $impure ]] || echo "Pure directory has impure xattr"
local target=$1
local expect=$2
- value=$($GETFATTR_PROG --absolute-names --only-values -n \
+ value=$(_getfattr --absolute-names --only-values -n \
$OVL_XATTR_REDIRECT $target)
[[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect"
{
local target=$1
- value=$($GETFATTR_PROG --absolute-names -d -m \
+ value=$(_getfattr --absolute-names -d -m \
$OVL_XATTR_REDIRECT $target)
[[ -z "$value" ]] || echo "Redirect xattr not empty"
{
local target=$1
- value=$($GETFATTR_PROG --absolute-names --only-values -n \
+ value=$(_getfattr --absolute-names --only-values -n \
$OVL_XATTR_OPAQUE $target)
[[ "$value" == "$OVL_XATTR_OPAQUE_VAL" ]] || \
{
local target=$1
- value=$($GETFATTR_PROG --absolute-names --only-values -n \
+ value=$(_getfattr --absolute-names --only-values -n \
$OVL_XATTR_IMPURE $target)
[[ "$value" == "$OVL_XATTR_IMPURE_VAL" ]] || echo "Missing impure xattr"
# get standard environment, filters and checks
. ./common/rc
. ./common/filter
+. ./common/attr
# remove previous $seqres.full before test
rm -f $seqres.full
local out_f target_f
local msg
- out_f=$($GETFATTR_PROG --absolute-names --only-values -n \
+ out_f=$(_getfattr --absolute-names --only-values -n \
$OVL_XATTR_METACOPY $target 2>&1 | _filter_scratch)
if [ "$exist" == "y" ];then
local target=$1
local expect=$2
- value=$($GETFATTR_PROG --absolute-names --only-values -n \
+ value=$(_getfattr --absolute-names --only-values -n \
$OVL_XATTR_REDIRECT $target)
[[ "$value" == "$expect" ]] || echo "Redirect xattr incorrect. Expected=\"$expect\", actual=\"$value\""
for ((i = 1; i <= $num_xattrs; i++)); do
name="user.attr_$(printf "%04d" $i)"
echo -n "$name="
- $GETFATTR_PROG --absolute-names -n $name --only-values $SCRATCH_MNT/foo
+ _getfattr --absolute-names -n $name --only-values $SCRATCH_MNT/foo
echo
done
return $exit
}
-_getfattr()
+do_getfattr()
{
- ${GETFATTR_PROG} $* 2>$tmp.err >$tmp.out
+ _getfattr $* 2>$tmp.err >$tmp.out
exit=$?
sed \
-e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
touch $testfile.1
echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
-_getfattr --absolute-names $testfile.1
+do_getfattr --absolute-names $testfile.1
inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
echo "*** make test file 2"
echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
| _attr -s "a3" $testfile.2 >/dev/null
-_getfattr --absolute-names $testfile.2
+do_getfattr --absolute-names $testfile.2
# print name and size from 1st line of output
_attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
cd $SCRATCH_MNT
touch testfile
$SETFATTR_PROG -n user.test -v 0xbabe testfile
-$GETFATTR_PROG testfile
+_getfattr testfile
cd $here
$UMOUNT_PROG $SCRATCH_MNT
_scratch_xfs_db -r -c version 2>&1 | _filter_version