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

Scot Hetzel swhetzel at gmail.com
Fri May 11 18:41:57 UTC 2007


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: mdconfig.patch
Type: text/x-diff
Size: 1333 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-current/attachments/20070511/23bfeebf/mdconfig.bin


More information about the freebsd-current mailing list