Date: Fri, 11 May 2007 13:41:56 -0500 From: "Scot Hetzel" <swhetzel@gmail.com> To: freebsd-current@freebsd.org Subject: mdconfig not returning error when listing a non-existing device. Message-ID: <790a9fff0705111141n3731f75at23aae6f0482bd638@mail.gmail.com>
next in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
I created a vnode filesystem to use with mdconfig and added it to the
/etc/rc.conf file:
mdconfig2_enable="YES"
mdconfig2_list="md99"
#ncvs filesystem to be mounted by zfs
mdconfig_md99="-t vnode -f /usr/home/ncvs.dsk"
The problem is that when the mdconfig2 rc script is executed, it fails
to create the md device.
hp010# ls /dev/md*
/dev/mdctl
hp010# /etc/rc.d/mdconfig2 start md99
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: start_precmd: [ -n
"${_mdconfig2_list}" ]
/etc/rc.d/mdconfig2: DEBUG: load_kld: geom_md kernel module already loaded.
/etc/rc.d/mdconfig2: DEBUG: run_rc_command: doit: mdconfig2_start
/etc/rc.d/mdconfig2: DEBUG: md99 config: -t vnode -f /usr/home/ncvs.dsk
/etc/rc.d/mdconfig2: DEBUG: md99 type: vnode
/etc/rc.d/mdconfig2: DEBUG: md99 dev: /dev/md99
/etc/rc.d/mdconfig2: DEBUG: md99 file: /usr/home/ncvs.dsk
/etc/rc.d/mdconfig2: DEBUG: md99 fs: /usr/home
/etc/rc.d/mdconfig2: DEBUG: md99 owner:
/etc/rc.d/mdconfig2: DEBUG: md99 perms:
/etc/rc.d/mdconfig2: DEBUG: md99 files:
/etc/rc.d/mdconfig2: DEBUG: md99 populate cmd:
/etc/rc.d/mdconfig2: ERROR: md99 already exists
This error comes from when it is checking if the device already exists:
if mdconfig -l -u ${_md} >/dev/null 2>&1; then
err 3 "${_md} already exists"
fi
The problem is that mdconfig -l doesn't return an error code when it
is asked to list a non-existant device.
hp010# ls /dev/md*
/dev/mdctl
hp010# mdconfig -l -u md99 ; echo $?
0
hp010# mdconfig -a -t vnode -f /usr/home/ncvs.dsk -u md99 ; echo $?
0
hp010# mdconfig -l -u md0 ; echo $?
md0 vnode 5.0G /usr/home/ncvs.dsk
0
This problem affects both the /etc/rc.d/mdconfig and mdconfig2 scripts.
Scot
NOTE: The attached patch adds mdconfig[,2]_list - its use is to allow
the scripts to configure md devices that don't start at 0.
--
DISCLAIMER:
No electrons were mamed while sending this message. Only slightly bruised.
[-- Attachment #2 --]
Index: mdconfig
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/mdconfig,v
retrieving revision 1.4
diff -u -r1.4 mdconfig
--- mdconfig 31 Dec 2006 10:37:18 -0000 1.4
+++ mdconfig 11 May 2007 18:18:50 -0000
@@ -191,6 +191,14 @@
_mdconfig_unit=$((${_mdconfig_unit} + 1))
fi
done
+ if [ -n "${mdconfig_list}" ] ; then
+ for _mdconfig_dev in ${mdconfig_list} ; do
+ eval _mdconfig_config=\$mdconfig_${mdconfig_dev}
+ if [ -n "${_mdconfig_config}" ] ; then
+ _mdconfig_list="${_mdconfig_list}${_mdconfig_list:+ }${_mdconfig_dev}"
+ fi
+ done
+ fi
fi
run_rc_command "${_mdconfig_cmd}"
Index: mdconfig2
===================================================================
RCS file: /home/ncvs/src/etc/rc.d/mdconfig2,v
retrieving revision 1.4
diff -u -r1.4 mdconfig2
--- mdconfig2 31 Dec 2006 10:37:18 -0000 1.4
+++ mdconfig2 11 May 2007 18:15:53 -0000
@@ -222,6 +222,14 @@
_mdconfig2_unit=$((${_mdconfig2_unit} + 1))
fi
done
+ if [ -n "${mdconfig2_list}" ] ; then
+ for _mdconfig2_dev in ${mdconfig2_list} ; do
+ eval _mdconfig2_config=\$mdconfig_${mdconfig2_dev}
+ if [ -n "${_mdconfig2_config}" ] ; then
+ _mdconfig2_list="${_mdconfig2_list}${_mdconfig2_list:+ }${_mdconfig2_dev}"
+ fi
+ done
+ fi
fi
run_rc_command "${_mdconfig2_cmd}"
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?790a9fff0705111141n3731f75at23aae6f0482bd638>
