Partitioned device fixes
authorBryn M. Reeves <bmr@redhat.com>
Tue, 22 Jan 2013 16:52:50 +0000 (16:52 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Tue, 22 Jan 2013 16:52:50 +0000 (16:52 +0000)
Fix device refresh to properly handle partitioned devices and
ensure that ba_deletedisk() generates a target device name and
not an alias path.

blkdevalias

index 7b81f08..818cf37 100755 (executable)
@@ -245,12 +245,16 @@ ba_refresh_alias () {
 
 # ba_refresh_device <dev path>
 ba_refresh_device () {
-    local _DEVPATH _DEVNAME _LINKDEST
+    local _DEVPATH _DEVNAME _LINKDEST _PARTNUM
     _DEVPATH="$1"
     _debug "ba_refresh_device: refreshing device at path $_DEVPATH"
     _LINKDEST=$($BA_READLINK $_DEVPATH)
     if [ "$?" != 0 ]; then
         _DEVNAME=$($BA_BASENAME $_DEVPATH | $BA_SED 's/p\+[1-9]*$//')
+        _PARTNUM=$(ba_get_partnum $_DEVNAME)
+        if [ "$_PARTNUM" != "0" ]; then
+            _DEVNAME="$(echo ${_DEVNAME} | sed 's/[0-9]*$//')/$_DEVNAME"
+        fi
         _debug "ba_refresh_device: non-symlinked dev at " \
             "$_DEVPATH has name $_DEVNAME"
     else
@@ -385,12 +389,13 @@ ba_deletedisk () {
     echo -n "Removing wwid map disk \"$_ALIAS\":"
     # generate device path for refresh call
     _DEVPATH="/dev/$BA_DEV_PATH/${WWIDMAP[$_WWID]}"
+    _TARGET=$(readlink -f $_DEVPATH)
     ba_del_wwid_mapping $_WWID \
     && if [ "$BA_DEBUG" != "yes" ]; then
         echo "                                  [  OK  ]"
     fi
     ba_store_wwid_map
-    ba_refresh_device $_DEVPATH
+    ba_refresh_device $_TARGET
 }
 
 # ba_list_disks: