Deleted Added
full compact
mdconfig2 (160669) mdconfig2 (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/mdconfig2 160669 2006-07-25 17:19:00Z pjd $
27# $FreeBSD: head/etc/rc.d/mdconfig2 165683 2006-12-31 10:37:18Z yar $
28#
29
30# PROVIDE: mdconfig2
31# REQUIRE: mountcritremote
32# BEFORE: SERVERS
33
34. /etc/rc.subr
35
36name="mdconfig2"
37stop_cmd="mdconfig2_stop"
38start_cmd="mdconfig2_start"
28#
29
30# PROVIDE: mdconfig2
31# REQUIRE: mountcritremote
32# BEFORE: SERVERS
33
34. /etc/rc.subr
35
36name="mdconfig2"
37stop_cmd="mdconfig2_stop"
38start_cmd="mdconfig2_start"
39start_precmd='[ -n "${_mdconfig2_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

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

83 if [ "${_type}" = "vnode" ]; then
84 _file=${_config##*-f\ }
85 _file=${_file%%\ *}
86 if [ -z "${_file}" ]; then
87 err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices"
88 fi
89
90 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

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

85 if [ "${_type}" = "vnode" ]; then
86 _file=${_config##*-f\ }
87 _file=${_file%%\ *}
88 if [ -z "${_file}" ]; then
89 err 2 "You need to specify \"-f <file>\" in mdconfig_${_md} for vnode devices"
90 fi
91
92 if [ "${_file}" != "${_file%.uzip}" ]; then
91 # Load geom_uzip kernel module if needed
92 kldstat -q -m g_uzip || kldload geom_uzip || err 1 "geom_uzip failed to load."
93 _dev="/dev/${_md}.uzip"
94 fi
95 for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done
96 fi
97
98 # Debugging help.
99 debug "${_md} config: ${_config}"
100 debug "${_md} type: ${_type}"

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

106 debug "${_md} files: ${_files}"
107 debug "${_md} populate cmd: ${_populate}"
108}
109
110mdconfig2_start()
111{
112 local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate _fsck_cmd _i
113
93 _dev="/dev/${_md}.uzip"
94 fi
95 for _i in `df ${_file} 2>/dev/null`; do _fs=${_i}; done
96 fi
97
98 # Debugging help.
99 debug "${_md} config: ${_config}"
100 debug "${_md} type: ${_type}"

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

106 debug "${_md} files: ${_files}"
107 debug "${_md} populate cmd: ${_populate}"
108}
109
110mdconfig2_start()
111{
112 local _md _fs _mp _mounted _dev _config _type _file _owner _perms _files _populate _fsck_cmd _i
113
114 # If there are no devices return before loading geom_md.ko.
115 if [ -z "${_mdconfig2_list}" ]; then
116 return
117 fi
118
119 kldstat -q -m g_md || kldload geom_md || err 1 "geom_md failed to load."
120
121 for _md in ${_mdconfig2_list}; do
122 init_variables ${_md}
123 if [ ! -r ${_file} ]; then
124 err 3 "${_file} doesn't exist"
125 continue
126 fi
127 # First pass: create md(4) vnode devices from files stored on
128 # non-root partition. Swap and malloc md(4) devices have already
129 # been created.
130 if [ "${_type}" = "vnode" -a "${_fs}" != "/" ]; then
114 for _md in ${_mdconfig2_list}; do
115 init_variables ${_md}
116 if [ ! -r ${_file} ]; then
117 err 3 "${_file} doesn't exist"
118 continue
119 fi
120 # First pass: create md(4) vnode devices from files stored on
121 # non-root partition. Swap and malloc md(4) devices have already
122 # been created.
123 if [ "${_type}" = "vnode" -a "${_fs}" != "/" ]; then
124 if [ "${_file}" != "${_file%.uzip}" ]; then
125 load_kld -m g_uzip geom_uzip || return 3
126 fi
131 if is_readonly ${_fs}; then
132 warn "${_fs} is mounted read-only, skipping ${_md}."
133 continue
134 fi
135 if mdconfig -l -u ${_md} >/dev/null 2>&1; then
136 err 3 "${_md} already exists"
137 fi
138 echo "Creating ${_md} device (${_type})."

--- 93 unchanged lines hidden ---
127 if is_readonly ${_fs}; then
128 warn "${_fs} is mounted read-only, skipping ${_md}."
129 continue
130 fi
131 if mdconfig -l -u ${_md} >/dev/null 2>&1; then
132 err 3 "${_md} already exists"
133 fi
134 echo "Creating ${_md} device (${_type})."

--- 93 unchanged lines hidden ---