mirror of
https://git.proxmox.com/git/mirror_zfs.git
synced 2026-05-24 03:08:51 +03:00
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 <behlendorf1@llnl.gov> Signed-off-by: Ryan Moeller <ryan@ixsystems.com> Closes #9826
This commit is contained in:
committed by
Brian Behlendorf
parent
ba0ba69e50
commit
6e1c594d64
@@ -115,13 +115,17 @@ export SYSTEM_FILES_FREEBSD='chflags
|
||||
compress
|
||||
dumpon
|
||||
fsck
|
||||
getextattr
|
||||
gpart
|
||||
lsextattr
|
||||
md5
|
||||
mdconfig
|
||||
mkfifo
|
||||
newfs
|
||||
pw
|
||||
random
|
||||
rmextattr
|
||||
setextattr
|
||||
sha256
|
||||
swapctl
|
||||
sysctl
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user