Module Name: src
Committed By: christos
Date: Sun Nov 29 00:34:39 UTC 2015
Modified Files:
src/sbin/gpt: map.c
Log Message:
print the current map type.
To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sbin/gpt/map.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/map.c
diff -u src/sbin/gpt/map.c:1.8 src/sbin/gpt/map.c:1.9
--- src/sbin/gpt/map.c:1.8 Sat Nov 28 19:15:12 2015
+++ src/sbin/gpt/map.c Sat Nov 28 19:34:39 2015
@@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/map.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
#endif
#ifdef __RCSID
-__RCSID("$NetBSD: map.c,v 1.8 2015/11/29 00:15:12 christos Exp $");
+__RCSID("$NetBSD: map.c,v 1.9 2015/11/29 00:34:39 christos Exp $");
#endif
#include <sys/types.h>
@@ -65,6 +65,26 @@ mkmap(off_t start, off_t size, int type)
return (m);
}
+static const char *maptypes[] = {
+ "unused",
+ "mbr",
+ "mbr partition",
+ "primary gpt header",
+ "secondary gpt header",
+ "primary gpt table",
+ "secondary gpt table",
+ "gpt partition",
+ "protective mbr",
+};
+
+static const char *
+map_type(int t)
+{
+ if ((size_t)t >= __arraycount(maptypes))
+ return "*unknown*";
+ return maptypes[t];
+}
+
map_t *
map_add(off_t start, off_t size, int type, void *data)
{
@@ -99,17 +119,14 @@ map_add(off_t start, off_t size, int typ
return (n);
}
-
- switch (n->map_type) {
- case MAP_TYPE_MBR_PART:
- case MAP_TYPE_GPT_PART:
+ if (n->map_type != MAP_TYPE_UNUSED) {
+ if (n->map_type != MAP_TYPE_MBR_PART ||
+ type != MAP_TYPE_GPT_PART) {
+ warnx("bogus map current=%s new=%s",
+ map_type(n->map_type), map_type(type));
+ return (NULL);
+ }
n->map_type = MAP_TYPE_UNUSED;
- break;
- case MAP_TYPE_UNUSED:
- break;
- default:
- warnx("bogus map %#x", n->map_type);
- return (NULL);
}
m = mkmap(start, size, type);