Module Name: src
Committed By: jnemeth
Date: Tue Sep 30 22:56:36 UTC 2014
Modified Files:
src/sbin/gpt: gpt_uuid.c show.c
Log Message:
correctly show partition type in the new world order
To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sbin/gpt/gpt_uuid.c
cvs rdiff -u -r1.20 -r1.21 src/sbin/gpt/show.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_uuid.c
diff -u src/sbin/gpt/gpt_uuid.c:1.1 src/sbin/gpt/gpt_uuid.c:1.2
--- src/sbin/gpt/gpt_uuid.c:1.1 Tue Sep 30 17:59:59 2014
+++ src/sbin/gpt/gpt_uuid.c Tue Sep 30 22:56:36 2014
@@ -1,4 +1,4 @@
-/* $NetBSD: gpt_uuid.c,v 1.1 2014/09/30 17:59:59 christos Exp $ */
+/* $NetBSD: gpt_uuid.c,v 1.2 2014/09/30 22:56:36 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.1 2014/09/30 17:59:59 christos Exp $");
+__RCSID("$NetBSD: gpt_uuid.c,v 1.2 2014/09/30 22:56:36 jnemeth Exp $");
#endif
#include <stdio.h>
@@ -133,6 +133,17 @@ gpt_uuid_symbolic(char *buf, size_t bufs
return -1;
}
+static int
+gpt_uuid_descriptive(char *buf, size_t bufsiz, const struct dce_uuid *u)
+{
+ size_t i;
+
+ for (i = 0; i < __arraycount(gpt_nv); i++)
+ if (memcmp(&gpt_nv[i].u, u, sizeof(*u)) == 0)
+ return strlcpy(buf, gpt_nv[i].d, bufsiz);
+ return -1;
+}
+
int
gpt_uuid_snprintf(char *buf, size_t bufsiz, const char *fmt,
const gpt_uuid_t uu)
@@ -145,6 +156,11 @@ gpt_uuid_snprintf(char *buf, size_t bufs
if ((r = gpt_uuid_symbolic(buf, bufsiz, &u)) != -1)
return r;
}
+ if (fmt[1] == 'l') {
+ int r;
+ if ((r = gpt_uuid_descriptive(buf, bufsiz, &u)) != -1)
+ return r;
+ }
return gpt_uuid_numeric(buf, bufsiz, &u);
}
Index: src/sbin/gpt/show.c
diff -u src/sbin/gpt/show.c:1.20 src/sbin/gpt/show.c:1.21
--- src/sbin/gpt/show.c:1.20 Tue Sep 30 20:23:23 2014
+++ src/sbin/gpt/show.c Tue Sep 30 22:56:36 2014
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: show.c,v 1.20 2014/09/30 20:23:23 jnemeth Exp $");
+__RCSID("$NetBSD: show.c,v 1.21 2014/09/30 22:56:36 jnemeth Exp $");
#endif
#include <sys/types.h>
@@ -135,8 +135,10 @@ show(void)
printf("- %s", buf);
} else {
char buf[128];
- gpt_uuid_snprintf(
- buf, sizeof(buf), "%s", ent->ent_type);
+ if (show_uuid || gpt_uuid_snprintf(buf,
+ sizeof(buf), "%ls", ent->ent_type) == -1)
+ gpt_uuid_snprintf(buf, sizeof(buf),
+ "%d", ent->ent_type);
printf("- %s", buf);
}
break;