mdconfig (160669) | mdconfig (165683) |
---|---|
1#!/bin/sh 2# 3# Copyright (c) 2006 The FreeBSD Project 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# | 1#!/bin/sh 2# 3# Copyright (c) 2006 The FreeBSD Project 4# All rights reserved. 5# 6# Redistribution and use in source and binary forms, with or without 7# modification, are permitted provided that the following conditions 8# are met: --- 10 unchanged lines hidden (view full) --- 19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25# SUCH DAMAGE. 26# |
27# $FreeBSD: head/etc/rc.d/mdconfig 160669 2006-07-25 17:19:00Z pjd $ | 27# $FreeBSD: head/etc/rc.d/mdconfig 165683 2006-12-31 10:37:18Z yar $ |
28# 29 30# PROVIDE: mdconfig 31# REQUIRE: localswap 32# BEFORE: mountcritlocal 33 34. /etc/rc.subr 35 36name="mdconfig" 37stop_cmd="mdconfig_stop" 38start_cmd="mdconfig_start" | 28# 29 30# PROVIDE: mdconfig 31# REQUIRE: localswap 32# BEFORE: mountcritlocal 33 34. /etc/rc.subr 35 36name="mdconfig" 37stop_cmd="mdconfig_stop" 38start_cmd="mdconfig_start" |
39start_precmd='[ -n "${_mdconfig_list}" ]' 40required_modules="geom_md:g_md" |
|
39 40is_readonly() 41{ 42 local _mp _ret 43 44 _mp=$1 45 _ret=`mount | while read _line; do 46 case ${_line} in --- 31 unchanged lines hidden (view full) --- 78 79 if [ "${_type}" = "vnode" ]; then 80 _file=${_config##*-f\ } 81 _file=${_file%%\ *} 82 if [ -z "${_file}" ]; then 83 err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices" 84 fi 85 if [ "${_file}" != "${_file%.uzip}" ]; then | 41 42is_readonly() 43{ 44 local _mp _ret 45 46 _mp=$1 47 _ret=`mount | while read _line; do 48 case ${_line} in --- 31 unchanged lines hidden (view full) --- 80 81 if [ "${_type}" = "vnode" ]; then 82 _file=${_config##*-f\ } 83 _file=${_file%%\ *} 84 if [ -z "${_file}" ]; then 85 err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices" 86 fi 87 if [ "${_file}" != "${_file%.uzip}" ]; then |
86 # Load geom_uzip kernel module if needed 87 kldstat -q -m g_uzip || kldload geom_uzip || err 1 "geom_uzip failed to load." | |
88 _dev="/dev/${_md}.uzip" 89 fi 90 for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done 91 fi 92 93 # Debugging help. 94 debug "${_md} config: ${_config}" 95 debug "${_md} type: ${_type}" 96 debug "${_md} dev: ${_dev}" 97 debug "${_md} file: ${_file}" 98 debug "${_md} fs: ${_fs}" 99 debug "${_md} newfs flags: ${_newfs}" 100} 101 102mdconfig_start() 103{ 104 local _md _mp _config _type _dev _file _fs _newfs _fsck_cmd 105 | 88 _dev="/dev/${_md}.uzip" 89 fi 90 for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done 91 fi 92 93 # Debugging help. 94 debug "${_md} config: ${_config}" 95 debug "${_md} type: ${_type}" 96 debug "${_md} dev: ${_dev}" 97 debug "${_md} file: ${_file}" 98 debug "${_md} fs: ${_fs}" 99 debug "${_md} newfs flags: ${_newfs}" 100} 101 102mdconfig_start() 103{ 104 local _md _mp _config _type _dev _file _fs _newfs _fsck_cmd 105 |
106 # If there are no devices return before loading geom_md.ko. 107 if [ -z "${_mdconfig_list}" ]; then 108 return 109 fi 110 111 kldstat -q -m g_md || kldload geom_md || err 1 "geom_md failed to load." 112 | |
113 for _md in ${_mdconfig_list}; do 114 init_variables ${_md} 115 # Create md(4) devices of types swap, malloc and vnode if the 116 # file is on the root partition. 117 if [ "${_type}" != "vnode" -o "${_fs}" = "/" ]; then 118 if [ "${_type}" = "vnode" ]; then 119 if is_readonly ${_fs}; then 120 warn "${_fs} is mounted read-only, skipping ${_md}." 121 continue 122 fi | 106 for _md in ${_mdconfig_list}; do 107 init_variables ${_md} 108 # Create md(4) devices of types swap, malloc and vnode if the 109 # file is on the root partition. 110 if [ "${_type}" != "vnode" -o "${_fs}" = "/" ]; then 111 if [ "${_type}" = "vnode" ]; then 112 if is_readonly ${_fs}; then 113 warn "${_fs} is mounted read-only, skipping ${_md}." 114 continue 115 fi |
116 if [ "${_file}" != "${_file%.uzip}" ]; then 117 load_kld -m g_uzip geom_uzip || return 3 118 fi |
|
123 fi 124 if mdconfig -l -u ${_md} >/dev/null 2>&1; then 125 err 3 "${_md} already exists" 126 fi 127 echo "Creating ${_md} device (${_type})." 128 if ! mdconfig -a ${_config} -u ${_md}; then 129 echo "Creating ${_md} device failed, moving on." 130 continue --- 70 unchanged lines hidden --- | 119 fi 120 if mdconfig -l -u ${_md} >/dev/null 2>&1; then 121 err 3 "${_md} already exists" 122 fi 123 echo "Creating ${_md} device (${_type})." 124 if ! mdconfig -a ${_config} -u ${_md}; then 125 echo "Creating ${_md} device failed, moving on." 126 continue --- 70 unchanged lines hidden --- |