Module Name: src Committed By: christos Date: Mon Aug 19 17:15:38 UTC 2024
Modified Files: src/sbin/gpt: gpt.8 gpt_uuid.c gpt_uuid.h uuid.c Log Message: Add -U option to specify new UUID Add OpenBSD from Anon Ymous To generate a diff of this commit: cvs rdiff -u -r1.82 -r1.83 src/sbin/gpt/gpt.8 cvs rdiff -u -r1.21 -r1.22 src/sbin/gpt/gpt_uuid.c cvs rdiff -u -r1.10 -r1.11 src/sbin/gpt/gpt_uuid.h cvs rdiff -u -r1.1 -r1.2 src/sbin/gpt/uuid.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/gpt.8 diff -u src/sbin/gpt/gpt.8:1.82 src/sbin/gpt/gpt.8:1.83 --- src/sbin/gpt/gpt.8:1.82 Mon Jun 10 05:17:29 2024 +++ src/sbin/gpt/gpt.8 Mon Aug 19 13:15:38 2024 @@ -1,4 +1,4 @@ -.\" $NetBSD: gpt.8,v 1.82 2024/06/10 09:17:29 kre Exp $ +.\" $NetBSD: gpt.8,v 1.83 2024/08/19 17:15:38 christos Exp $ .\" .\" Copyright (c) 2002 Marcel Moolenaar .\" All rights reserved. @@ -26,7 +26,7 @@ .\" .\" $FreeBSD: src/sbin/gpt/gpt.8,v 1.17 2006/06/22 22:22:32 marcel Exp $ .\" -.Dd July 15, 2023 +.Dd August 19, 2024 .Dt GPT 8 .Os .Sh NAME @@ -216,6 +216,8 @@ Linux RAID Linux swap .It Cm linux-lvm Linux LVM +.It Cm obsd +OpenBSD data .It Cm windows Microsoft basic data - NTFS, FAT32 ("msdos"), FAT16, also used for UDF .It Cm windows-reserved @@ -722,8 +724,9 @@ They may be used by code in the future. .\" ==== uuid ==== .It Nm Ic uuid Oo Fl a Oc -.It Nm Ic uuid Oo Fl b Ar blocknr Oc Oo Fl i Ar index Oc \ -Oo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc +.It Nm Ic uuid Oo Fl b Ar blocknr Oc Oo Fl i Ar index Ar Oc \ +Oo Fl L Ar label Oc Oo Fl s Ar sectors Oc Oo Fl t Ar type Oc \ +Oo Fl U Ar newuuid Oc The .Ic uuid command allows the user to change the UUID of any and all partitions @@ -733,6 +736,13 @@ It uses the same selection options as th command. See above for a description of these options. If +.Ar newuuid +is not specified, a random UUID value is derived from the timestamp +.Po see the +.Fl T +option +.Pc . +If .Fl a is used, then the header UUID is changed as well. .Pp Index: src/sbin/gpt/gpt_uuid.c diff -u src/sbin/gpt/gpt_uuid.c:1.21 src/sbin/gpt/gpt_uuid.c:1.22 --- src/sbin/gpt/gpt_uuid.c:1.21 Wed Sep 27 05:44:10 2023 +++ src/sbin/gpt/gpt_uuid.c Mon Aug 19 13:15:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.c,v 1.21 2023/09/27 09:44:10 riastradh Exp $ */ +/* $NetBSD: gpt_uuid.c,v 1.22 2024/08/19 17:15:38 christos 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.21 2023/09/27 09:44:10 riastradh Exp $"); +__RCSID("$NetBSD: gpt_uuid.c,v 1.22 2024/08/19 17:15:38 christos Exp $"); #endif #include <err.h> @@ -89,6 +89,7 @@ static const struct { { GPT_ENT_TYPE_NETBSD_RAIDFRAME, "raid", "NetBSD RAIDFrame component" }, { GPT_ENT_TYPE_NETBSD_SWAP, "swap", "NetBSD swap" }, + { GPT_ENT_TYPE_OPENBSD_DATA, "obsd", "OpenBSD data" }, { GPT_ENT_TYPE_VMWARE_VMKCORE, "vmcore", "VMware VMkernel core dump" }, { GPT_ENT_TYPE_VMWARE_VMFS, "vmfs", "VMware VMFS" }, { GPT_ENT_TYPE_VMWARE_RESERVED, "vmresered", "VMware reserved" }, Index: src/sbin/gpt/gpt_uuid.h diff -u src/sbin/gpt/gpt_uuid.h:1.10 src/sbin/gpt/gpt_uuid.h:1.11 --- src/sbin/gpt/gpt_uuid.h:1.10 Wed Sep 27 05:44:10 2023 +++ src/sbin/gpt/gpt_uuid.h Mon Aug 19 13:15:38 2024 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.h,v 1.10 2023/09/27 09:44:10 riastradh Exp $ */ +/* $NetBSD: gpt_uuid.h,v 1.11 2024/08/19 17:15:38 christos Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -71,6 +71,7 @@ typedef enum { GPT_TYPE_NETBSD_LFS, GPT_TYPE_NETBSD_RAIDFRAME, GPT_TYPE_NETBSD_SWAP, + GPT_TYPE_OPENBSD_DATA, GPT_TYPE_VMWARE_VMKCORE, GPT_TYPE_VMWARE_VMFS, GPT_TYPE_VMWARE_RESERVED Index: src/sbin/gpt/uuid.c diff -u src/sbin/gpt/uuid.c:1.1 src/sbin/gpt/uuid.c:1.2 --- src/sbin/gpt/uuid.c:1.1 Tue Jun 25 00:53:40 2019 +++ src/sbin/gpt/uuid.c Mon Aug 19 13:15:38 2024 @@ -33,7 +33,7 @@ __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $"); #endif #ifdef __RCSID -__RCSID("$NetBSD: uuid.c,v 1.1 2019/06/25 04:53:40 jnemeth Exp $"); +__RCSID("$NetBSD: uuid.c,v 1.2 2024/08/19 17:15:38 christos Exp $"); #endif #include <sys/types.h> @@ -53,7 +53,7 @@ static int cmd_uuid(gpt_t, int, char *[] static const char *uuidhelp[] = { "-a", - "[-b blocknr] [-i index] [-L label] [-s sectors] [-t type]", + "[-b blocknr] [-i index] [-L label] [-s sectors] [-t type] [-U newuuid]", }; struct gpt_cmd c_uuid = { @@ -70,7 +70,10 @@ change_ent(struct gpt_ent *ent, void *v, { static gpt_uuid_t uuidstore; - if (!backup) + if (v != NULL) { + memcpy(uuidstore, v, sizeof(uuidstore)); + } + else if (!backup) gpt_uuid_generate(NULL, uuidstore); memmove(ent->ent_guid, uuidstore, sizeof(ent->ent_guid)); } @@ -90,20 +93,35 @@ cmd_uuid(gpt_t gpt, int argc, char *argv { int ch, rc; struct gpt_find find; + gpt_uuid_t new_uuid; + void *v; + + if (gpt == NULL) + return usage(); memset(&find, 0, sizeof(find)); find.msg = "UUID changed"; /* Get the uuid options */ - while ((ch = getopt(argc, argv, GPT_FIND)) != -1) { - if (gpt == NULL || gpt_add_find(gpt, &find, ch) == -1) - return usage(); + v = NULL; + while ((ch = getopt(argc, argv, GPT_FIND "U:")) != -1) { + switch (ch) { + case 'U': + if (gpt_uuid_parse(optarg, new_uuid) == -1) + return usage(); + v = new_uuid; + break; + default: + if (gpt_add_find(gpt, &find, ch) == -1) + return usage(); + break; + } } - if (gpt == NULL || argc != optind) + if (argc != optind) return usage(); - rc = gpt_change_ent(gpt, &find, change_ent, NULL); + rc = gpt_change_ent(gpt, &find, change_ent, v); if (rc != 0) return rc;