Subject: NetBSD-specific GPT partition types
To: None <tech-userlevel@netbsd.org>
From: Jeff Rizzo <riz@tastylime.net>
List: tech-userlevel
Date: 12/26/2007 16:21:03
This is a multi-part message in MIME format.
--------------000500010005040300030905
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit

This is a patch to add some netbsd-specific types for use by gpt(8) -
with the attached patch, I was able to configure an lfs on raidframe,
with wedges as the components - and all labelled with GPT.    I've also
got another patch (not included here so as to not muddy the waters)
which add a "-g" flag to "gpt show" to display partition guids - it also
displays the disk guid.

If nobody has any serious objection, I'd like to commit this in the next
couple days.  It's not particularly intrusive - I think we can wait for
some of the bigger ideas that were raised in the other thread to be a
little more fully fleshed out - but I think this is useful in the
meanwhile, and doesn't conflict with any of those plans.

+j



--------------000500010005040300030905
Content-Type: text/plain; x-mac-type="0"; x-mac-creator="0";
 name="gpt.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="gpt.diff"

? sbin/gpt/.gdbinit
? sbin/gpt/gpt
? sbin/gpt/gpt.cat8
Index: sys/sys/disklabel_gpt.h
===================================================================
RCS file: /cvsroot/src/sys/sys/disklabel_gpt.h,v
retrieving revision 1.3
diff -u -r1.3 disklabel_gpt.h
--- sys/sys/disklabel_gpt.h	13 Aug 2006 15:31:21 -0000	1.3
+++ sys/sys/disklabel_gpt.h	26 Dec 2007 20:43:56 -0000
@@ -100,6 +100,19 @@
 /*
  * Partition types defined by other operating systems.
  */
