mirror of
https://github.com/linux-apfs/apfstests.git
synced 2026-05-01 15:01:44 -07:00
fstests: filter redundant output by getfattr
When getfattr dumps values of all extended attributes (-d option),
it doesn't print empty extended attributes. e.g: user.name. But from
attr-2.4.48 this behavior is changed, new getfattr prints
user.name="".
The {=""} will break the golden image, so filter the redundant =""
at the end if it has.
Signed-off-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
This commit is contained in:
+12
@@ -224,6 +224,18 @@ _sort_getfattr_output()
|
||||
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)
|
||||
|
||||
+1
-1
@@ -151,7 +151,7 @@ done
|
||||
|
||||
# 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
|
||||
|
||||
|
||||
+2
-2
@@ -51,14 +51,14 @@ attr_set()
|
||||
$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.
|
||||
|
||||
+4
-4
@@ -35,9 +35,9 @@ _attr()
|
||||
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
|
||||
@@ -49,7 +49,7 @@ _attr_list()
|
||||
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
|
||||
@@ -110,7 +110,7 @@ done
|
||||
|
||||
echo "*** check"
|
||||
# don't print it all out...
|
||||
getfattr --absolute-names $testfile \
|
||||
_getfattr --absolute-names $testfile \
|
||||
| tee -a $seqres.full \
|
||||
| $AWK_PROG '
|
||||
/^#/ { next }
|
||||
|
||||
+1
-1
@@ -76,7 +76,7 @@ set_xattr_loop $test_file &
|
||||
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
|
||||
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ trap "_cleanup; exit \$status" 0 1 2 3 15
|
||||
|
||||
getfattr()
|
||||
{
|
||||
$GETFATTR_PROG --absolute-names -dh $@ 2>&1 | _filter_scratch
|
||||
_getfattr --absolute-names -dh $@ 2>&1 | _filter_scratch
|
||||
}
|
||||
|
||||
setfattr()
|
||||
@@ -166,7 +166,7 @@ _backup()
|
||||
# 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"
|
||||
|
||||
+2
-2
@@ -72,7 +72,7 @@ _flakey_drop_and_remount
|
||||
# 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
|
||||
@@ -89,7 +89,7 @@ _flakey_drop_and_remount
|
||||
|
||||
# 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
|
||||
|
||||
+1
-1
@@ -63,7 +63,7 @@ $SETCAP_PROG cap_chown+ep $file
|
||||
$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
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ _cleanup()
|
||||
|
||||
getfattr()
|
||||
{
|
||||
$GETFATTR_PROG --absolute-names "$@" |& _filter_test_dir
|
||||
_getfattr --absolute-names "$@" |& _filter_test_dir
|
||||
}
|
||||
|
||||
setfattr()
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ $SETFATTR_PROG -n user.ping -v pong $SCRATCH_MNT/testfile
|
||||
|
||||
# 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
|
||||
|
||||
+3
-2
@@ -23,6 +23,7 @@ _cleanup()
|
||||
|
||||
# get standard environment, filters and checks
|
||||
. ./common/rc
|
||||
. ./common/attr
|
||||
|
||||
# remove previous $seqres.full before test
|
||||
rm -f $seqres.full
|
||||
@@ -59,11 +60,11 @@ $GETRICHACL_PROG x
|
||||
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
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ $SETFATTR_PROG -n trusted.small -v a $SCRATCH_MNT/file
|
||||
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=$!
|
||||
|
||||
+3
-3
@@ -58,7 +58,7 @@ testf() {
|
||||
|
||||
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
|
||||
@@ -127,7 +127,7 @@ setf "zerojoin_moo\xe2\x80\x8ccow.txt" "zero width joiners"
|
||||
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"
|
||||
@@ -175,7 +175,7 @@ testf "combmark_\xe1\x80\x9c\xe1\x80\xad\xe1\x80\xaf.txt" "combining marks"
|
||||
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}."
|
||||
|
||||
|
||||
+1
-1
@@ -58,7 +58,7 @@ $XFS_IO_PROG -c "pwrite -S 0xea 0 64K" \
|
||||
# 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
|
||||
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ $SETFATTR_PROG -n "trusted.overlay.opaque" -v "y" $upperdir/testdir
|
||||
$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
|
||||
|
||||
+2
-2
@@ -71,7 +71,7 @@ touch $SCRATCH_MNT/testf1
|
||||
$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.
|
||||
@@ -86,7 +86,7 @@ $SETFATTR_PROG -n "trusted.overlay.fsz" -v "n" \
|
||||
$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'
|
||||
|
||||
|
||||
+2
-2
@@ -77,7 +77,7 @@ subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
|
||||
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"
|
||||
|
||||
@@ -109,7 +109,7 @@ $here/src/t_dir_type $impure_dir $test_file_st_ino
|
||||
$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"
|
||||
|
||||
|
||||
+2
-2
@@ -89,7 +89,7 @@ subdir_d=$($here/src/t_dir_type $impure_dir $impure_subdir_st_ino)
|
||||
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"
|
||||
|
||||
@@ -121,7 +121,7 @@ $here/src/t_dir_type $impure_dir $test_file_st_ino
|
||||
$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"
|
||||
|
||||
|
||||
+3
-3
@@ -57,7 +57,7 @@ check_redirect()
|
||||
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"
|
||||
@@ -67,7 +67,7 @@ check_no_redirect()
|
||||
{
|
||||
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"
|
||||
@@ -78,7 +78,7 @@ check_opaque()
|
||||
{
|
||||
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" ]] || \
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ check_impure()
|
||||
{
|
||||
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"
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user