Fix ba_map regression
authorBryn M. Reeves <bmr@redhat.com>
Mon, 21 Jan 2013 14:16:37 +0000 (14:16 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Mon, 21 Jan 2013 14:16:37 +0000 (14:16 +0000)
commit1531d897223b869e8f3ce1784b4fcff1aedae7e9
tree59ce29c54aa6e92115e8f6b92e71aaa274e9dbf7
parentb5fa9d9d5e403787bcbb938090665eab730df312
Fix ba_map regression

The local variable fixes introduced a regression in device mapping
preventing any aliases from being linked by udev.

Fix this by correcting local variable name usage and dmsetup
invocation.

This patch also improved debug logging in these functions to make
debugging future problems easier.

Note that the map command depends on a udev-like environment and
this must be supplied manually if testing outside of the context
of udev rule processing, for e.g.:

  [root@rhel6-vm1 ~]# ID_BUS=scsi DEVNAME=sda BA_DEBUG=yes \
     /sbin/blkdevalias map 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0
  ba_map: 0QEMU_QEMU_HARDDISK_drive-scsi0-0-0 -> DSK1
  ba_get_partnum: sda
  calling /sbin/dmsetup info sda
  ba_get_partnum: non-dm device sda NUM=
  ba_map: WWID=0QEMU_QEMU_HARDDISK_drive-scsi0-0-0 PART=0 TYPE=sd
  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=0660

  [root@rhel6-vm1 ~]# DM_NAME=mpathc DEVNAME=dm-1 \
     /sbin/blkdevalias map 0QEMU_QEMU_HARDDISK_drive-scsi0-0-2
  BA_WWID=0QEMU_QEMU_HARDDISK_drive-scsi0-0-2
  BA_NAME=oracleasm/disks/DSK3
  BA_TYPE=mpath
  BA_USER=oracle
  BA_GROUP=oracle
  BA_MODE=0660
blkdevalias