+#define	GPT_ENT_TYPE_NETBSD_SWAP	\
+	{0x49f48d32,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+#define	GPT_ENT_TYPE_NETBSD_UFS		\
+	{0x49f48d5a,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+#define	GPT_ENT_TYPE_NETBSD_LFS		\
+	{0x49f48d82,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+#define	GPT_ENT_TYPE_NETBSD_RAIDFRAME	\
+	{0x49f48daa,0xb10e,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+#define	GPT_ENT_TYPE_NETBSD_CCD	\
+	{0x2db519c4,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+#define	GPT_ENT_TYPE_NETBSD_CGD	\
+	{0x2db519ec,0xb10f,0x11dc,0xb9,0x9b,{0x00,0x19,0xd1,0x87,0x96,0x48}}
+
 #define	GPT_ENT_TYPE_FREEBSD		\
 	{0x516e7cb4,0x6ecf,0x11d6,0x8f,0xf8,{0x00,0x02,0x2d,0x09,0x71,0x2b}}
 #define	GPT_ENT_TYPE_FREEBSD_SWAP	\
Index: sys/sys/disk.h
===================================================================
RCS file: /cvsroot/src/sys/sys/disk.h,v
retrieving revision 1.46
diff -u -r1.46 disk.h
--- sys/sys/disk.h	8 Oct 2007 16:41:15 -0000	1.46
+++ sys/sys/disk.h	26 Dec 2007 20:43:56 -0000
@@ -234,6 +234,7 @@
 #define	DKW_PTYPE_CCD		"ccd"
 #define	DKW_PTYPE_APPLEUFS	"appleufs"
 #define	DKW_PTYPE_NTFS		"ntfs"
+#define	DKW_PTYPE_CGD		"cgd"
 
 /*
  * Disk geometry dictionary.
Index: sbin/gpt/add.c
===================================================================
RCS file: /cvsroot/src/sbin/gpt/add.c,v
retrieving revision 1.5
diff -u -r1.5 add.c
--- sbin/gpt/add.c	18 Dec 2007 21:46:45 -0000	1.5
+++ sbin/gpt/add.c	26 Dec 2007 20:43:56 -0000
@@ -215,7 +215,7 @@
 
 	/* Create UFS partitions by default. */
 	if (uuid_is_nil(&type, NULL)) {
-		uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+		uuid_t ufs = GPT_ENT_TYPE_NETBSD_UFS;
 		type = ufs;
 	}
 
Index: sbin/gpt/gpt.c
===================================================================
RCS file: /cvsroot/src/sbin/gpt/gpt.c,v
retrieving revision 1.6
diff -u -r1.6 gpt.c
--- sbin/gpt/gpt.c	19 Dec 2007 05:48:33 -0000	1.6
+++ sbin/gpt/gpt.c	26 Dec 2007 20:43:57 -0000
@@ -295,22 +295,33 @@
 		}
 		break;
 	case 'l':
-		if (strcmp(s, "linux") == 0) {
+		if (strcmp(s, "lfs") == 0) {
+			uuid_t lfs = GPT_ENT_TYPE_NETBSD_LFS;
+			*uuid = lfs;
+			return (0);
+		} else if (strcmp(s, "linux") == 0) {
 			uuid_t lnx = GPT_ENT_TYPE_MS_BASIC_DATA;
 			*uuid = lnx;
 			return (0);
 		}
 		break;
+	case 'r':
+		if (strcmp(s, "raid") == 0) {
+			uuid_t raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
+			*uuid = raid;
+			return (0);
+		}
+		break;
 	case 's':
 		if (strcmp(s, "swap") == 0) {
-			uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP;
+			uuid_t sw = GPT_ENT_TYPE_NETBSD_SWAP;
 			*uuid = sw;
 			return (0);
 		}
 		break;
 	case 'u':
 		if (strcmp(s, "ufs") == 0) {
-			uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
+			uuid_t ufs = GPT_ENT_TYPE_NETBSD_UFS;
 			*uuid = ufs;
 			return (0);
 		}
Index: sbin/gpt/show.c
===================================================================
RCS file: /cvsroot/src/sbin/gpt/show.c,v
retrieving revision 1.3
diff -u -r1.3 show.c
--- sbin/gpt/show.c	18 Dec 2007 21:46:47 -0000	1.3
+++ sbin/gpt/show.c	26 Dec 2007 20:43:57 -0000
@@ -70,6 +70,10 @@
 	static uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
 	static uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
 	static uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
+	static uuid_t nb_swap = GPT_ENT_TYPE_NETBSD_SWAP;
+	static uuid_t nb_ufs = GPT_ENT_TYPE_NETBSD_UFS;
+	static uuid_t nb_lfs = GPT_ENT_TYPE_NETBSD_LFS;
+	static uuid_t nb_raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
 	static char buf[80];
 	char *s;
 
@@ -78,6 +82,14 @@
 
 	if (uuid_equal(t, &efi_slice, NULL))
 		return ("EFI System");
+	if (uuid_equal(t, &nb_swap, NULL))
+		return ("NetBSD swap");
+	if (uuid_equal(t, &nb_ufs, NULL))
+		return ("NetBSD UFS/UFS2");
+	if (uuid_equal(t, &nb_lfs, NULL))
+		return ("NetBSD LFS");
+	if (uuid_equal(t, &nb_raid, NULL))
+		return ("NetBSD RAIDFrame component");
 	if (uuid_equal(t, &swap, NULL))
 		return ("FreeBSD swap");
 	if (uuid_equal(t, &ufs, NULL))
Index: sys/dev/dkwedge/dkwedge_gpt.c
===================================================================
RCS file: /cvsroot/src/sys/dev/dkwedge/dkwedge_gpt.c,v
retrieving revision 1.6
diff -u -r1.6 dkwedge_gpt.c
--- sys/dev/dkwedge/dkwedge_gpt.c	4 Mar 2007 06:01:45 -0000	1.6
+++ sys/dev/dkwedge/dkwedge_gpt.c	26 Dec 2007 20:43:57 -0000
@@ -62,8 +62,14 @@
 #if 0
 	{ GPT_ENT_TYPE_FREEBSD,		??? },
 #endif
-	{ GPT_ENT_TYPE_FREEBSD_SWAP,	"swap" },	/* XXX for now */
-	{ GPT_ENT_TYPE_FREEBSD_UFS,	"ffs" },	/* XXX for now */
+	{ GPT_ENT_TYPE_NETBSD_SWAP,		DKW_PTYPE_SWAP },
+	{ GPT_ENT_TYPE_FREEBSD_SWAP,		DKW_PTYPE_SWAP },
+	{ GPT_ENT_TYPE_NETBSD_UFS,		DKW_PTYPE_FFS },
+	{ GPT_ENT_TYPE_FREEBSD_UFS,		DKW_PTYPE_FFS },
+	{ GPT_ENT_TYPE_NETBSD_LFS,		DKW_PTYPE_LFS },
+	{ GPT_ENT_TYPE_NETBSD_RAIDFRAME,	DKW_PTYPE_RAIDFRAME },
+	{ GPT_ENT_TYPE_NETBSD_CCD,		DKW_PTYPE_CCD },
+	{ GPT_ENT_TYPE_NETBSD_CGD,		DKW_PTYPE_CGD },
 
 	/* XXX What about the MS and Linux types? */
 

--------------000500010005040300030905--