chiark / gitweb /
fixes from tests before big run
[chiark-utils.git] / backup / snap-common
index c12bc6dcbbbafae0949efde85e7b15f02fec84ff..f6e788ab975a566f1c5dcad9ce4b17297eea798e 100644 (file)
@@ -29,6 +29,27 @@ esac
 
 #---------- common functions
 
+lvmunmapperdevice () {
+       # turns device=/dev/mapper/... into /dev/<group>/<volume>
+       case "$device" in
+       /dev/mapper/*)
+               device="`printf '%s' "$device" | perl -pe '
+                       s,^/dev/mapper/,,;
+                       die if m,/,;
+                       s,\-\-,!,g;
+                       s,\-,/,g;
+                       s,\!,-,g;
+                       s,^,/dev/,;
+               '`"
+               ;;
+       esac
+}
+
+lvmdevice2vgroup () {
+       vgroup="${device#/dev/}"
+       vgroup="${vgroup%/*}"
+}
+
 lvmdropcore () {
        snmnt="$vardir/snap-mount"
        umount -v "$snmnt" || true
@@ -49,6 +70,7 @@ lvmdropcore () {
 }
 
 lvmextentscore1 () {
+       # vgroup must be set
        vgdisplay_out="$(really vgdisplay -c "$vgroup")"
        extents="$(printf "%s" "$vgdisplay_out" | awk -F: '{print $16}')"
        extsize="$(printf "%s" "$vgdisplay_out" | awk -F: '{print $13}')"
@@ -60,6 +82,7 @@ lvmextentscore2 () {
 }
 
 lvmcreatecore1 () {
+       # vgroup must be set
        lvpath="/dev/$vgroup/$lvm_lv"
        ln -s -- "$lvpath" "$vardir"/snap-device
        sync