Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/arch/arm/arm Ignore PMBR partition if it's partition 0.



details:   https://anonhg.NetBSD.org/src/rev/66cf1afe0422
branches:  trunk
changeset: 789295:66cf1afe0422
user:      matt <matt%NetBSD.org@localhost>
date:      Tue Aug 13 00:04:08 2013 +0000

description:
Ignore PMBR partition if it's partition 0.
Make sure all unused parts of the partition table are zeroed.

diffstat:

 sys/arch/arm/arm/disksubr_mbr.c |  20 ++++++++++++++------
 1 files changed, 14 insertions(+), 6 deletions(-)

diffs (61 lines):

diff -r 4c23a701a63d -r 66cf1afe0422 sys/arch/arm/arm/disksubr_mbr.c
--- a/sys/arch/arm/arm/disksubr_mbr.c   Mon Aug 12 23:42:14 2013 +0000
+++ b/sys/arch/arm/arm/disksubr_mbr.c   Tue Aug 13 00:04:08 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr_mbr.c,v 1.17 2013/03/10 04:01:49 christos Exp $       */
+/*     $NetBSD: disksubr_mbr.c,v 1.18 2013/08/13 00:04:08 matt Exp $   */
 
 /*
  * Copyright (c) 1998 Christopher G. Demetriou.  All rights reserved.
@@ -68,7 +68,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.17 2013/03/10 04:01:49 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.18 2013/08/13 00:04:08 matt Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -146,18 +146,22 @@
                        }
                }
 #endif
-               for (i = 0; i < MBR_PART_COUNT; i++, mbrp++) {
-                       if (mbrp->mbrp_type == MBR_PTYPE_UNUSED)
+               pp = &lp->d_partitions['e' - 'a'];
+               for (i = 0; i < MBR_PART_COUNT; i++, mbrp++, pp++) {
+                       if ((i == 0 && mbrp->mbrp_type == MBR_PTYPE_PMBR)
+                           || mbrp->mbrp_type == MBR_PTYPE_UNUSED) {
+                               memset(pp, 0, sizeof(*pp));
                                continue;
+                       }
                        if (le32toh(mbrp->mbrp_start) +
                            le32toh(mbrp->mbrp_size) > lp->d_secperunit) {
                                /* This mbr doesn't look good.... */
+                               memset(pp, 0, sizeof(*pp));
                                continue;
                        }
                        nfound++;
 
                        /* Install in partition e, f, g, or h. */
-                       pp = &lp->d_partitions['e' - 'a' + i];
                        pp->p_offset = le32toh(mbrp->mbrp_start);
                        pp->p_size = le32toh(mbrp->mbrp_size);
                        pp->p_fstype = xlat_mbr_fstype(mbrp->mbrp_type);
@@ -181,11 +185,15 @@
                        lp->d_secpercyl = lp->d_ntracks * lp->d_nsectors;
 #endif
                }
+               i += 'e' - 'a';
                if (nfound > 0) {
-                       lp->d_npartitions = 'e' - 'a' + i;
+                       lp->d_npartitions = i;
                        strncpy(lp->d_packname, "fictitious-MBR",
                            sizeof lp->d_packname);
                }
+               if (lp->d_npartitions < MAXPARTITIONS) {
+                       memset(pp, 0, (MAXPARTITIONS - i) * sizeof(*pp));
+               }
        }
 
        *cylp = cyl;



Home | Main Index | Thread Index | Old Index