[Rear-users] SF.net SVN: rear:[743] trunk/usr/share/rear

jhoekx at users.sourceforge.net jhoekx at users.sourceforge.net
Wed Nov 23 16:32:34 CET 2011


Revision: 743
          http://rear.svn.sourceforge.net/rear/?rev=743&view=rev
Author:   jhoekx
Date:     2011-11-23 15:32:34 +0000 (Wed, 23 Nov 2011)
Log Message:
-----------
layout: detect partitions on software RAID and multipath devices and include them in the dependency information.

Code to actually restore the partitions is not included.

Modified Paths:
--------------
    trunk/usr/share/rear/layout/save/GNU/Linux/21_raid_layout.sh
    trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh
    trunk/usr/share/rear/layout/save/default/33_remove_exclusions.sh
    trunk/usr/share/rear/lib/layout-functions.sh

Modified: trunk/usr/share/rear/layout/save/GNU/Linux/21_raid_layout.sh
===================================================================
--- trunk/usr/share/rear/layout/save/GNU/Linux/21_raid_layout.sh	2011-11-23 15:27:14 UTC (rev 742)
+++ trunk/usr/share/rear/layout/save/GNU/Linux/21_raid_layout.sh	2011-11-23 15:32:34 UTC (rev 743)
@@ -8,6 +8,12 @@
                 continue
             fi
 
+            ### Get the actual device node
+            if [[ -h $device ]] ; then
+                name=${device##*/}
+                device=$(readlink -f $device)
+            fi
+
             # We use the detailed mdadm output quite alot
             mdadm --misc --detail $device > $TMP_DIR/mdraid
 
@@ -72,7 +78,15 @@
                 chunksize=""
             fi
 
-            echo "raid ${device}${level}${ndevices}${uuid}${sparedevices}${layout}${chunksize}${devices}"
+            if [[ "$name" ]] ; then
+                name=" name=$name"
+            else
+                name=""
+            fi
+
+            echo "raid ${device}${level}${ndevices}${uuid}${name}${sparedevices}${layout}${chunksize}${devices}"
+
+            extract_partitions "$device"
         done < <(mdadm --detail --scan --config=partitions)
     ) >> $DISKLAYOUT_FILE
 fi

Modified: trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh
===================================================================
--- trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh	2011-11-23 15:27:14 UTC (rev 742)
+++ trunk/usr/share/rear/layout/save/GNU/Linux/28_multipath_layout.sh	2011-11-23 15:32:34 UTC (rev 743)
@@ -20,6 +20,8 @@
     done
 
     echo "multipath /dev/mapper/$dm_name ${slaves%,}" >> $DISKLAYOUT_FILE
+
+    extract_partitions "$dev_name"
 done < <( dmsetup ls --target multipath )
 
 if grep -q ^multipath $DISKLAYOUT_FILE ; then

Modified: trunk/usr/share/rear/layout/save/default/33_remove_exclusions.sh
===================================================================
--- trunk/usr/share/rear/layout/save/default/33_remove_exclusions.sh	2011-11-23 15:27:14 UTC (rev 742)
+++ trunk/usr/share/rear/layout/save/default/33_remove_exclusions.sh	2011-11-23 15:32:34 UTC (rev 743)
@@ -19,10 +19,8 @@
 while read done name type junk ; do
     case $type in
         part)
-            name=$( echo "$name" | sed -r 's/(.*)[0-9]$/\1/')
-            if [ "${name/cciss/}" != "$name" ] ; then
-                name=${name%p}
-            fi
+            ### find the immediate parent
+            name=$(grep "^$name " $LAYOUT_DEPS | cut -d " " -f 2)
             remove_component $type $name
             ;;
         lvmdev)

Modified: trunk/usr/share/rear/lib/layout-functions.sh
===================================================================
--- trunk/usr/share/rear/lib/layout-functions.sh	2011-11-23 15:27:14 UTC (rev 742)
+++ trunk/usr/share/rear/lib/layout-functions.sh	2011-11-23 15:32:34 UTC (rev 743)
@@ -365,17 +365,26 @@
     local name=${1#/dev/}
     name=${name#/sys/block/}
 
-    if [ -e /sys/block/${name//\//!} ] ; then
+    if [[ -e /sys/block/${name//\//!} ]] ; then
         echo "${name//\//!}"
         return 0
     fi
 
+    ### Follow symlinks
+    if [[ -h /dev/$name ]] ; then
+        local target=$(readlink -f /dev/$name)
+        if [[ -e /sys/block/${target#/dev/} ]] ; then
+            echo "${target#/dev/}"
+            return 0
+        fi
+    fi
+
     # accomodate for mapper/test -> dm-? mapping
     local dev_number=$(dmsetup info -c --noheadings -o major,minor ${name##*/} 2>&8 )
-    if [ -n "$dev_number" ] ; then
+    if [[ "$dev_number" ]] ; then
         local dev_name sysfs_device
         for sysfs_device in /sys/block/*/dev ; do
-            if [ "$dev_number" = "$( < $sysfs_device)" ] ; then
+            if [[ "$dev_number" = "$( < $sysfs_device)" ]] ; then
                 dev_name=${sysfs_device#/sys/block/}
                 echo "${dev_name%/*}"
                 return 0

This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.





More information about the rear-users mailing list