Add device refresh capability to scandisks command
authorBryn M. Reeves <bmr@redhat.com>
Tue, 22 Jan 2013 12:47:39 +0000 (12:47 +0000)
committerBryn M. Reeves <bmr@redhat.com>
Tue, 22 Jan 2013 12:47:39 +0000 (12:47 +0000)
When issued with '-r' the scandisk command will now request change
uevents for all discovered devices. This will cause the latest
configuration parameters to be applied including device name,
symlink directory and ownership/permissions.

This may be used after manually editing the configuration or
mapping files to update the system to the current configuration.

blkdevalias

index e701004..6b23bed 100755 (executable)
@@ -423,9 +423,21 @@ ba_querydisk () {
 }
 
 ba_scandisks () {
-    local _DEV _TARGET
+    local _DEV _TARGET _REFRESH
+    echo $1
+    if [ "x$1" == "x-r" ]; then
+        _REFRESH="yes"
+    else
+        _REFRESH="no"
+    fi
+    _debug "ba_scandisks: device refresh requested: $_REFRESH"
     for _DEV in /dev/$BA_DEV_PATH/*; do
         _TARGET=$(readlink $_DEV)
+        # perform refresh on pre-canonicalised device path
+        if [ "$_REFRESH" == "yes" ]; then
+            _debug "ba_scandisks: refreshing device at $_TARGET"
+            ba_refresh_device $_TARGET
+        fi
         if [[ $_TARGET == *dm-* ]]; then
             _TARGET=$($BA_SUDO $BA_DMSETUP info \
                 --noheadings -c /dev/$(basename $_TARGET) -o name)
@@ -485,7 +497,7 @@ case "$1" in
         ba_querydisk $2 $3
         ;;
     scan*)
-        ba_scandisks
+        ba_scandisks $2
         ;;
     map)
         ba_map $2