Subject: port-macppc/10046: my disk partitions are not shown as 4.2BSD in disklabel(8)
To: None <gnats-bugs@gnats.netbsd.org>
From: SUNAGAWA Keiki <kei_sun@ba2.so-net.ne.jp>
List: netbsd-bugs
Date: 05/04/2000 12:32:12
>Number:         10046
>Category:       port-macppc
>Synopsis:       my disk partitions are not shown as 4.2BSD in disklabel(8)
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    port-macppc-maintainer
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Thu May 04 12:33:00 PDT 2000
>Closed-Date:
>Last-Modified:
>Originator:     SUNAGAWA Keiki
>Release:        -current as of 2000-05-04
>Organization:
	home
>Environment:
	
System: NetBSD azarin 1.4P NetBSD 1.4P (AZARIN) #84: Wed Dec 1 21:54:14 JST 1999 kei@azarin:/a/anoncvs/netbsd/src/sys/arch/macppc/compile/AZARIN macppc

>Description:
	It seems that Apple changed the value of disk partition type in recent
	version of their Drive Setup utility.  Some partition type are added,
	too.

	This PR also might be applicable to mac68k port, but I don't know if
	recent version of Drive Setup runs on m68k Macintoshes.

>How-To-Repeat:
	Make `A/UX root', `A/UX Swap', and `User file system' partitions with
	Drive Setup utility come with recent version of MacOS, install NetBSD
	onto it, and get its disklabel.

>Fix:
	Add some definition of partition type string and modify disksubr.c
	slightly to recognize new partition type value.

	After that, my /usr and /var partitions are shown as 4.2BSD fstype in
	disklabel(8) and /usr partition take wd0g.  I attached the diff of the
	result for the record.

