function is_linux
{
- if [[ $(uname -o) == "GNU/Linux" ]]; then
- return 0
- else
- return 1
- fi
+ [ $(uname) = "Linux" ]
}
# Determine if this is an illumos test system
# Return 0 if platform illumos, 1 if otherwise
function is_illumos
{
- if [[ $(uname -o) == "illumos" ]]; then
- return 0
- else
- return 1
- fi
+ [ $(uname) = "illumos" ]
}
# Determine if this is a FreeBSD test system
function is_freebsd
{
- if [[ $(uname -o) == "FreeBSD" ]]; then
- return 0
- else
- return 1
- fi
+ [ $(uname) = "FreeBSD" ]
}
# Determine if this is a DilOS test system
{
typeset ID=""
[[ -f /etc/os-release ]] && . /etc/os-release
- if [[ $ID == "dilos" ]]; then
- return 0
- else
- return 1
- fi
+ [ "$ID" = "dilos" ]
}
# Determine if this is a 32-bit system
function is_32bit
{
- if [[ $(getconf LONG_BIT) == "32" ]]; then
- return 0
- else
- return 1
- fi
+ [ $(getconf LONG_BIT) = "32" ]
}
# Determine if kmemleak is enabled
function is_kmemleak
{
- if is_linux && [[ -e /sys/kernel/debug/kmemleak ]]; then
- return 0
- else
- return 1
- fi
+ is_linux && [ -e /sys/kernel/debug/kmemleak ]
}
# Determine whether a dataset is mounted
#
function not_shared
{
- typeset fs=$1
-
- is_shared $fs
- if (($? == 0)); then
- return 1
- fi
-
- return 0
+ ! is_shared $1
}
#
#
function not_shared_smb
{
- typeset fs=$1
-
- is_shared_smb $fs
- if (($? == 0)); then
- return 1
- fi
-
- return 0
+ ! is_shared_smb $1
}
#
{
typeset fs=$1
- is_shared $fs || is_shared_smb $fs
- if (($? == 0)); then
+ if is_shared $fs || is_shared_smb $fs; then
zfs unshare $fs || log_fail "zfs unshare $fs failed"
fi
-
- return 0
}
#
{
typeset fs=$1
- if is_linux; then
- is_shared $fs
- if (($? != 0)); then
+ if ! is_shared $fs; then
+ if is_linux; then
log_must share "*:$fs"
- fi
- else
- is_shared $fs
- if (($? != 0)); then
+ else
log_must share -F nfs $fs
fi
fi
{
typeset fs=$1
- if is_linux; then
- is_shared $fs
- if (($? == 0)); then
+ if is_shared $fs; then
+ if is_linux; then
log_must unshare -u "*:$fs"
- fi
- else
- is_shared $fs
- if (($? == 0)); then
+ else
log_must unshare -F nfs $fs
fi
fi
return 0
else
typeset cur_zone=$(zonename 2>/dev/null)
- if [[ $cur_zone != "global" ]]; then
- return 1
- fi
- return 0
+ [ $cur_zone = "global" ]
fi
}