Source-Changes-HG archive

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

[src/trunk]: src/usr.sbin/sysinst Remove a hardcoded assumption that for BIOS...



details:   https://anonhg.NetBSD.org/src/rev/ae69dc522f31
branches:  trunk
changeset: 460397:ae69dc522f31
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Oct 21 14:07:42 2019 +0000

description:
Remove a hardcoded assumption that for BIOS boot we always will have
the first partition as root - in mixed EFI/BIOS setups this might not
be true (and in general the user is free to define arbitrary orders).
Pointed out by Robert Nestor.

diffstat:

 usr.sbin/sysinst/disks.c |  24 +++++++++++++++++++++---
 1 files changed, 21 insertions(+), 3 deletions(-)

diffs (42 lines):

diff -r 3bd6d9b6be59 -r ae69dc522f31 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c  Mon Oct 21 11:59:01 2019 +0000
+++ b/usr.sbin/sysinst/disks.c  Mon Oct 21 14:07:42 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: disks.c,v 1.51 2019/08/20 06:38:17 martin Exp $ */
+/*     $NetBSD: disks.c,v 1.52 2019/10/21 14:07:42 martin Exp $ */
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -1955,12 +1955,30 @@
 char *
 bootxx_name(struct install_partition_desc *install)
 {
-       int fstype;
+       size_t i;
+       int fstype = -1;
        const char *bootxxname;
        char *bootxx;
 
+       /* find a partition to be mounted as / */
+       for (i = 0; i < install->num; i++) {
+               if ((install->infos[i].instflags & PUIINST_MOUNT)
+                   && strcmp(install->infos[i].mount, "/") == 0) {
+                       fstype = install->infos[i].fs_type;
+                       break;
+               }
+       }
+       if (fstype < 0) {
+               /* not found? take first root type partition instead */
+               for (i = 0; i < install->num; i++) {
+                       if (install->infos[i].type == PT_root) {
+                               fstype = install->infos[i].fs_type;
+                               break;
+                       }
+               }
+       }
+
        /* check we have boot code for the root partition type */
-       fstype = install->infos[0].fs_type;
        switch (fstype) {
 #if defined(BOOTXX_FFSV1) || defined(BOOTXX_FFSV2)
        case FS_BSDFFS:



Home | Main Index | Thread Index | Old Index