Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.sbin/sysinst PR install/54480: when upgrading a system a...
details: https://anonhg.NetBSD.org/src/rev/6139feac5d41
branches: trunk
changeset: 964858:6139feac5d41
user: martin <martin%NetBSD.org@localhost>
date: Tue Aug 20 06:38:17 2019 +0000
description:
PR install/54480: when upgrading a system and re-mounting the target /
with proper options, and the installed system does not use NAME= syntax
in fstab(5), use the device name we used to get here, instead of the
name from fstab, it might be different to what the real system calls the
device (compact flash root showing up as wd0 native, but sd? on the
card reader used for updating it right now).
This is an abuse of the upgrade functionality and in general pretty dangerous
when multiple devices are used in the upgraded fstab (e.g. separate /usr),
and it used to work more by accident with the old code.
However, it is a quite usefull way to upgrade tiny systems with compact flash
root, and it used to work - so support it properly (as far as we can).
diffstat:
usr.sbin/sysinst/disks.c | 43 +++++++++++++++++++++++++++++++++++--------
1 files changed, 35 insertions(+), 8 deletions(-)
diffs (68 lines):
diff -r 16a15a19f010 -r 6139feac5d41 usr.sbin/sysinst/disks.c
--- a/usr.sbin/sysinst/disks.c Tue Aug 20 06:37:06 2019 +0000
+++ b/usr.sbin/sysinst/disks.c Tue Aug 20 06:38:17 2019 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.50 2019/08/08 13:45:19 martin Exp $ */
+/* $NetBSD: disks.c,v 1.51 2019/08/20 06:38:17 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -1484,12 +1484,14 @@
const char *fsname = (const char*)item->var;
part_id pno;
struct disk_partitions *parts;
- bool first;
+ size_t len;
+ bool first, is_root;
if (num < 2 || strstr(list[2].u.s_val, "noauto") != NULL)
return 0;
- if ((strcmp(list[1].u.s_val, "/") == 0) && target_mounted())
+ is_root = strcmp(list[1].u.s_val, "/") == 0;
+ if (is_root && target_mounted())
return 0;
if (strcmp(item->head, name_prefix) == 0) {
@@ -1502,11 +1504,36 @@
parts->pscheme->get_part_device(parts, pno,
rdev, sizeof(rdev), NULL, raw_dev_name, true);
} else {
- /* plain device name */
- strcpy(rdev, "/dev/r");
- strlcat(rdev, list[0].u.s_val, sizeof(rdev));
- strcpy(dev, "/dev/");
- strlcat(dev, list[0].u.s_val, sizeof(dev));
+ /* this fstab entry uses the plain device name */
+ if (is_root) {
+ /*
+ * PR 54480: we can not use the current device name
+ * as it might be different from the real environment.
+ * This is an abuse of the functionality, but it used
+ * to work before (and still does work if only a single
+ * target disk is involved).
+ * Use the device name from the current "pm" instead.
+ */
+ strcpy(rdev, "/dev/r");
+ strlcat(rdev, pm->diskdev, sizeof(rdev));
+ strcpy(dev, "/dev/");
+ strlcat(dev, pm->diskdev, sizeof(dev));
+ /* copy over the partition letter, if any */
+ len = strlen(list[0].u.s_val);
+ if (list[0].u.s_val[len-1] >= 'a' &&
+ list[0].u.s_val[len-1] <=
+ ('a' + getmaxpartitions())) {
+ strlcat(rdev, &list[0].u.s_val[len-1],
+ sizeof(rdev));
+ strlcat(dev, &list[0].u.s_val[len-1],
+ sizeof(dev));
+ }
+ } else {
+ strcpy(rdev, "/dev/r");
+ strlcat(rdev, list[0].u.s_val, sizeof(rdev));
+ strcpy(dev, "/dev/");
+ strlcat(dev, list[0].u.s_val, sizeof(dev));
+ }
}
if (with_fsck) {
Home |
Main Index |
Thread Index |
Old Index