Module Name: src Committed By: jnemeth Date: Fri Oct 3 00:51:31 UTC 2014
Modified Files: src/sbin/gpt: create.c gpt_uuid.c gpt_uuid.h migrate.c Log Message: "0" is not guaranteed to be unique To generate a diff of this commit: cvs rdiff -u -r1.10 -r1.11 src/sbin/gpt/create.c cvs rdiff -u -r1.5 -r1.6 src/sbin/gpt/gpt_uuid.c cvs rdiff -u -r1.1 -r1.2 src/sbin/gpt/gpt_uuid.h cvs rdiff -u -r1.19 -r1.20 src/sbin/gpt/migrate.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/create.c diff -u src/sbin/gpt/create.c:1.10 src/sbin/gpt/create.c:1.11 --- src/sbin/gpt/create.c:1.10 Tue Sep 30 17:59:59 2014 +++ src/sbin/gpt/create.c Fri Oct 3 00:51:31 2014 @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: create.c,v 1.10 2014/09/30 17:59:59 christos Exp $"); +__RCSID("$NetBSD: create.c,v 1.11 2014/10/03 00:51:31 jnemeth Exp $"); #endif #include <sys/types.h> @@ -174,7 +174,7 @@ create(int fd) hdr->hdr_lba_alt = htole64(last); hdr->hdr_lba_start = htole64(tbl->map_start + blocks); hdr->hdr_lba_end = htole64(last - blocks - 1LL); - gpt_uuid_copy(hdr->hdr_guid, gpt_uuid_nil); + gpt_uuid_create_new(hdr->hdr_guid); hdr->hdr_lba_table = htole64(tbl->map_start); hdr->hdr_entries = htole32((blocks * secsz) / sizeof(struct gpt_ent)); if (le32toh(hdr->hdr_entries) > parts) @@ -183,7 +183,7 @@ create(int fd) ent = tbl->map_data; for (i = 0; i < le32toh(hdr->hdr_entries); i++) { - gpt_uuid_copy(ent[i].ent_guid, gpt_uuid_nil); + gpt_uuid_create_new(ent[i].ent_guid); } hdr->hdr_crc_table = htole32(crc32(ent, le32toh(hdr->hdr_entries) * Index: src/sbin/gpt/gpt_uuid.c diff -u src/sbin/gpt/gpt_uuid.c:1.5 src/sbin/gpt/gpt_uuid.c:1.6 --- src/sbin/gpt/gpt_uuid.c:1.5 Thu Oct 2 21:27:41 2014 +++ src/sbin/gpt/gpt_uuid.c Fri Oct 3 00:51:31 2014 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.c,v 1.5 2014/10/02 21:27:41 apb Exp $ */ +/* $NetBSD: gpt_uuid.c,v 1.6 2014/10/03 00:51:31 jnemeth Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -32,7 +32,7 @@ #include <sys/cdefs.h> #ifdef __RCSID -__RCSID("$NetBSD: gpt_uuid.c,v 1.5 2014/10/02 21:27:41 apb Exp $"); +__RCSID("$NetBSD: gpt_uuid.c,v 1.6 2014/10/03 00:51:31 jnemeth Exp $"); #endif #include <stdio.h> @@ -44,6 +44,11 @@ __RCSID("$NetBSD: gpt_uuid.c,v 1.5 2014/ #include <sys/endian.h> #endif +#if !defined(HAVE_NBTOOL_CONFIG_H) +#include <sys/types.h> +#include <sys/uuid.h> +#endif + const gpt_uuid_t gpt_uuid_nil; struct dce_uuid { @@ -230,3 +235,14 @@ gpt_uuid_create(gpt_type_t t, gpt_uuid_t if (b) utf8_to_utf16((const uint8_t *)gpt_nv[t].d, b, s / sizeof(*b)); } + +#if !defined(HAVE_NBTOOL_CONFIG_H) +void +gpt_uuid_create_new(gpt_uuid_t t) +{ + struct uuid u; + + uuidgen(&u, 1); + gpt_dce_to_uuid((struct dce_uuid *)&u, t); +} +#endif Index: src/sbin/gpt/gpt_uuid.h diff -u src/sbin/gpt/gpt_uuid.h:1.1 src/sbin/gpt/gpt_uuid.h:1.2 --- src/sbin/gpt/gpt_uuid.h:1.1 Tue Sep 30 17:59:59 2014 +++ src/sbin/gpt/gpt_uuid.h Fri Oct 3 00:51:31 2014 @@ -91,6 +91,8 @@ void gpt_uuid_create(gpt_type_t, gpt_uui int gpt_uuid_parse(const char *, gpt_uuid_t); +void gpt_uuid_create_new(gpt_uuid_t); + __END_DECLS #endif /* _GPT_UUID_T */ Index: src/sbin/gpt/migrate.c diff -u src/sbin/gpt/migrate.c:1.19 src/sbin/gpt/migrate.c:1.20 --- src/sbin/gpt/migrate.c:1.19 Tue Sep 30 17:59:59 2014 +++ src/sbin/gpt/migrate.c Fri Oct 3 00:51:31 2014 @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: migrate.c,v 1.19 2014/09/30 17:59:59 christos Exp $"); +__RCSID("$NetBSD: migrate.c,v 1.20 2014/10/03 00:51:31 jnemeth Exp $"); #endif #include <sys/types.h> @@ -335,7 +335,7 @@ migrate(int fd) hdr->hdr_lba_alt = htole64(tpg->map_start); hdr->hdr_lba_start = htole64(tbl->map_start + blocks); hdr->hdr_lba_end = htole64(lbt->map_start - 1LL); - gpt_uuid_copy(hdr->hdr_guid, gpt_uuid_nil); + gpt_uuid_create_new(hdr->hdr_guid); hdr->hdr_lba_table = htole64(tbl->map_start); hdr->hdr_entries = htole32((blocks * secsz) / sizeof(struct gpt_ent)); if (le32toh(hdr->hdr_entries) > parts) @@ -344,7 +344,7 @@ migrate(int fd) ent = tbl->map_data; for (i = 0; i < le32toh(hdr->hdr_entries); i++) { - gpt_uuid_copy(ent[i].ent_guid, gpt_uuid_nil); + gpt_uuid_create_new(ent[i].ent_guid); } /* Mirror partitions. */