Author: ae
Date: Wed Feb 15 10:33:29 2012
New Revision: 231754
URL: http://svn.freebsd.org/changeset/base/231754

Log:
  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 after:    2 weeks

Modified:
  head/sys/geom/part/g_part_ebr.c

Modified: head/sys/geom/part/g_part_ebr.c
==============================================================================
--- head/sys/geom/part/g_part_ebr.c     Wed Feb 15 10:15:15 2012        
(r231753)
+++ head/sys/geom/part/g_part_ebr.c     Wed Feb 15 10:33:29 2012        
(r231754)
@@ -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. */
_______________________________________________
svn-src-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to