Module Name: src
Committed By: martin
Date: Fri Jul 26 08:18:47 UTC 2019
Modified Files:
src/usr.sbin/sysinst: defs.h disklabel.c gpt.c label.c mbr.c
Log Message:
Strip trailing / from last mounted strings.
No idea how they happen, but for cgd root (init.root = "/altroot")
they have been reported to exist.
To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.9 -r1.10 src/usr.sbin/sysinst/disklabel.c \
src/usr.sbin/sysinst/label.c
cvs rdiff -u -r1.3 -r1.4 src/usr.sbin/sysinst/gpt.c
cvs rdiff -u -r1.18 -r1.19 src/usr.sbin/sysinst/mbr.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/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.41 src/usr.sbin/sysinst/defs.h:1.42
--- src/usr.sbin/sysinst/defs.h:1.41 Tue Jul 23 18:13:40 2019
+++ src/usr.sbin/sysinst/defs.h Fri Jul 26 08:18:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: defs.h,v 1.41 2019/07/23 18:13:40 martin Exp $ */
+/* $NetBSD: defs.h,v 1.42 2019/07/26 08:18:47 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -648,6 +648,7 @@ int fs_is_lfs(void *);
*/
const char *get_last_mounted(int fd, daddr_t offset, uint *fs_type,
uint *fs_sub_type, uint flags);
+void canonicalize_last_mounted(char*);
int edit_and_check_label(struct pm_devs *p, struct partition_usage_set *pset);
int edit_ptn(menudesc *, void *);
int checkoverlap(struct disk_partitions *parts);
Index: src/usr.sbin/sysinst/disklabel.c
diff -u src/usr.sbin/sysinst/disklabel.c:1.9 src/usr.sbin/sysinst/disklabel.c:1.10
--- src/usr.sbin/sysinst/disklabel.c:1.9 Sun Jul 21 11:56:20 2019
+++ src/usr.sbin/sysinst/disklabel.c Fri Jul 26 08:18:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: disklabel.c,v 1.9 2019/07/21 11:56:20 martin Exp $ */
+/* $NetBSD: disklabel.c,v 1.10 2019/07/26 08:18:47 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@@ -245,6 +245,8 @@ disklabel_parts_read(const char *disk, d
if (parts->l.d_partitions[part].p_fstype ==
fs_type)
parts->fs_sub_type[part] = fs_sub_type;
+ canonicalize_last_mounted(
+ parts->last_mounted[part]);
}
}
Index: src/usr.sbin/sysinst/label.c
diff -u src/usr.sbin/sysinst/label.c:1.9 src/usr.sbin/sysinst/label.c:1.10
--- src/usr.sbin/sysinst/label.c:1.9 Tue Jul 9 16:16:33 2019
+++ src/usr.sbin/sysinst/label.c Fri Jul 26 08:18:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: label.c,v 1.9 2019/07/09 16:16:33 martin Exp $ */
+/* $NetBSD: label.c,v 1.10 2019/07/26 08:18:47 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.9 2019/07/09 16:16:33 martin Exp $");
+__RCSID("$NetBSD: label.c,v 1.10 2019/07/26 08:18:47 martin Exp $");
#endif
#include <sys/types.h>
@@ -1480,6 +1480,24 @@ edit_and_check_label(struct pm_devs *p,
}
/*
+ * strip trailing / to avoid confusion in path comparisions later
+ */
+void
+canonicalize_last_mounted(char *path)
+{
+ char *p;
+
+ for (;;) {
+ p = strrchr(path, '/');
+ if (p == NULL)
+ return;
+ if (p[1] != 0)
+ return;
+ p[0] = 0;
+ }
+}
+
+/*
* Try to get 'last mounted on' (or equiv) from fs superblock.
*/
const char *
Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.3 src/usr.sbin/sysinst/gpt.c:1.4
--- src/usr.sbin/sysinst/gpt.c:1.3 Thu Jul 25 13:16:35 2019
+++ src/usr.sbin/sysinst/gpt.c Fri Jul 26 08:18:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: gpt.c,v 1.3 2019/07/25 13:16:35 martin Exp $ */
+/* $NetBSD: gpt.c,v 1.4 2019/07/26 08:18:47 martin Exp $ */
/*
* Copyright 2018 The NetBSD Foundation, Inc.
@@ -358,7 +358,9 @@ gpt_read_from_disk(const char *dev, dadd
const char *lm = get_last_mounted(fd, p->gp_start,
&p->fs_type, &p->fs_sub_type, p->gp_type->fsflags);
if (lm != NULL && *lm != 0) {
- p->last_mounted = strdup(lm);
+ char *path = strdup(lm);
+ canonicalize_last_mounted(path);
+ p->last_mounted = path;
} else {
p->fs_type = p->gp_type->default_fs_type;
#ifdef DEFAULT_UFS2
Index: src/usr.sbin/sysinst/mbr.c
diff -u src/usr.sbin/sysinst/mbr.c:1.18 src/usr.sbin/sysinst/mbr.c:1.19
--- src/usr.sbin/sysinst/mbr.c:1.18 Thu Jul 25 18:55:40 2019
+++ src/usr.sbin/sysinst/mbr.c Fri Jul 26 08:18:47 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: mbr.c,v 1.18 2019/07/25 18:55:40 martin Exp $ */
+/* $NetBSD: mbr.c,v 1.19 2019/07/26 08:18:47 martin Exp $ */
/*
* Copyright 1997 Piermont Information Systems Inc.
@@ -547,7 +547,9 @@ read_mbr(const char *disk, mbr_info_t *m
&mbri->fs_type[i],
&mbri->fs_sub_type[i],
flags);
- mbri->last_mounted[i] = strdup(mount);
+ char *p = strdup(mount);
+ canonicalize_last_mounted(p);
+ mbri->last_mounted[i] = p;
}
}
#if BOOTSEL