Module Name: src
Committed By: martin
Date: Thu Aug 1 16:32:06 UTC 2019
Modified Files:
src/usr.sbin/sysinst: disks.c label.c target.c
Log Message:
Do not strip the trailing / on root mounts when evaluation "last mounted
on". Fix some /dev/ and raw vs. block device confusion on system upgrades.
To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/usr.sbin/sysinst/disks.c
cvs rdiff -u -r1.10 -r1.11 src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/sysinst/target.c
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/usr.sbin/sysinst/disks.c
diff -u src/usr.sbin/sysinst/disks.c:1.44 src/usr.sbin/sysinst/disks.c:1.45
--- src/usr.sbin/sysinst/disks.c:1.44 Thu Jul 25 13:11:15 2019
+++ src/usr.sbin/sysinst/disks.c Thu Aug 1 16:32:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: disks.c,v 1.44 2019/07/25 13:11:15 martin Exp $ */
+/* $NetBSD: disks.c,v 1.45 2019/08/01 16:32:06 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -80,6 +80,8 @@ struct disk_desc {
daddr_t dd_totsec;
};
+static const char name_prefix[] = "NAME=";
+
/* Local prototypes */
static int foundffs(struct data *, size_t);
#ifdef USE_SYSVBFS
@@ -1399,23 +1401,37 @@ done_with_disks:
return 0;
}
-
-
static int
/*ARGSUSED*/
foundffs(struct data *list, size_t num)
{
int error;
+ char rbuf[PATH_MAX], buf[PATH_MAX];
+ const char *rdev, *dev;
if (num < 2 || strcmp(list[1].u.s_val, "/") == 0 ||
strstr(list[2].u.s_val, "noauto") != NULL)
return 0;
- error = fsck_preen(list[0].u.s_val, "ffs", false);
+ /* need the raw device for fsck_preen */
+ if (strncmp(list[0].u.s_val, name_prefix, sizeof(name_prefix)-1)
+ != 0) {
+ strcpy(rbuf, "/dev/r");
+ strlcat(rbuf, list[0].u.s_val, sizeof(rbuf));
+ rdev = rbuf;
+ strcpy(buf, "/dev/");
+ strlcat(buf, list[0].u.s_val, sizeof(buf));
+ dev = buf;
+ } else {
+ rdev = list[0].u.s_val;
+ dev = list[0].u.s_val;
+ }
+
+ error = fsck_preen(rdev, "ffs", false);
if (error != 0)
return error;
- error = target_mount("", list[0].u.s_val, list[1].u.s_val);
+ error = target_mount("", dev, list[1].u.s_val);
if (error != 0) {
msg_fmt_display(MSG_mount_failed, "%s", list[0].u.s_val);
if (!ask_noyes(NULL))
Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.10 src/usr.sbin/sysinst/label.c:1.11
--- src/usr.sbin/sysinst/label.c:1.10 Fri Jul 26 08:18:47 2019
+++ src/usr.sbin/sysinst/label.c Thu Aug 1 16:32:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.10 2019/07/26 08:18:47 martin Exp $ */
+/* $NetBSD: label.c,v 1.11 2019/08/01 16:32:06 martin Exp $ */
/*
* Copyright 1997 Jonathan Stone
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: label.c,v 1.10 2019/07/26 08:18:47 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.11 2019/08/01 16:32:06 martin Exp $");
#endif
#include <sys/types.h>
@@ -1487,6 +1487,12 @@ canonicalize_last_mounted(char *path)
{
char *p;
+ if (path == NULL)
+ return;
+
+ if (strcmp(path, "/") == 0)
+ return; /* in this case a "trailing" slash is allowed */
+
for (;;) {
p = strrchr(path, '/');
if (p == NULL)
Index: src/usr.sbin/sysinst/target.c
diff -u src/usr.sbin/sysinst/target.c:1.8 src/usr.sbin/sysinst/target.c:1.9
--- src/usr.sbin/sysinst/target.c:1.8 Tue Jul 23 18:13:40 2019
+++ src/usr.sbin/sysinst/target.c Thu Aug 1 16:32:06 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: target.c,v 1.8 2019/07/23 18:13:40 martin Exp $ */
+/* $NetBSD: target.c,v 1.9 2019/08/01 16:32:06 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.8 2019/07/23 18:13:40 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.9 2019/08/01 16:32:06 martin Exp $");
#endif
/*
@@ -209,6 +209,9 @@ target_already_root(void)
bool
is_root_part_mount(const char *last_mounted)
{
+ if (last_mounted == NULL)
+ return false;
+
return strcmp(last_mounted, "/") == 0 ||
strcmp(last_mounted, "/targetroot") == 0 ||
strcmp(last_mounted, "/altroot") == 0;