Module Name:    src
Committed By:   kre
Date:           Sat Nov  2 12:46:49 UTC 2024

Modified Files:
        src/sbin/gpt: add.c

Log Message:
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.45 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.45
--- src/sbin/gpt/add.c:1.44	Tue Jul  3 03:41:23 2018
+++ src/sbin/gpt/add.c	Sat Nov  2 12:46:49 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.45 2024/11/02 12:46:49 kre 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