When searching for a partition that may be the root partition for upgrading,
allow "/", "/targetroot" and "/altroot" as potential last mount points.
This commit is contained in:
parent
0ed3032a3b
commit
c2ed2005cc
@ -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 @@ void free_install_desc(struct install_partition_desc*);
|
||||
#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);
|
||||
|
@ -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 @@ mount_disks(struct install_partition_desc *install)
|
||||
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 @@ mount_disks(struct install_partition_desc *install)
|
||||
/* 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);
|
||||
|
@ -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 @@ target_already_root(void)
|
||||
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 @@ target_already_root(void)
|
||||
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?
|
||||
|
@ -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 @@ do_upgrade(void)
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user