Add a helper function to check kern.features.* sysctls.

Discussed with:	dougb
This commit is contained in:
Hiroki Sato 2011-06-11 21:40:37 +00:00
parent 90dc53a6f0
commit d3ae0231fe
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=222996
2 changed files with 24 additions and 5 deletions

View File

@ -349,11 +349,8 @@ afexists()
_af=$1
case ${_af} in
inet)
${SYSCTL_N} kern.features.inet > /dev/null 2>&1
;;
inet6)
${SYSCTL_N} kern.features.inet6 > /dev/null 2>&1
inet|inet6)
check_kern_features ${_af}
;;
ipx)
${SYSCTL_N} net.ipx > /dev/null 2>&1

View File

@ -1734,6 +1734,28 @@ check_required_after()
fi
# check_kern_features mib
# Return existence of kern.features.* sysctl MIB as true or
# false. The result will be cached in $_rc_cache_kern_features_
# namespace. "0" means the kern.features.X exists.
check_kern_features()
{
local _v
[ -n "$1" ] || return 1;
_v=`eval echo "\\$_rc_cache_kern_features_$1"`
[ -n "$_v" ] && return "$_v";
if ${SYSCTL_N} kern.features.$1 > /dev/null 2>&1; then
eval _rc_cache_kern_features_$1=0
return 0
else
eval _rc_cache_kern_features_$1=1
return 1
fi
}
# _echoonce var msg mode
# mode=0: Echo $msg if ${$var} is empty.
# After doing echo, a string is set to ${$var}.