Module Name: src Committed By: matt Date: Tue Aug 13 00:04:08 UTC 2013
Modified Files: src/sys/arch/arm/arm: disksubr_mbr.c Log Message: Ignore PMBR partition if it's partition 0. Make sure all unused parts of the partition table are zeroed. To generate a diff of this commit: cvs rdiff -u -r1.17 -r1.18 src/sys/arch/arm/arm/disksubr_mbr.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/arm/arm/disksubr_mbr.c diff -u src/sys/arch/arm/arm/disksubr_mbr.c:1.17 src/sys/arch/arm/arm/disksubr_mbr.c:1.18 --- src/sys/arch/arm/arm/disksubr_mbr.c:1.17 Sun Mar 10 04:01:49 2013 +++ src/sys/arch/arm/arm/disksubr_mbr.c Tue Aug 13 00:04:08 2013 @@ -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 @@ mbr_label_read(dev_t dev, } } #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 @@ mbr_label_read(dev_t dev, 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;