packages: VirtualBox/mount.vdi - use parted instead of sfdisk, that can rea...

glen glen at pld-linux.org
Fri Dec 4 15:41:33 CET 2009


Author: glen                         Date: Fri Dec  4 14:41:33 2009 GMT
Module: packages                      Tag: HEAD
---- Log message:
- use parted instead of sfdisk, that can read gpt partition table

---- Files affected:
packages/VirtualBox:
   mount.vdi (1.5 -> 1.6) 

---- Diffs:

================================================================
Index: packages/VirtualBox/mount.vdi
diff -u packages/VirtualBox/mount.vdi:1.5 packages/VirtualBox/mount.vdi:1.6
--- packages/VirtualBox/mount.vdi:1.5	Fri Dec  4 15:17:20 2009
+++ packages/VirtualBox/mount.vdi	Fri Dec  4 15:41:27 2009
@@ -27,7 +27,7 @@
 # Commands
 LOSETUP=/sbin/losetup
 MOUNT=/bin/mount
-SFDISK=/sbin/sfdisk
+PARTED=/usr/sbin/parted
 SED=/bin/sed
 
 PROGRAM=${0##*/}
@@ -140,33 +140,15 @@
 dskoff=8704
 
 # find free loop device. XXX race possible
-imgdev=$($LOSETUP -f)
+imgdev=$($LOSETUP -f) || exit 1
 $LOSETUP $imgdev -o $dskoff "$DEVICE"
-# http://vserver.13thfloor.at/Stuff/QEMU/hdloop.sh
-sfd=$($SFDISK -dump $imgdev 2>/dev/null | $SED -n '
-	/:/ s/[a-zA-Z]*=\ *\([0-9a-f]*\)\(,\|$\)/\1/g;
-	T;  s/^.*:\ //; p' | tr ' ' '.')
-$LOSETUP -d $imgdev
-
-getoffset() {
-	pstart=$1
-	psize=$2
-
-	blksize=512
-	offset=$((pstart*blksize))
-	size=$((psize*blksize))
-	echo $((offset+dskoff))
-}
-
-p=1
-for a in $sfd; do
-	if [ "$p" = "$PARTITION" ]; then
-		OFFSET=$(getoffset $(echo "$a" | tr '.' ' '))
-	fi
-	x=$((p++))
-done
+dump=$($PARTED -s -m $imgdev unit B print)
+$LOSETUP -d $imgdev || exit 1
+
+partoff=$(echo "$dump" | $SED -ne "s/^$PARTITION:"'\([0-9]*\)B:.*/\1/p')
+OFFSET=$((dskoff + partoff))
 
-if [ -z "$OFFSET" ]; then
+if [ -z "$partoff" -o -z "$OFFSET" ]; then
 	echo >&2 "$PROGRAM: couldn't figure out offset, perhaps out of range?"
 	exit 1
 fi
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/VirtualBox/mount.vdi?r1=1.5&r2=1.6&f=u



More information about the pld-cvs-commit mailing list