rc.subr (f5dfe75da5ba2937f8766792f625f32fc3ef4757) rc.subr (b11974c250671368e1eb869ca8ce2ed70622917f)
1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $
2# $FreeBSD$
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.

--- 1839 unchanged lines hidden (view full) ---

1848{
1849 if [ -n "$3" ]; then
1850 flags="$3"
1851 fi
1852 /sbin/mdmfs $flags -s $1 ${mfs_type} $2
1853}
1854
1855# Code common to scripts that need to load a kernel module
1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $
2# $FreeBSD$
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.

--- 1839 unchanged lines hidden (view full) ---

1848{
1849 if [ -n "$3" ]; then
1850 flags="$3"
1851 fi
1852 /sbin/mdmfs $flags -s $1 ${mfs_type} $2
1853}
1854
1855# Code common to scripts that need to load a kernel module
1856# if it isn't in the kernel yet. Syntax:
1857# load_kld file
1856# if it isn't in the kernel yet. Syntax:
1857# load_kld [-e regex] [-m module] file
1858# where -e or -m chooses the way to check if the module
1859# is already loaded:
1860# regex is egrep'd in the output from `kldstat -v',
1861# module is passed to `kldstat -m'.
1862# The default way is as though `-m file' were specified.
1858load_kld()
1859{
1863load_kld()
1864{
1860 local _opt
1865 local _loaded _mod _opt _re
1861
1866
1862 # Silently ignore legacy options; they are unnecessary
1863 while getopts "e:m:" _opt; do
1864 case "$_opt" in
1867 while getopts "e:m:" _opt; do
1868 case "$_opt" in
1865 e) ;;
1866 m) ;;
1867 *) err 3 'USAGE: load_kld file' ;;
1869 e) _re="$OPTARG" ;;
1870 m) _mod="$OPTARG" ;;
1871 *) err 3 'USAGE: load_kld [-e regex] [-m module] file' ;;
1868 esac
1869 done
1870 shift $(($OPTIND - 1))
1871 if [ $# -ne 1 ]; then
1872 esac
1873 done
1874 shift $(($OPTIND - 1))
1875 if [ $# -ne 1 ]; then
1872 err 3 'USAGE: load_kld file'
1876 err 3 'USAGE: load_kld [-e regex] [-m module] file'
1873 fi
1877 fi
1874 if ! kldload -n "$1"; then
1875 warn "Unable to load kernel module $1"
1876 return 1
1878 _mod=${_mod:-$1}
1879 _loaded=false
1880 if [ -n "$_re" ]; then
1881 if kldstat -v | egrep -q -e "$_re"; then
1882 _loaded=true
1883 fi
1877 else
1884 else
1878 info "$1 kernel module loaded."
1885 if kldstat -q -m "$_mod"; then
1886 _loaded=true
1887 fi
1879 fi
1888 fi
1889 if ! $_loaded; then
1890 if ! kldload "$1"; then
1891 warn "Unable to load kernel module $1"
1892 return 1
1893 else
1894 info "$1 kernel module loaded."
1895 fi
1896 else
1897 debug "load_kld: $1 kernel module already loaded."
1898 fi
1880 return 0
1881}
1882
1883# ltr str src dst [var]
1884# Change every $src in $str to $dst.
1885# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor
1886# awk(1). If var is non-NULL, set it to the result.
1887ltr()

--- 283 unchanged lines hidden ---
1899 return 0
1900}
1901
1902# ltr str src dst [var]
1903# Change every $src in $str to $dst.
1904# Useful when /usr is not yet mounted and we cannot use tr(1), sed(1) nor
1905# awk(1). If var is non-NULL, set it to the result.
1906ltr()

--- 283 unchanged lines hidden ---