Module Name:    src
Committed By:   martin
Date:           Sun Jan 30 11:58:29 UTC 2022

Modified Files:
        src/usr.sbin/sysinst: defs.h gpt.c target.c

Log Message:
Do not defer wedge deletions when we have nothing mounted.
Define and use a constant for maximum disk name length.


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/usr.sbin/sysinst/defs.h
cvs rdiff -u -r1.27 -r1.28 src/usr.sbin/sysinst/gpt.c
cvs rdiff -u -r1.16 -r1.17 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/defs.h
diff -u src/usr.sbin/sysinst/defs.h:1.78 src/usr.sbin/sysinst/defs.h:1.79
--- src/usr.sbin/sysinst/defs.h:1.78	Sat Jan 29 16:01:16 2022
+++ src/usr.sbin/sysinst/defs.h	Sun Jan 30 11:58:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: defs.h,v 1.78 2022/01/29 16:01:16 martin Exp $	*/
+/*	$NetBSD: defs.h,v 1.79 2022/01/30 11:58:29 martin Exp $	*/
 
 /*
  * Copyright 1997 Piermont Information Systems Inc.
@@ -59,6 +59,7 @@ const char *getfslabelname(uint, uint);
 #define STRSIZE		255
 #define	MENUSTRSIZE	80
 #define SSTRSIZE	30
+#define	DISKNAMESIZE	24	/* max(strlen("/dev/rsd22c")) */
 
 /* these are used for different alignment defaults */
 #define	HUGE_DISK_SIZE	(daddr_t)(128 * (GIG / 512))

Index: src/usr.sbin/sysinst/gpt.c
diff -u src/usr.sbin/sysinst/gpt.c:1.27 src/usr.sbin/sysinst/gpt.c:1.28
--- src/usr.sbin/sysinst/gpt.c:1.27	Sat Jan 29 15:32:49 2022
+++ src/usr.sbin/sysinst/gpt.c	Sun Jan 30 11:58:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: gpt.c,v 1.27 2022/01/29 15:32:49 martin Exp $	*/
+/*	$NetBSD: gpt.c,v 1.28 2022/01/30 11:58:29 martin Exp $	*/
 
 /*
  * Copyright 2018 The NetBSD Foundation, Inc.
@@ -49,7 +49,7 @@ bool	gpt_parts_check(void);	/* check for
 #define GUID_STR_LEN	40
 #define	GPT_PTYPE_ALLOC	32	/* initial type array allocation, should be >
 				 * gpt type -l | wc -l */
-#define	GPT_DEV_LEN	16	/* dkNN */
+#define	GPT_DEV_LEN	DISKNAMESIZE	/* dkNN */
 
 #define	GPT_PARTS_PER_SEC	4	/* a 512 byte sector holds 4 entries */
 #define	GPT_DEFAULT_MAX_PARTS	128

Index: src/usr.sbin/sysinst/target.c
diff -u src/usr.sbin/sysinst/target.c:1.16 src/usr.sbin/sysinst/target.c:1.17
--- src/usr.sbin/sysinst/target.c:1.16	Sat Jan 29 15:32:49 2022
+++ src/usr.sbin/sysinst/target.c	Sun Jan 30 11:58:29 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: target.c,v 1.16 2022/01/29 15:32:49 martin Exp $	*/
+/*	$NetBSD: target.c,v 1.17 2022/01/30 11:58:29 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.16 2022/01/29 15:32:49 martin Exp $");
+__RCSID("$NetBSD: target.c,v 1.17 2022/01/30 11:58:29 martin Exp $");
 #endif
 
 /*
@@ -123,7 +123,7 @@ struct unwind_mount {
 /* Record a wedge for later deletion after all file systems have been unmounted */
 struct umount_delwedge {
 	struct umount_delwedge *next;
-	char disk[MAXPATHLEN], wedge[MAXPATHLEN];
+	char disk[DISKNAMESIZE], wedge[DISKNAMESIZE];
 };
 struct umount_delwedge *post_umount_dwlist = NULL;
 
@@ -549,6 +549,12 @@ register_post_umount_delwedge(const char
 {
 	struct umount_delwedge *dw;
 
+	if (unwind_mountlist == NULL) {
+		/* we have nothing mounted, can delete it right now */
+		delete_wedge(disk, wedge);
+		return;
+	}
+
 	dw = calloc(1, sizeof(*dw));
 	dw->next = post_umount_dwlist;
 	strlcpy(dw->disk, disk, sizeof(dw->disk));

Reply via email to