Fix parameter validation and error reporting in ba_map()
authorBryn M. Reeves <bmr@redhat.com>
Wed, 6 Feb 2013 18:01:14 +0000 (18:01 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Wed, 6 Feb 2013 18:01:14 +0000 (18:01 +0000)
commit6758470b85193968da5002fdcad13e78bae50d08
treefe86c57898db011a7b618bf10d75a3a6de0b0551
parent538db7dd716d934ee5a79658cdec27f11834d28a
Fix parameter validation and error reporting in ba_map()

ba_map() tried to use parameters before validating them leading
to user-visible bash errors.

Also make it clear that a device that does not match on partition
or type is not an error (even though it's a 'failure' for the
udev rule).

This helps when manually debugging mapping by handcrafting udev
environment variables, e.g.:

BA_WWID=0QEMU_QEMU_HARDDISK_drive-scsi0-0-3
BA_NAME=oracleasm/disks/DSK4
BA_TYPE=mpath
BA_USER=oracle
BA_GROUP=oracle
BA_MODE=0620

BA_WWID=0QEMU_QEMU_HARDDISK_drive-scsi0-0-0
BA_NAME=oracleasm/disks/DSK1
BA_TYPE=sd
BA_USER=oracle
BA_GROUP=oracle
BA_MODE=0620

Usage: /sbin/blkdevalias map <wwid>
ERROR: WWID "qux" is not mapped to any blkdevalias device
Usage: /sbin/blkdevalias map <wwid>
blkdevalias