fstests: filter redundant output by getfattr
[xfstests-dev.git] / common / attr
index 10b98eefcb17d2a57c56d3283f57a1ed3c8bd16d..20049de02b50e7b378d3249a0f0ebbb28bc55a24 100644 (file)
@@ -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)