Subject: port-hpcarm/18256: hpcarm MAXPATIONS bump request
To: None <gnats-bugs@gnats.netbsd.org>
From: None <sengel@melshake.com>
List: netbsd-bugs
Date: 09/10/2002 09:16:00
>Number:         18256
>Category:       port-hpcarm
>Synopsis:       hpcarm MAXPATIONS bump request
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    port-hpcarm-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Tue Sep 10 09:17:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Stephane Engel
>Release:        current (1.6G as 20020904)
>Organization:
>Environment:
NetBSD minimi 1.6G NetBSD 1.6G (MINIMI) #0: Sun Sep 8 22:45:26 UTC 2002 root@minimi:/BSD/NetBSD/src/sys/arch/hpcarm/compile/MINIMI hpcarm
>Description:
Try to moot a removable disk with a disklabel made on a platform wich as MAXPARTITIONS = 16 (like i386).
It will failled with a disk label corrupted.

Also, see my mail : 
http://mail-index.netbsd.org/port-hpcarm/2002/09/05/0001.html
>How-To-Repeat:
See "Full Description".
>Fix:
bump MAXPARTITIONS to 16.
the following patch work fine with my Jornada 720.


--- ./sys/arch/hpcarm/include/disklabel.h.orig	Sat Sep  7 00:19:01 2002
+++ ./sys/arch/hpcarm/include/disklabel.h	Sat Sep  7 00:33:33 2002
@@ -34,10 +34,24 @@
 #define _MACHINE_DISKLABEL_H_
 
 #define	LABELSECTOR	1		/* sector containing label */
 #define	LABELOFFSET	0		/* offset of label in sector */
-#define	MAXPARTITIONS	8		/* number of partitions */
+#define	MAXPARTITIONS		16	/* number of partitions */
+#define	OLDMAXPARTITIONS	8	/* number of partitions before 1.7 */
 #define	RAW_PART	3		/* raw partition: XX?d (XXX) */
+
+/*
+ * We use the highest bit of the minor number for the partition number.
+ * This maintains backward compatibility with device nodes created before
+ * MAXPARTITIONS was increased.
+ */
+#define __HPCARM_MAXDISKS	((1 << 20) / MAXPARTITIONS)
+#define DISKUNIT(dev)	((minor(dev) / OLDMAXPARTITIONS) % __HPCARM_MAXDISKS)
+#define DISKPART(dev)	((minor(dev) % OLDMAXPARTITIONS) + \
+    ((minor(dev) / (__HPCARM_MAXDISKS * OLDMAXPARTITIONS)) * OLDMAXPARTITIONS))
+#define	DISKMINOR(unit, part) \
+    (((unit) * OLDMAXPARTITIONS) + ((part) % OLDMAXPARTITIONS) + \
+     ((part) / OLDMAXPARTITIONS) * (__HPCARM_MAXDISKS * OLDMAXPARTITIONS))
 
 /* Pull in MBR partition definitions. */
 #include <sys/disklabel_mbr.h>
 
--- ./sys/arch/hpcarm/include/types.h.orig	Sat Sep  7 08:45:36 2002
+++ ./sys/arch/hpcarm/include/types.h	Sat Sep  7 08:43:57 2002
@@ -7,6 +7,7 @@
 
 #define	__HAVE_DEVICE_REGISTER
 #define	__HAVE_NWSCONS
 #define	__HAVE_GENERIC_SOFT_INTERRUPTS
+#define	__HAVE_OLD_DISKLABEL
 
 #endif

>Release-Note:
>Audit-Trail:
>Unformatted: