Source-Changes-HG archive

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

[src/netbsd-6]: src/sys/arch/arm/arm Pull up following revision(s) (requested...



details:   https://anonhg.NetBSD.org/src/rev/db820450d2cf
branches:  netbsd-6
changeset: 775663:db820450d2cf
user:      riz <riz%NetBSD.org@localhost>
date:      Sun Feb 10 20:17:23 2013 +0000

description:
Pull up following revision(s) (requested by msaitoh in ticket #804):
        sys/arch/arm/arm/disksubr_mbr.c: revision 1.15
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 eaeb9a39d04e -r db820450d2cf sys/arch/arm/arm/disksubr_mbr.c
--- a/sys/arch/arm/arm/disksubr_mbr.c   Sat Feb 09 18:32:10 2013 +0000
+++ b/sys/arch/arm/arm/disksubr_mbr.c   Sun Feb 10 20:17:23 2013 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disksubr_mbr.c,v 1.13.4.1 2012/10/23 16:21:32 riz Exp $        */
+/*     $NetBSD: disksubr_mbr.c,v 1.13.4.2 2013/02/10 20:17:23 riz 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.13.4.1 2012/10/23 16:21:32 riz Exp $");
+__KERNEL_RCSID(0, "$NetBSD: disksubr_mbr.c,v 1.13.4.2 2013/02/10 20:17:23 riz 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