Subject: more than 8 BSD slices for grub
To: None <pkgsrc-users@NetBSD.org>
From: Klaus Heinz <k.heinz.jul.sieben@kh-22.de>
List: pkgsrc-users
Date: 07/07/2007 13:34:05
--i7F3eY7HS/tUJxUd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

I have had those two patches for some time and noticed it during my update
of the pkgsrc tree, so here they are.

The patches do not change the behaviour of grub if built on non-NetBSD
platforms because I do no think the grub maintainers would accept
them[1], consequently my motivation to adapt them appropriately was
rather low.

Please review.

ciao
     Klaus

[1] according to how they dealt with jmmv's grub patches, which were
about real bugs instead of better functionality.

--i7F3eY7HS/tUJxUd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-ap

$NetBSD$

  Replace hard-coded constants by proper use of symbolic constants.

--- stage2/disk_io.c.orig	2004-05-23 18:35:24.000000000 +0200
+++ stage2/disk_io.c
@@ -404,7 +404,7 @@ sane_partition (void)
 	  || current_drive == cdrom_drive)
       && (current_partition & 0xFF) == 0xFF
       && ((current_partition & 0xFF00) == 0xFF00
-	  || (current_partition & 0xFF00) < 0x800)
+	  || (current_partition & 0xFF00) < (BSD_LABEL_NPARTS_MAX << 8))
       && ((current_partition >> 16) == 0xFF
 	  || (current_drive & 0x80)))
     return 1;
@@ -1061,13 +1061,13 @@ set_device (char *device)
 	      if (*device == ',')
 		device++;
 	      
-	      if (*device >= 'a' && *device <= 'h')
+	      if (*device >= 'a' && *device <= ('a' + BSD_LABEL_NPARTS_MAX - 1))
 		{
 		  current_partition = (((*(device++) - 'a') << 8)
 				       | (current_partition & 0xFF00FF));
 		}
 	    }
-	  else if (*device >= 'a' && *device <= 'h')
+	  else if (*device >= 'a' && *device <= ('a' + BSD_LABEL_NPARTS_MAX - 1))
 	    {
 	      part_choice ++;
 	      current_partition = ((*(device++) - 'a') << 8) | 0xFF00FF;

--i7F3eY7HS/tUJxUd
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename=patch-aq

$NetBSD$

  Cannot use MAXPARTITIONS from sys/disklabel.h here :-/, so we use
  common maximum number of partitions for NetBSD.

--- stage2/pc_slice.h.orig	2003-07-09 13:45:53.000000000 +0200
+++ stage2/pc_slice.h
@@ -167,7 +167,11 @@
 #define BSD_LABEL_MAG_OFFSET 0
 #define BSD_LABEL_MAG2_OFFSET 132
 #define BSD_LABEL_NPARTS_OFFSET 138
-#define BSD_LABEL_NPARTS_MAX 8
+#if defined(__NetBSD__)
+#  define BSD_LABEL_NPARTS_MAX 16
+#else
+#  define BSD_LABEL_NPARTS_MAX 8
+#endif
 
 #define BSD_PART_OFFSET 148
 

--i7F3eY7HS/tUJxUd--