Changeset View
Changeset View
Standalone View
Standalone View
libexec/rc/rc.subr
Show First 20 Lines • Show All 1,835 Lines • ▼ Show 20 Lines | |||||
{ | { | ||||
if [ -n "$3" ]; then | if [ -n "$3" ]; then | ||||
flags="$3" | flags="$3" | ||||
fi | fi | ||||
/sbin/mdmfs $flags -s $1 ${mfs_type} $2 | /sbin/mdmfs $flags -s $1 ${mfs_type} $2 | ||||
} | } | ||||
# Code common to scripts that need to load a kernel module | # Code common to scripts that need to load a kernel module | ||||
# if it isn't in the kernel yet. Syntax: | # if it isn't in the kernel yet. Syntax: | ||||
# load_kld [-e regex] [-m module] file | # load_kld file | ||||
# where -e or -m chooses the way to check if the module | |||||
# is already loaded: | |||||
# regex is egrep'd in the output from `kldstat -v', | |||||
# module is passed to `kldstat -m'. | |||||
# The default way is as though `-m file' were specified. | |||||
load_kld() | load_kld() | ||||
{ | { | ||||
local _loaded _mod _opt _re | local _opt | ||||
# Silently ignore legacy options; they are unnecessary | |||||
while getopts "e:m:" _opt; do | while getopts "e:m:" _opt; do | ||||
case "$_opt" in | case "$_opt" in | ||||
e) _re="$OPTARG" ;; | e) ;; | ||||
m) _mod="$OPTARG" ;; | m) ;; | ||||
*) err 3 'USAGE: load_kld [-e regex] [-m module] file' ;; | *) err 3 'USAGE: load_kld file' ;; | ||||
esac | esac | ||||
done | done | ||||
shift $(($OPTIND - 1)) | shift $(($OPTIND - 1)) | ||||
if [ $# -ne 1 ]; then | if [ $# -ne 1 ]; then | ||||
err 3 'USAGE: load_kld [-e regex] [-m module] file' | err 3 'USAGE: load_kld file' | ||||
fi | fi | ||||
_mod=${_mod:-$1} | if ! kldload -n "$1"; then | ||||
_loaded=false | |||||
if [ -n "$_re" ]; then | |||||
if kldstat -v | egrep -q -e "$_re"; then | |||||
_loaded=true | |||||
fi | |||||
else | |||||
if kldstat -q -m "$_mod"; then | |||||
_loaded=true | |||||
fi | |||||
fi | |||||
if ! $_loaded; then | |||||
if ! kldload "$1"; then | |||||
warn "Unable to load kernel module $1" | warn "Unable to load kernel module $1" | ||||
return 1 | return 1 | ||||
else | else | ||||
info "$1 kernel module loaded." | info "$1 kernel module loaded." | ||||
jilles: Debug output will be different, but I think it is enough to mention that in the commit message. | |||||
fi | |||||
else | |||||
debug "load_kld: $1 kernel module already loaded." | |||||
fi | fi | ||||
return 0 | return 0 | ||||
} | } | ||||
# ltr str src dst [var] | # ltr str src dst [var] | ||||
# Change every $src in $str to $dst. | # Change every $src in $str to $dst. | ||||
# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor | # Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor | ||||
# awk(1). If var is non-NULL, set it to the result. | # awk(1). If var is non-NULL, set it to the result. | ||||
▲ Show 20 Lines • Show All 284 Lines • Show Last 20 Lines |
Debug output will be different, but I think it is enough to mention that in the commit message.