Module Name: src Committed By: martin Date: Thu Dec 20 14:58:10 UTC 2018
Modified Files: src/sbin/gpt: gpt_uuid.c gpt_uuid.h Log Message: Add a query function (for external code) to enumerate the know guids. Add recently added VMware GUIDs to the internal enum type. Fix some short names (bogus + duplicate). To generate a diff of this commit: cvs rdiff -u -r1.16 -r1.17 src/sbin/gpt/gpt_uuid.c cvs rdiff -u -r1.7 -r1.8 src/sbin/gpt/gpt_uuid.h 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_uuid.c diff -u src/sbin/gpt/gpt_uuid.c:1.16 src/sbin/gpt/gpt_uuid.c:1.17 --- src/sbin/gpt/gpt_uuid.c:1.16 Tue Nov 6 04:04:33 2018 +++ src/sbin/gpt/gpt_uuid.c Thu Dec 20 14:58:10 2018 @@ -1,4 +1,4 @@ -/* $NetBSD: gpt_uuid.c,v 1.16 2018/11/06 04:04:33 mrg Exp $ */ +/* $NetBSD: gpt_uuid.c,v 1.17 2018/12/20 14:58:10 martin 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.16 2018/11/06 04:04:33 mrg Exp $"); +__RCSID("$NetBSD: gpt_uuid.c,v 1.17 2018/12/20 14:58:10 martin Exp $"); #endif #include <err.h> @@ -87,9 +87,9 @@ static const struct { { GPT_ENT_TYPE_NETBSD_RAIDFRAME, "raid", "NetBSD RAIDFrame component" }, { GPT_ENT_TYPE_NETBSD_SWAP, "swap", "NetBSD swap" }, - { GPT_ENT_TYPE_VMWARE_VMKCORE, "swap", "VMware VMkernel core dump" }, - { GPT_ENT_TYPE_VMWARE_VMFS, "swap", "VMware VMFS" }, - { GPT_ENT_TYPE_VMWARE_RESERVED, "swap", "VMware reserved" }, + { 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" }, }; static void @@ -234,6 +234,23 @@ gpt_uuid_parse(const char *s, gpt_uuid_t return 0; } +size_t +gpt_uuid_query( + void (*func)(const char *uuid, const char *short_name, const char *desc)) +{ + size_t i; + char buf[64]; + + if (func != NULL) { + for (i = 0; i < __arraycount(gpt_nv); i++) { + gpt_uuid_numeric(buf, sizeof(buf), &gpt_nv[i].u); + (*func)(buf, gpt_nv[i].n, gpt_nv[i].d); + } + } + return __arraycount(gpt_nv); +} + +#ifndef GPT_UUID_QUERY_ONLY void gpt_uuid_help(const char *prefix) { @@ -323,3 +340,4 @@ gpt_uuid_generate(gpt_t gpt, gpt_uuid_t gpt_dce_to_uuid(&u, t); return 0; } +#endif Index: src/sbin/gpt/gpt_uuid.h diff -u src/sbin/gpt/gpt_uuid.h:1.7 src/sbin/gpt/gpt_uuid.h:1.8 --- src/sbin/gpt/gpt_uuid.h:1.7 Sun Dec 6 04:27:05 2015 +++ src/sbin/gpt/gpt_uuid.h Thu Dec 20 14:58:10 2018 @@ -67,7 +67,10 @@ typedef enum { GPT_TYPE_NETBSD_FFS, GPT_TYPE_NETBSD_LFS, GPT_TYPE_NETBSD_RAIDFRAME, - GPT_TYPE_NETBSD_SWAP + GPT_TYPE_NETBSD_SWAP, + GPT_TYPE_VMWARE_VMKCORE, + GPT_TYPE_VMWARE_VMFS, + GPT_TYPE_VMWARE_RESERVED } gpt_type_t; typedef uint8_t gpt_uuid_t[16]; @@ -98,6 +101,10 @@ int gpt_uuid_parse(const char *, gpt_uui struct gpt; int gpt_uuid_generate(struct gpt *, gpt_uuid_t); +/* returns number of entries, callback func may be NULL */ +size_t gpt_uuid_query( + void (*func)(const char *uuid, const char *short_name, const char *desc)); + void gpt_uuid_help(const char *); __END_DECLS