palo: Fix partition detection and support big drives

The partition detection was broken on big drives. Use u64
addresses now, and print partition table like fdisk output.

Signed-off-by: Helge Deller <deller@gmx.de>
diff --git a/lib/common.h b/lib/common.h
index b46c350..62c1fed 100644
--- a/lib/common.h
+++ b/lib/common.h
@@ -134,9 +134,9 @@
 struct diskpartition
 {
     /* in honor of the MBR scheme, these are in 512-byte sectors */
-    unsigned start;
+    __u64 start;
     /* length == 0 means nothing's here */
-    unsigned length;
+    __u64 length;
     unsigned char id;
 };
 
diff --git a/lib/diskpart.c b/lib/diskpart.c
index 5fae1b9..999d8ed 100644
--- a/lib/diskpart.c
+++ b/lib/diskpart.c
@@ -29,7 +29,7 @@
     int i;
     int ex = -1;
     int extnum = 4;
-    unsigned offset;
+    __u64 offset;
 	
     /* seekread MBR */
     if (seekread(bootdev, (char *)&fb, sizeof fb, 0) == -1)
@@ -52,14 +52,14 @@
 	offset = mptab[ex].start;
 	while (extnum < maxparts)
 	{
-	    if (disk_2gb_limit && offset >= (2 * (GB / 512))) { /* weird () to quiet compiler */
-		printf("NOTE: Extended partition %d might be beyond reach of IPL\r\n",
-				extnum + 1);
+	    if (disk_2gb_limit && ((offset * 512) >> 31)) {
+		// printf("NOTE: Extended partition %d is beyond reach of IPL\r\n", extnum + 1);
+		break;
 	    }
 
 	    fb.dosmagic[0] = 0; // wipe dosmagic flag just to be on the safe side
-	    if (seekread(bootdev, (char *)&fb, sizeof fb, 512ULL * offset) == -1) {
-		printf("seekread(bootdev,..., 512 * 0x%x) failed!\n\r", offset);
+	    if (seekread(bootdev, (char *)&fb, sizeof fb, 512 * offset) < 0) {
+		// printf("seekread(bootdev,..., 512 * 0x%x) failed!\n\r", offset);
 		break;
 	    }
 	    if (fb.dosmagic[0] != 0x55 || fb.dosmagic[1] != 0xaa)
@@ -72,7 +72,7 @@
 	    mptab[extnum].length = __le32_to_cpu(ptab[0].nr_sects);
 	    mptab[extnum].id = ptab[0].sys_ind;
 
-	    offset = mptab[extnum].start + __le32_to_cpu(ptab[1].start_sect);
+	    offset += __le32_to_cpu(ptab[1].start_sect);
 
 	    extnum++;
 	    if (!is_extended(ptab[1].sys_ind))
@@ -88,15 +88,20 @@
 {
     int i;
     const int mbshift = 20 - 9;
+    const int gbshift = 30 - 9;
 
-    printf("Partition Start(MB) End(MB) Id Type\n\r");
+    printf("Partition    Start       End   Sectors   Size Id Type\n\r");
     for (i = 0; i < maxparts; i++)
     {
+	unsigned int gb = (mptab[i].length >> gbshift);
 	if (mptab[i].id != 0 && ! is_extended(mptab[i].id))
-	    printf("%-9x %8d %7d %3x %s\n\r",
+	    printf("%-8x %9lld %9lld %9lld %5d%c %02x %s\n\r",
 		i + 1,
-		1 + (mptab[i].start >> mbshift),
-		(mptab[i].start + mptab[i].length) >> mbshift,
+		mptab[i].start,
+		mptab[i].start + mptab[i].length - 1,
+		mptab[i].length,
+		gb ? : (unsigned) (mptab[i].length >> mbshift),
+		gb ? 'G' : 'M',
 		mptab[i].id,
 		mptab[i].id == LINUX_EXT2_PARTITION ? "ext2" :
 			(mptab[i].id == LINUX_SWAP_PARTITION ? "swap" :