From 5c01edd69a20396eb63396437c55e26c6bf3deb7 Mon Sep 17 00:00:00 2001 From: krw Date: Fri, 6 May 2022 14:22:49 +0000 Subject: [PATCH] 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. --- sbin/fdisk/part.c | 25 +++++++++++++++---------- 1 file 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; } -- 2.20.1