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 Change for non MBR disk (PR#47463):
details: https://anonhg.NetBSD.org/src/rev/2a194b337688
branches: trunk
changeset: 784099:2a194b337688
user: msaitoh <msaitoh%NetBSD.org@localhost>
date: Fri Jan 18 02:46:30 2013 +0000
description:
Change for non MBR disk (PR#47463):
- Check each mbrp_type field in fdisk partition table in MBR to know whether
a sector is really MBR or not. Same as MI subr_disk_mbr.c
- Check whether each number in a partition table is out of bound or not.
Same as MI subr_disk_mbr.c
- Update d_packname and d_npartitions if we found any partitions.
- Currently, the exended partitions is not supported...
diffstat:
sys/arch/arm/arm/disksubr_mbr.c | 22 ++++++++++++++++------
1 files changed, 16 insertions(+), 6 deletions(-)
diffs (57 lines):
diff -r 170405538b50 -r 2a194b337688 sys/arch/arm/arm/disksubr_mbr.c
--- a/sys/arch/arm/arm/disksubr_mbr.c Fri Jan 18 01:41:07 2013 +0000
+++ b/sys/arch/arm/arm/disksubr_mbr.c Fri Jan 18 02:46:30 2013 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disksubr_mbr.c,v 1.14 2012/10/16 00:25:09 msaitoh Exp $ */
+/* $NetBSD: disksubr_mbr.c,v 1.15 2013/01/18 02:46:30 msaitoh 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.14 2012/10/16 00:25:09 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.15 2013/01/18 02:46:30 msaitoh Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -117,6 +117,7 @@
goto out;
} else {
struct mbr_partition *ourmbrp = NULL;
+ int nfound = 0;
/* XXX "there has to be a better check than this." */
if (memcmp((char *)bp->b_data + MBRSIGOFS, mbrsig, sizeof(mbrsig))) {
@@ -145,9 +146,14 @@
}
#endif
for (i = 0; i < MBR_PART_COUNT; i++, mbrp++) {
-
- strncpy(lp->d_packname, "fictitious-MBR",
- sizeof lp->d_packname);
+ if (mbrp->mbrp_type == MBR_PTYPE_UNUSED)
+ continue;
+ if (le32toh(mbrp->mbrp_start) +
+ le32toh(mbrp->mbrp_size) > lp->d_secperunit) {
+ /* This mbr doesn't look good.... */
+ continue;
+ }
+ nfound++;
/* Install in partition e, f, g, or h. */
pp = &lp->d_partitions['e' - 'a' + i];
@@ -175,7 +181,11 @@
#endif
}
}
- lp->d_npartitions = 'e' - 'a' + i;
+ if (nfound > 0) {
+ lp->d_npartitions = 'e' - 'a' + i;
+ strncpy(lp->d_packname, "fictitious-MBR",
+ sizeof lp->d_packname);
+ }
}
*cylp = cyl;
Home |
Main Index |
Thread Index |
Old Index