Module Name:    src
Committed By:   martin
Date:           Sun Nov 17 13:36:15 UTC 2024

Modified Files:
        src/sbin/gpt [netbsd-9]: add.c

Log Message:
Pull up following revision(s) (requested by kre in ticket #1920):

        sbin/gpt/add.c: revision 1.45

PR bin/58806  Never create a partition with a null guid

If a new partition entry being added doesn't already have a guid,
make one for it.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.44.2.1 src/sbin/gpt/add.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.44 src/sbin/gpt/add.c:1.44.2.1
--- src/sbin/gpt/add.c:1.44	Tue Jul  3 03:41:23 2018
+++ src/sbin/gpt/add.c	Sun Nov 17 13:36:15 2024
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.44 2018/07/03 03:41:23 jnemeth Exp $");
+__RCSID("$NetBSD: add.c,v 1.44.2.1 2024/11/17 13:36:15 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -122,6 +122,12 @@ add(gpt_t gpt, off_t alignment, off_t bl
 		}
 	}
 
+	if (gpt_uuid_is_nil(ent->ent_guid))
+		if (gpt_uuid_generate(gpt, ent->ent_guid) == -1) {
+			gpt_warnx(gpt, "Unable to make UUID");
+			return -1;
+		}
+
 	if (alignment > 0) {
 		alignsecs = alignment / gpt->secsz;
 		map = map_alloc(gpt, block, sectors, alignsecs);

Reply via email to