diff options
author | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-05-06 14:22:50 +0000 |
---|---|---|
committer | Kenneth R Westerback <krw@cvs.openbsd.org> | 2022-05-06 14:22:50 +0000 |
commit | d3eccde1ef5b43e23ed27dfcc3d080ea90d5f228 (patch) | |
tree | 96af6e8a6386e3c969ed4a2e7d3f3276a1f94932 /sbin/fdisk/part.c | |
parent | 698643b42398beca0bf2d90ab5b34e6cccc2a261 (diff) |
When printing the GPT table, display "Microsoft basic data" instead of
"FAT12" for partition types that are mapped to GPT_UUID_MSDOS.
No intentional functional change.
Diffstat (limited to 'sbin/fdisk/part.c')
-rw-r--r-- | sbin/fdisk/part.c | 25 |
1 files changed, 15 insertions, 10 deletions
diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index b98756ef0c3..1a01d5b4113 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.125 2022/05/03 11:48:47 krw Exp $ */ +/* $OpenBSD: part.c,v 1.126 2022/05/06 14:22:49 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -457,21 +457,26 @@ const char * PRT_uuid_to_typename(const struct uuid *uuid) { static char typename[UUID_STR_LEN + 1]; + const uint8_t gpt_uuid_msdos[] = GPT_UUID_MSDOS; + struct uuid uuid_msdos; const struct gpt_type *gt; char *uuidstr; uint32_t status; - memset(typename, 0, sizeof(typename)); + uuid_dec_be(gpt_uuid_msdos, &uuid_msdos); + if (uuid_compare(&uuid_msdos, uuid, NULL) == 0) + return "Microsoft basic data"; gt = find_gpt_type(uuid); - if (gt == NULL) { - uuid_to_string(uuid, &uuidstr, &status); - if (status == uuid_s_ok) - strlcpy(typename, uuidstr, sizeof(typename)); - free(uuidstr); - } else { - strlcpy(typename, gt->gt_sname, sizeof(typename)); - } + if (gt != NULL) + return gt->gt_sname; + + uuid_to_string(uuid, &uuidstr, &status); + if (status == uuid_s_ok) + strlcpy(typename, uuidstr, sizeof(typename)); + else + typename[0] = '\0'; + free(uuidstr); return typename; } |