Module Name:    src
Committed By:   christos
Date:           Mon Jan 16 18:47:58 UTC 2012

Modified Files:
        src/common/lib/libutil: getfstypename.c
        src/sys/arch/i386/stand/lib: biosdisk.c
        src/sys/lib/libkern: xlat_mbr_fstype.c
        src/sys/sys: disk.h disklabel.h

Log Message:
PR/45796: Evgeniy Ivanov minixfs3 support.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/common/lib/libutil/getfstypename.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.7 -r1.8 src/sys/lib/libkern/xlat_mbr_fstype.c
cvs rdiff -u -r1.55 -r1.56 src/sys/sys/disk.h
cvs rdiff -u -r1.111 -r1.112 src/sys/sys/disklabel.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/common/lib/libutil/getfstypename.c
diff -u src/common/lib/libutil/getfstypename.c:1.5 src/common/lib/libutil/getfstypename.c:1.6
--- src/common/lib/libutil/getfstypename.c:1.5	Mon Nov 14 11:21:44 2011
+++ src/common/lib/libutil/getfstypename.c	Mon Jan 16 13:47:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: getfstypename.c,v 1.5 2011/11/14 16:21:44 christos Exp $	*/
+/*	$NetBSD: getfstypename.c,v 1.6 2012/01/16 18:47:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2011 The NetBSD Foundation, Inc.
@@ -39,10 +39,10 @@
 # include <sys/cdefs.h>
 # ifndef _KERNEL
 #  if !defined(lint)
-__RCSID("$NetBSD: getfstypename.c,v 1.5 2011/11/14 16:21:44 christos Exp $");
+__RCSID("$NetBSD: getfstypename.c,v 1.6 2012/01/16 18:47:57 christos Exp $");
 #  endif
 # else
-__KERNEL_RCSID(0, "$NetBSD: getfstypename.c,v 1.5 2011/11/14 16:21:44 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: getfstypename.c,v 1.6 2012/01/16 18:47:57 christos Exp $");
 # endif /* _KERNEL */
 
 # define FSTYPE_ENUMNAME fstype_enum
@@ -121,6 +121,8 @@ getfstypename(int fstype)
 		return DKW_PTYPE_CGD;
 	case FSMAXTYPES:
 		return DKW_PTYPE_UNKNOWN;
+	case FS_MINIXFS3:
+		return DKW_PTYPE_MINIXFS3;
 	}
 	/* Stupid gcc, should know it is impossible to get here */
 	return DKW_PTYPE_UNKNOWN;

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.39 src/sys/arch/i386/stand/lib/biosdisk.c:1.40
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.39	Wed Sep 21 04:57:12 2011
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Mon Jan 16 13:47:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.39 2011/09/21 08:57:12 gsutre Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.40 2012/01/16 18:47:57 christos Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -404,6 +404,40 @@ check_label(struct biosdisk *d, daddr_t 
 }
 
 static int
