rc.subr (159828) | rc.subr (160666) |
---|---|
1# $NetBSD: rc.subr,v 1.66 2006/04/01 10:05:50 he Exp $ | 1# $NetBSD: rc.subr,v 1.66 2006/04/01 10:05:50 he Exp $ |
2# $FreeBSD: head/etc/rc.subr 159828 2006-06-21 09:42:55Z yar $ | 2# $FreeBSD: head/etc/rc.subr 160666 2006-07-25 17:10:35Z yar $ |
3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 1342 unchanged lines hidden (view full) --- 1353 if [ -n "$3" ]; then 1354 flags="$3" 1355 fi 1356 /sbin/mdmfs $flags -s $1 md $2 1357} 1358 1359# Code common to scripts that need to load a kernel module 1360# if it isn't in the kernel yet. Syntax: | 3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 1342 unchanged lines hidden (view full) --- 1353 if [ -n "$3" ]; then 1354 flags="$3" 1355 fi 1356 /sbin/mdmfs $flags -s $1 md $2 1357} 1358 1359# Code common to scripts that need to load a kernel module 1360# if it isn't in the kernel yet. Syntax: |
1361# load_kld [-e regexp] [-m modname] filename | 1361# load_kld [-e regex] [-m module] file |
1362# where -e or -m chooses the way to check if the module 1363# is already loaded: | 1362# where -e or -m chooses the way to check if the module 1363# is already loaded: |
1364# regexp is egrep'd in the output from `kldstat -v', 1365# modname is passed to `kldstat -m'. 1366# The default way is as though `-m filename' were specified. | 1364# regex is egrep'd in the output from `kldstat -v', 1365# module is passed to `kldstat -m'. 1366# The default way is as though `-m file' were specified. |
1367load_kld() 1368{ 1369 local _loaded _mod _opt _re 1370 1371 while getopts "e:m:" _opt; do 1372 case "$_opt" in 1373 e) _re="$OPTARG" ;; 1374 m) _mod="$OPTARG" ;; | 1367load_kld() 1368{ 1369 local _loaded _mod _opt _re 1370 1371 while getopts "e:m:" _opt; do 1372 case "$_opt" in 1373 e) _re="$OPTARG" ;; 1374 m) _mod="$OPTARG" ;; |
1375 *) err 3 'USAGE: load_kld [-e regex] [-m module] file' ;; |
|
1375 esac 1376 done 1377 shift $(($OPTIND - 1)) | 1376 esac 1377 done 1378 shift $(($OPTIND - 1)) |
1379 if [ $# -ne 1 ]; then 1380 err 3 'USAGE: load_kld [-e regex] [-m module] file' 1381 fi |
|
1378 _mod=${_mod:-$1} 1379 _loaded=false 1380 if [ -n "$_re" ]; then 1381 if kldstat -v | egrep -q -e "$_re"; then 1382 _loaded=true 1383 fi 1384 else 1385 if kldstat -q -m "$_mod"; then 1386 _loaded=true 1387 fi 1388 fi 1389 if ! $_loaded; then 1390 if ! kldload "$1"; then 1391 warn "Unable to load kernel module $1" 1392 return 1 | 1382 _mod=${_mod:-$1} 1383 _loaded=false 1384 if [ -n "$_re" ]; then 1385 if kldstat -v | egrep -q -e "$_re"; then 1386 _loaded=true 1387 fi 1388 else 1389 if kldstat -q -m "$_mod"; then 1390 _loaded=true 1391 fi 1392 fi 1393 if ! $_loaded; then 1394 if ! kldload "$1"; then 1395 warn "Unable to load kernel module $1" 1396 return 1 |
1397 else 1398 info "$1 kernel module loaded." |
|
1393 fi | 1399 fi |
1400 else 1401 debug "load_kld: $1 kernel module already loaded." |
|
1394 fi 1395 return 0 1396} 1397 1398# ltr str src dst 1399# Change every $src in $str to $dst. 1400# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor 1401# awk(1). --- 103 unchanged lines hidden --- | 1402 fi 1403 return 0 1404} 1405 1406# ltr str src dst 1407# Change every $src in $str to $dst. 1408# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor 1409# awk(1). --- 103 unchanged lines hidden --- |