Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 5 Mar 2012 04:51:22 +0000 (UTC)
From:      "Andrey V. Elsukov" <ae@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r232535 - stable/9/sys/geom/part
Message-ID:  <201203050451.q254pMab067441@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: ae
Date: Mon Mar  5 04:51:22 2012
New Revision: 232535
URL: http://svn.freebsd.org/changeset/base/232535

Log:
  MFC r231754:
    Add additional check to EBR probe and create methods:
    don't try probe and create  EBR scheme when parent partition type
    is not "ebr". This fixes error messages about corrupted EBR for
    some partitions where is actually another partition scheme.
  
    NOTE: if you have EBR on the partition with different than "ebr"
    (0x05) type, then you will lost access to partitions until it will be
    changed.
  
  MFC r231928:
    Add alias for the partition type 0x0f. Now "ebr" name is used for both
    types 0x05 and 0x0f, but 0x05 is preferred and used when partition is
    created with "gpart add -t ebr ...".
    This should keep EBR partitions accessible after r231754 for those,
    who have EBR on the partition with type 0x0f.

Modified:
  stable/9/sys/geom/part/g_part_ebr.c
  stable/9/sys/geom/part/g_part_mbr.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/geom/part/g_part_ebr.c
==============================================================================
--- stable/9/sys/geom/part/g_part_ebr.c	Mon Mar  5 04:46:28 2012	(r232534)
+++ stable/9/sys/geom/part/g_part_ebr.c	Mon Mar  5 04:51:22 2012	(r232535)
@@ -268,7 +268,7 @@ g_part_ebr_add(struct g_part_table *base
 static int
 g_part_ebr_create(struct g_part_table *basetable, struct g_part_parms *gpp)
 {
-	char psn[8];
+	char type[64];
 	struct g_consumer *cp;
 	struct g_provider *pp;
 	uint32_t msize;
@@ -285,10 +285,15 @@ g_part_ebr_create(struct g_part_table *b
 	if (basetable->gpt_depth == 0)
 		return (ENXIO);
 	cp = LIST_FIRST(&pp->consumers);
-	error = g_getattr("PART::scheme", cp, &psn);
-	if (error)
+	error = g_getattr("PART::scheme", cp, &type);
+	if (error != 0)
 		return (error);
-	if (strcmp(psn, "MBR"))
+	if (strcmp(type, "MBR") != 0)
+		return (ENXIO);
+	error = g_getattr("PART::type", cp, &type);
+	if (error != 0)
+		return (error);
+	if (strcmp(type, "ebr") != 0)
 		return (ENXIO);
 
 	msize = MIN(pp->mediasize / pp->sectorsize, UINT32_MAX);
@@ -405,7 +410,7 @@ g_part_ebr_precheck(struct g_part_table 
 static int
 g_part_ebr_probe(struct g_part_table *table, struct g_consumer *cp)
 {
-	char psn[8];
+	char type[64];
 	struct g_provider *pp;
 	u_char *buf, *p;
 	int error, index, res;
@@ -422,10 +427,16 @@ g_part_ebr_probe(struct g_part_table *ta
 	/* Check that we have a parent and that it's a MBR. */
 	if (table->gpt_depth == 0)
 		return (ENXIO);
-	error = g_getattr("PART::scheme", cp, &psn);
-	if (error)
+	error = g_getattr("PART::scheme", cp, &type);
+	if (error != 0)
+		return (error);
+	if (strcmp(type, "MBR") != 0)
+		return (ENXIO);
+	/* Check that partition has type DOSPTYP_EBR. */
+	error = g_getattr("PART::type", cp, &type);
+	if (error != 0)
 		return (error);
-	if (strcmp(psn, "MBR"))
+	if (strcmp(type, "ebr") != 0)
 		return (ENXIO);
 
 	/* Check that there's a EBR. */

Modified: stable/9/sys/geom/part/g_part_mbr.c
==============================================================================
--- stable/9/sys/geom/part/g_part_mbr.c	Mon Mar  5 04:46:28 2012	(r232534)
+++ stable/9/sys/geom/part/g_part_mbr.c	Mon Mar  5 04:51:22 2012	(r232535)
@@ -119,6 +119,7 @@ static struct g_part_mbr_alias {
 	{ DOSPTYP_EXT,		G_PART_ALIAS_EBR },
 	{ DOSPTYP_NTFS,		G_PART_ALIAS_MS_NTFS },
 	{ DOSPTYP_FAT32,	G_PART_ALIAS_MS_FAT32 },
+	{ DOSPTYP_EXTLBA,	G_PART_ALIAS_EBR },
 	{ DOSPTYP_LDM,		G_PART_ALIAS_MS_LDM_DATA },
 	{ DOSPTYP_LINSWP,	G_PART_ALIAS_LINUX_SWAP },
 	{ DOSPTYP_LINUX,	G_PART_ALIAS_LINUX_DATA },



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201203050451.q254pMab067441>