Show the paritition types that we recognize in human readable format. eg:

pluto2# gpt show da0
     start       end      size  contents
         0         0         1  PMBR
         1         1         1  Pri GPT header
         2        33        32  Pri GPT table
        34    401595    401562  GPT part - EFI System partition
    401596    925883    524288  GPT part - FreeBSD ufs partition
    925884   9314491   8388608  GPT part - FreeBSD swap partition
...
It'll print a plain uuid string for unrecognized types.
This commit is contained in:
Peter Wemm 2003-02-13 01:00:26 +00:00
parent 7ac1f02eed
commit 7201d7b009

View File

@ -49,6 +49,33 @@ usage_show(void)
exit(1);
}
static const char *
friendly(uuid_t *t)
{
uuid_t efi_slice = GPT_ENT_TYPE_EFI;
uuid_t freebsd = GPT_ENT_TYPE_FREEBSD;
uuid_t swap = GPT_ENT_TYPE_FREEBSD_SWAP;
uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS;
uuid_t vinum = GPT_ENT_TYPE_FREEBSD_VINUM;
static char buf[80];
char *s;
if (memcmp(t, &efi_slice, sizeof(uuid_t)) == 0)
return "EFI System partition";
else if (memcmp(t, &freebsd, sizeof(uuid_t)) == 0)
return "FreeBSD disklabel container";
else if (memcmp(t, &swap, sizeof(uuid_t)) == 0)
return "FreeBSD swap partition";
else if (memcmp(t, &ufs, sizeof(uuid_t)) == 0)
return "FreeBSD ufs partition";
else if (memcmp(t, &vinum, sizeof(uuid_t)) == 0)
return "FreeBSD vinum partition";
uuid_to_string(t, &s, NULL);
strlcpy(buf, s, sizeof buf);
free(s);
return buf;
}
static void
show(int fd __unused)
{
@ -56,7 +83,6 @@ show(int fd __unused)
map_t *m, *p;
struct mbr *mbr;
struct gpt_ent *ent;
char *s;
unsigned int i;
printf(" %*s", lbawidth, "start");
@ -107,9 +133,7 @@ show(int fd __unused)
case MAP_TYPE_GPT_PART:
printf("GPT part ");
ent = m->map_data;
uuid_to_string(&ent->ent_type, &s, NULL);
printf("%s", s);
free(s);
printf("- %s", friendly(&ent->ent_type));
break;
case MAP_TYPE_PMBR:
printf("PMBR");