aboutsummaryrefslogtreecommitdiffstats
path: root/tests/zfs-tests/include/libtest.shlib
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2020-01-10 16:24:59 -0500
committerBrian Behlendorf <[email protected]>2020-01-10 13:24:59 -0800
commit6e1c594d6491ed5c9cc052ad5d94098eff684e2a (patch)
tree13480e369e83f8c3e2b3805b8b9c59fbcbfcf171 /tests/zfs-tests/include/libtest.shlib
parentba0ba69e50efeda7190b59f27c23ada0edf6f36b (diff)
ZTS: Create xattr helpers to hide platform
Create xattr helpers to hide platform and update usage in tests. This does not generally aim to enable all xattr tests yet, but it is a necessary step in that direction. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #9826
Diffstat (limited to 'tests/zfs-tests/include/libtest.shlib')
-rw-r--r--tests/zfs-tests/include/libtest.shlib79
1 files changed, 79 insertions, 0 deletions
diff --git a/tests/zfs-tests/include/libtest.shlib b/tests/zfs-tests/include/libtest.shlib
index b3bd3dfdf..3ba7a8cbe 100644
--- a/tests/zfs-tests/include/libtest.shlib
+++ b/tests/zfs-tests/include/libtest.shlib
@@ -3949,3 +3949,82 @@ function range_shuffle # begin end
shuf -i ${begin}-${end}
fi
}
+
+#
+# Cross-platform xattr helpers
+#
+
+function get_xattr # name path
+{
+ typeset name=$1
+ typeset path=$2
+
+ case $(uname) in
+ FreeBSD)
+ getextattr -qq user "${name}" "${path}"
+ ;;
+ *)
+ attr -qg "${name}" "${path}"
+ ;;
+ esac
+}
+
+function set_xattr # name value path
+{
+ typeset name=$1
+ typeset value=$2
+ typeset path=$3
+
+ case $(uname) in
+ FreeBSD)
+ setextattr user "${name}" "${value}" "${path}"
+ ;;
+ *)
+ attr -qs "${name}" -V "${value}" "${path}"
+ ;;
+ esac
+}
+
+function set_xattr_stdin # name value
+{
+ typeset name=$1
+ typeset path=$2
+
+ case $(uname) in
+ FreeBSD)
+ setextattr -i user "${name}" "${path}"
+ ;;
+ *)
+ attr -qs "${name}" "${path}"
+ ;;
+ esac
+}
+
+function rm_xattr # name path
+{
+ typeset name=$1
+ typeset path=$2
+
+ case $(uname) in
+ FreeBSD)
+ rmextattr -q user "${name}" "${path}"
+ ;;
+ *)
+ attr -qr "${name}" "${path}"
+ ;;
+ esac
+}
+
+function ls_xattr # path
+{
+ typeset path=$1
+
+ case $(uname) in
+ FreeBSD)
+ lsextattr -qq user "${path}"
+ ;;
+ *)
+ attr -ql "${path}"
+ ;;
+ esac
+}