+read_minix_subp(struct biosdisk *d, struct disklabel* dflt_lbl,
+			int this_ext, daddr_t sector)
+{
+	struct mbr_partition mbr[MBR_PART_COUNT];
+	int i;
+	int typ;
+	struct partition *p;
+
+	if (readsects(&d->ll, sector, 1, d->buf, 0)) {
+#ifdef DISK_DEBUG
+		printf("Error reading MFS sector %d\n", sector);
+#endif
+		return EIO;
+	}
+	if ((uint8_t)d->buf[510] != 0x55 || (uint8_t)d->buf[511] != 0xAA) {
+		return -1;
+	}
+	memcpy(&mbr, ((struct mbr_sector *)d->buf)->mbr_parts, sizeof(mbr));
+	for (i = 0; i < MBR_PART_COUNT; i++) {
+		typ = mbr[i].mbrp_type;
+		if (typ == 0)
+			continue;
+		sector = this_ext + mbr[i].mbrp_start;
+		if (dflt_lbl->d_npartitions >= MAXPARTITIONS)
+			continue;
+		p = &dflt_lbl->d_partitions[dflt_lbl->d_npartitions++];
+		p->p_offset = sector;
+		p->p_size = mbr[i].mbrp_size;
+		p->p_fstype = xlat_mbr_fstype(typ);
+	}
+	return 0;
+}
+
+static int
 read_label(struct biosdisk *d)
 {
 	struct disklabel dflt_lbl;
@@ -452,6 +486,13 @@ read_label(struct biosdisk *d)
 #ifdef DISK_DEBUG
 			printf("ptn type %d in sector %d\n", typ, sector);
 #endif
+                        if (typ == MBR_PTYPE_MINIX_14B) {
+				if (!read_minix_subp(d, &dflt_lbl,
+						   this_ext, sector)) {
+					/* Don't add "container" partition */
+					continue;
+				}
+			}
 			if (typ == MBR_PTYPE_NETBSD) {
 				error = check_label(d, sector);
 				if (error >= 0)

Index: src/sys/lib/libkern/xlat_mbr_fstype.c
diff -u src/sys/lib/libkern/xlat_mbr_fstype.c:1.7 src/sys/lib/libkern/xlat_mbr_fstype.c:1.8
--- src/sys/lib/libkern/xlat_mbr_fstype.c:1.7	Mon Apr 28 16:24:06 2008
+++ src/sys/lib/libkern/xlat_mbr_fstype.c	Mon Jan 16 13:47:57 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: xlat_mbr_fstype.c,v 1.7 2008/04/28 20:24:06 martin Exp $	*/
+/*	$NetBSD: xlat_mbr_fstype.c,v 1.8 2012/01/16 18:47:57 christos Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0,"$NetBSD: xlat_mbr_fstype.c,v 1.7 2008/04/28 20:24:06 martin Exp $");
+__KERNEL_RCSID(0,"$NetBSD: xlat_mbr_fstype.c,v 1.8 2012/01/16 18:47:57 christos Exp $");
 
 
 #include <sys/disklabel.h>
@@ -55,6 +55,7 @@ xlat_mbr_fstype(int mbr_type)
 		{ MBR_PTYPE_LNXSWAP,	FS_SWAP },
 		{ MBR_PTYPE_NETBSD,	FS_BSDFFS },
 		{ MBR_PTYPE_NTFS,	FS_NTFS },
+		{ MBR_PTYPE_MINIX_14B,	FS_MINIXFS3 },
 		{ 0,			FS_OTHER }
 	};
 	const struct ptn_types *pt;

Index: src/sys/sys/disk.h
diff -u src/sys/sys/disk.h:1.55 src/sys/sys/disk.h:1.56
--- src/sys/sys/disk.h:1.55	Sun Nov 13 17:07:00 2011
+++ src/sys/sys/disk.h	Mon Jan 16 13:47:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: disk.h,v 1.55 2011/11/13 22:07:00 christos Exp $	*/
+/*	$NetBSD: disk.h,v 1.56 2012/01/16 18:47:58 christos Exp $	*/
 
 /*-
  * Copyright (c) 1996, 1997, 2004 The NetBSD Foundation, Inc.
@@ -245,6 +245,7 @@ __link_set_add_data(dkwedge_methods, nam
 #define	DKW_PTYPE_EFS		"efs"
 #define	DKW_PTYPE_NILFS		"nilfs"
 #define	DKW_PTYPE_CGD		"cgd"
+#define	DKW_PTYPE_MINIXFS3	"minixfs3"
 
 /*
  * Disk geometry dictionary.

Index: src/sys/sys/disklabel.h
diff -u src/sys/sys/disklabel.h:1.111 src/sys/sys/disklabel.h:1.112
--- src/sys/sys/disklabel.h:1.111	Sun Nov 13 17:19:09 2011
+++ src/sys/sys/disklabel.h	Mon Jan 16 13:47:58 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: disklabel.h,v 1.111 2011/11/13 22:19:09 christos Exp $	*/
+/*	$NetBSD: disklabel.h,v 1.112 2012/01/16 18:47:58 christos Exp $	*/
 
 /*
  * Copyright (c) 1987, 1988, 1993
@@ -357,7 +357,8 @@ x(UDF,     24, "UDF",        NULL,   "ud
 x(SYSVBFS, 25, "SysVBFS",    NULL,  "sysvbfs")/* System V boot file system */ \
 x(EFS,     26, "EFS",        NULL,   "efs")   /* SGI's Extent Filesystem */ \
 x(NILFS,   27, "NiLFS",      NULL,   "nilfs") /* NTT's NiLFS(2) */ \
-x(CGD,     28, "cgd",	     NULL,   NULL)    /* Cryptographic disk */
+x(CGD,     28, "cgd",	     NULL,   NULL)    /* Cryptographic disk */ \
+x(MINIXFS3,29, "MINIX FSv3", NULL,   NULL)    /* MINIX file system v3 */
 
 
 #ifndef _LOCORE

Reply via email to