Source-Changes-HG archive

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

[src/trunk]: src/distrib/utils/sysinst Correct some bugs in mbr handling, whi...



details:   https://anonhg.NetBSD.org/src/rev/37167c3dc70c
branches:  trunk
changeset: 471903:37167c3dc70c
user:      bouyer <bouyer%NetBSD.org@localhost>
date:      Wed Apr 14 16:00:42 1999 +0000

description:
Correct some bugs in mbr handling, which could lead to invalid partition
tables being written on disk:
- when counting non-BSD partitions, use part[i], not part[0]
- when using full disk for NetBSD, initialise all the fileds of the
  mbr entries (especially flags)
- When converting to on-disk format, if start and size = 0, initialise
  c/h/s to 0 for both start and end. convert_mbr_chs() would make an entry
  0/0/0, 0/0/1 which is not bogus, but not what we really want either.

diffstat:

 distrib/utils/sysinst/mbr.c |  25 ++++++++++++++++++-------
 1 files changed, 18 insertions(+), 7 deletions(-)

diffs (54 lines):

diff -r 225f517c0fda -r 37167c3dc70c distrib/utils/sysinst/mbr.c
--- a/distrib/utils/sysinst/mbr.c       Wed Apr 14 15:23:27 1999 +0000
+++ b/distrib/utils/sysinst/mbr.c       Wed Apr 14 16:00:42 1999 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: mbr.c,v 1.13 1999/04/11 22:40:20 bouyer Exp $ */
+/*     $NetBSD: mbr.c,v 1.14 1999/04/14 16:00:42 bouyer Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -194,9 +194,9 @@
                int i;
                /* Count nonempty, non-BSD partitions. */
                for (i = 0; i < NMBRPART; i++) {
-                       otherparts += otherpart(part[0].mbrp_typ);
+                       otherparts += otherpart(part[i].mbrp_typ);
                        /* check for dualboot *bsd too */
-                       ourparts += ourpart(part[0].mbrp_typ);
+                       ourparts += ourpart(part[i].mbrp_typ);
                }                                         
 
                /* Ask if we really want to blow away non-NetBSD stuff */
@@ -211,9 +211,12 @@
                }
 
                /* Set the partition information for full disk usage. */
-               part[0].mbrp_typ = part[0].mbrp_size = 0;
-               part[1].mbrp_typ = part[1].mbrp_size = 0;
-               part[2].mbrp_typ = part[2].mbrp_size = 0;
+               part[0].mbrp_typ = part[0].mbrp_flag = 0;
+               part[0].mbrp_start = part[0].mbrp_size = 0;
+               part[1].mbrp_typ = part[0].mbrp_flag = 0;
+               part[1].mbrp_start = part[0].mbrp_size = 0;
+               part[2].mbrp_typ = part[0].mbrp_flag = 0;
+               part[2].mbrp_start = part[0].mbrp_size = 0;
                part[3].mbrp_typ = dosptyp_nbsd;
                part[3].mbrp_size = bsize - bsec;
                part[3].mbrp_start = bsec;
@@ -425,7 +428,15 @@
 
        mbrp = (struct mbr_partition *)&buf[MBR_PARTOFF];
        for (i = 0; i < NMBRPART; i++) {
-               if (mbrp[i].mbrp_typ != 0) {
+               if (mbrp[i].mbrp_start == 0 &&
+                   mbrp[i].mbrp_size == 0) {
+                       mbrp[i].mbrp_scyl = 0;
+                       mbrp[i].mbrp_shd = 0;
+                       mbrp[i].mbrp_ssect = 0;
+                       mbrp[i].mbrp_ecyl = 0;
+                       mbrp[i].mbrp_ehd = 0;
+                       mbrp[i].mbrp_esect = 0;
+               } else {
                        pstart = mbrp[i].mbrp_start;
                        psize = mbrp[i].mbrp_size;
                        mbrp[i].mbrp_start = native_to_le32(pstart);



Home | Main Index | Thread Index | Old Index