# This is a shell archive.  Save it in a file, remove anything before
# this line, and then unpack it by entering "sh file".  Note, it may
# create directories; files and directories will be owned by you and
# have default permissions.
#
# This archive contains:
#
#	disklabel.diff
#
echo x - disklabel.diff
sed 's/^X//' >disklabel.diff << 'END-of-disklabel.diff'
XIndex: include/disklabel.h
X===================================================================
XRCS file: /a/rsync/netbsd.org/syssrc/sys/arch/macppc/include/disklabel.h,v
Xretrieving revision 1.4
Xdiff -u -r1.4 disklabel.h
X+++ disklabel.h	2000/05/02 08:43:09
X@@ -173,10 +173,13 @@
X #define PART_TYPE_DRIVER	"APPLE_DRIVER"
X #define PART_TYPE_DRIVER43	"APPLE_DRIVER43"
X #define PART_TYPE_DRIVERATA	"APPLE_DRIVER_ATA"
X+#define PART_TYPE_DRIVERIOKIT	"APPLE_DRIVER_IOKIT"
X+#define PART_TYPE_FREE		"APPLE_FREE"
X #define PART_TYPE_FWB_COMPONENT	"FWB DRIVER COMPONENTS"
X #define PART_TYPE_MAC		"APPLE_HFS"
X #define PART_TYPE_NETBSD	"NETBSD"
X #define PART_TYPE_PARTMAP	"APPLE_PARTITION_MAP"
X+#define PART_TYPE_PATCHES	"APPLE_PATCHES"
X #define PART_TYPE_SCRATCH	"APPLE_SCRATCH"
X #define PART_TYPE_UNIX		"APPLE_UNIX_SVR2"
X 
X@@ -196,11 +199,14 @@
X 	u_int32_t       bzbUMountTime;
X };
X 
X+/* Apple seems to change the meening of these values. */
X #define BZB_MAGIC	0xABADBABE
X #define BZB_TYPEFS	1
X #define BZB_TYPESWAP	3
X #define BZB_ROOTFS	0x8000
X+#define BZB_ROOTFS_NEW	0xc000
X #define BZB_USRFS	0x4000
X+#define BZB_USRFS_NEW	0x0004
X 
X #ifdef	_KERNEL
X struct disklabel;
XIndex: macppc/disksubr.c
X===================================================================
XRCS file: /a/rsync/netbsd.org/syssrc/sys/arch/macppc/macppc/disksubr.c,v
Xretrieving revision 1.7
Xdiff -u -r1.7 disksubr.c
X+++ disksubr.c	2000/05/02 08:45:50
X@@ -187,17 +187,21 @@
X 	if (strcmp(PART_TYPE_DRIVER, typestr) == 0 ||
X 	    strcmp(PART_TYPE_DRIVER43, typestr) == 0 ||
X 	    strcmp(PART_TYPE_DRIVERATA, typestr) == 0 ||
X+	    strcmp(PART_TYPE_DRIVERIOKIT, typestr) == 0 ||
X 	    strcmp(PART_TYPE_FWB_COMPONENT, typestr) == 0 ||
X-	    strcmp(PART_TYPE_PARTMAP, typestr) == 0)
X+	    strcmp(PART_TYPE_PARTMAP, typestr) == 0 ||
X+	    strcmp(PART_TYPE_PATCHES, typestr) == 0)
X 		type = 0;
X 	else if (strcmp(PART_TYPE_UNIX, typestr) == 0) {
X 		/* unix part, swap, root, usr */
X 		bzb = (struct blockzeroblock *)(&part->pmBootArgs);
X 		if (bzb->bzbMagic != BZB_MAGIC)
X 			type = 0;
X-		else if (bzb->bzbFlags & BZB_ROOTFS)
X+		else if (bzb->bzbFlags & BZB_ROOTFS ||
X+		    bzb->bzbFlags == BZB_ROOTFS_NEW)
X 			type = ROOT_PART;
X-		else if (bzb->bzbFlags & BZB_USRFS)
X+		else if (bzb->bzbFlags & BZB_USRFS ||
X+		    bzb->bzbFlags == BZB_USRFS_NEW)
X 			type = UFS_PART;
X 		else if (bzb->bzbType == BZB_TYPESWAP)
X 			type = SWAP_PART;
END-of-disklabel.diff
exit

*** disklabel.wd0.old	Fri May  5 04:00:48 2000
--- disklabel.wd0.new	Fri May  5 04:00:47 2000
***************
*** 17,30 ****
  track-to-track seek: 0	# milliseconds
  drivedata: 0 
  
! 9 partitions:
  #        size   offset     fstype   [fsize bsize   cpg]
    a:   204800   820544     4.2BSD        0     0     0   # (Cyl.  814*- 1017*)
    b:   204800  1025344       swap                        # (Cyl. 1017*- 1220*)
    c:  6357456        0     unused        0     0         # (Cyl.    0 - 6306)
!   d:      512      320    unknown                        # (Cyl.    0*- 0*)
!   e:      512      832    unknown                        # (Cyl.    0*- 1*)
!   f:   819200     1344        HFS                        # (Cyl.    1*- 814*)
!   g:   613510  1230144    unknown                        # (Cyl. 1220*- 1829*)
!   h:  4513792  1843654    unknown                        # (Cyl. 1829*- 6306*)
!   i:       10  6357446    unknown                        # (Cyl. 6306*- 6306)
--- 17,28 ----
  track-to-track seek: 0	# milliseconds
  drivedata: 0 
  
! 7 partitions:
  #        size   offset     fstype   [fsize bsize   cpg]
    a:   204800   820544     4.2BSD        0     0     0   # (Cyl.  814*- 1017*)
    b:   204800  1025344       swap                        # (Cyl. 1017*- 1220*)
    c:  6357456        0     unused        0     0         # (Cyl.    0 - 6306)
!   d:   819200     1344        HFS                        # (Cyl.    1*- 814*)
!   e:  4513792  1843654     4.2BSD        0     0     0   # (Cyl. 1829*- 6306*)
!   f:       10  6357446    unknown                        # (Cyl. 6306*- 6306)
!   g:   613510  1230144     4.2BSD        0     0     0   # (Cyl. 1220*- 1829*)
>Release-Note:
>Audit-Trail:
>Unformatted: