mdconfig not returning error when listing a non-existing device.

From: Scot Hetzel <swhetzel_at_gmail.com>
Date: Fri, 11 May 2007 13:41:56 -0500
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.

Received on Fri May 11 2007 - 16:41:57 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:39:10 UTC