Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst When searching for a partition that may be ...
details: https://anonhg.NetBSD.org/src/rev/0cc45c481745
branches: trunk
changeset: 842747:0cc45c481745
user: martin <martin%NetBSD.org@localhost>
date: Tue Jul 23 15:23:14 2019 +0000
description:
When searching for a partition that may be the root partition for upgrading,
allow "/", "/targetroot" and "/altroot" as potential last mount points.
diffstat:
usr.sbin/sysinst/defs.h | 3 ++-
usr.sbin/sysinst/disks.c | 19 ++++++++++++++-----
usr.sbin/sysinst/target.c | 34 +++++++++++++++++++++++++---------
usr.sbin/sysinst/upgrade.c | 7 ++++++-
4 files changed, 47 insertions(+), 16 deletions(-)
diffs (154 lines):
diff -r 9d84dd2e2fd9 -r 0cc45c481745 usr.sbin/sysinst/defs.h
--- a/usr.sbin/sysinst/defs.h Tue Jul 23 15:19:07 2019 +0000
+++ b/usr.sbin/sysinst/defs.h Tue Jul 23 15:23:14 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.38 2019/07/13 17:13:36 martin Exp $ */
+/* $NetBSD: defs.h,v 1.39 2019/07/23 15:23:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -771,6 +771,7 @@
#if defined(DEBUG) || defined(DEBUG_ROOT)
void backtowin(void);
#endif
+bool is_root_part_mount(const char *);
const char *concat_paths(const char *, const char *);
const char *target_expand(const char *);
bool needs_expanding(const char *, size_t);
diff -r 9d84dd2e2fd9 -r 0cc45c481745 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c Tue Jul 23 15:19:07 2019 +0000
+++ b/usr.sbin/sysinst/disks.c Tue Jul 23 15:23:14 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.38 2019/07/14 11:25:10 martin Exp $ */
+/* $NetBSD: disks.c,v 1.39 2019/07/23 15:23:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -1514,6 +1514,7 @@
int fstabsize;
int error;
char devdev[PATH_MAX];
+ size_t i;
static struct lookfor fstabbuf[] = {
{"/dev/", "/dev/%s %s ffs %s", "c", NULL, 0, 0, foundffs},
@@ -1530,10 +1531,18 @@
/* avoid needing to call target_already_root() again */
targetroot_mnt[0] = 0;
else {
- assert(install != NULL && install->num > 0);
- assert(strcmp(install->infos[0].mount, "/") == 0);
- if (!install->infos[0].parts->pscheme->get_part_device(
- install->infos[0].parts, install->infos[0].cur_part_id,
+ for (i = 0; i < install->num; i++) {
+ if (is_root_part_mount(install->infos[i].mount))
+ break;
+ }
+
+ if (i >= install->num) {
+ hit_enter_to_continue(MSG_noroot, NULL);
+ return -1;
+ }
+
+ if (!install->infos[i].parts->pscheme->get_part_device(
+ install->infos[i].parts, install->infos[i].cur_part_id,
devdev, sizeof devdev, NULL, plain_name, true))
return -1;
error = mount_root(devdev, install);
diff -r 9d84dd2e2fd9 -r 0cc45c481745 usr.sbin/sysinst/target.c
--- a/usr.sbin/sysinst/target.c Tue Jul 23 15:19:07 2019 +0000
+++ b/usr.sbin/sysinst/target.c Tue Jul 23 15:23:14 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: target.c,v 1.6 2019/06/15 08:20:33 martin Exp $ */
+/* $NetBSD: target.c,v 1.7 2019/07/23 15:23:14 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: target.c,v 1.6 2019/06/15 08:20:33 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.7 2019/07/23 15:23:14 martin Exp $");
#endif
/*
@@ -164,13 +164,19 @@
return last_res;
last_pm = pm;
- last_res = 1;
+ last_res = 0;
parts = pm->parts;
- if (pm->no_part || parts == NULL) {
+ if (parts == NULL) {
last_res = 0;
return 0;
}
+
+ if (pm->no_part) {
+ last_res = is_active_rootpart(pm->diskdev, -1);
+ return last_res;
+ }
+
if (pm->parts->pscheme->secondary_partitions != NULL)
parts = pm->parts->pscheme->secondary_partitions(parts,
pm->ptstart, false);
@@ -180,20 +186,30 @@
continue;
if (info.nat_type->generic_ptype != PT_root)
continue;
- if (strcmp(info.last_mounted, "/") != 0)
+ if (!is_root_part_mount(info.last_mounted))
continue;
-
if (!parts->pscheme->get_part_device(parts, ptn,
dev, sizeof dev, &rootpart, plain_name, false))
continue;
last_res = is_active_rootpart(dev, rootpart);
- return last_res;
- }
+ break;
+ }
- return 1;
+ return last_res;
}
+/*
+ * Could something with this "last mounted on" information be a potential
+ * root partition?
+ */
+bool
+is_root_part_mount(const char *last_mounted)
+{
+ return strcmp(last_mounted, "/") == 0 ||
+ strcmp(last_mounted, "/targetroot") == 0 ||
+ strcmp(last_mounted, "/altroot") == 0;
+}
/*
* Is this device partition (e.g., "sd0a") mounted as root?
diff -r 9d84dd2e2fd9 -r 0cc45c481745 usr.sbin/sysinst/upgrade.c
--- a/usr.sbin/sysinst/upgrade.c Tue Jul 23 15:19:07 2019 +0000
+++ b/usr.sbin/sysinst/upgrade.c Tue Jul 23 15:23:14 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: upgrade.c,v 1.9 2019/06/24 18:48:08 martin Exp $ */
+/* $NetBSD: upgrade.c,v 1.10 2019/07/23 15:23:14 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -67,6 +67,11 @@
if (find_disks(msg_string(MSG_upgrade)) < 0)
return;
+ if (pm->parts == NULL) {
+ hit_enter_to_continue(MSG_noroot, NULL);
+ return;
+ }
+
if (pm->parts->pscheme->pre_update_verify) {
if (pm->parts->pscheme->pre_update_verify(pm->parts))
pm->parts->pscheme->write_to_disk(pm->parts);
Home |
Main Index |
Thread Index |
Old Index