Add GPTPARTATTR_MS_* defines for Microsoft basic data attributes
authorkrw <krw@openbsd.org>
Thu, 15 Sep 2022 10:10:14 +0000 (10:10 +0000)
committerkrw <krw@openbsd.org>
Thu, 15 Sep 2022 10:10:14 +0000 (10:10 +0000)
and make 'fdisk -v' display their names (NoAutoMount, Hidden,
Shadow, ReadOnly).

Shift 1ULL instead of 1 to make it clear these are uint64_t
flags. Makes clang happier.

sbin/fdisk/gpt.c
sys/sys/disklabel.h

index c3f66ca..3800e73 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: gpt.c,v 1.81 2022/09/11 11:47:55 krw Exp $    */
+/*     $OpenBSD: gpt.c,v 1.82 2022/09/15 10:10:14 krw Exp $    */
 /*
  * Copyright (c) 2015 Markus Muller <mmu@grummel.net>
  * Copyright (c) 2015 Kenneth R Westerback <krw@openbsd.org>
@@ -434,7 +434,9 @@ GPT_print_parthdr(const int verbosity)
 void
 GPT_print_part(const unsigned int pn, const char *units, const int verbosity)
 {
+       const uint8_t            gpt_uuid_msdos[] = GPT_UUID_MSDOS;
        const struct unit_type  *ut;
+       struct uuid              uuid_msdos;
        char                    *guidstr = NULL;
        double                   size;
        uint64_t                 attrs, end, start;
@@ -463,7 +465,19 @@ GPT_print_part(const unsigned int pn, const char *units, const int verbosity)
                        if (attrs & GPTPARTATTR_IGNORE)
                                printf("Ignore ");
                        if (attrs & GPTPARTATTR_BOOTABLE)
-                               printf("Bootable");
+                               printf("Bootable ");
+                       uuid_dec_be(gpt_uuid_msdos, &uuid_msdos);
+                       if (uuid_compare(&uuid_msdos, &gp[pn].gp_type, NULL) ==
+                           0) {
+                               if (attrs & GPTPARTATTR_MS_READONLY)
+                                       printf("ReadOnly " );
+                               if (attrs & GPTPARTATTR_MS_SHADOW)
+                                       printf("Shadow ");
+                               if (attrs & GPTPARTATTR_MS_HIDDEN)
+                                       printf("Hidden ");
+                               if (attrs & GPTPARTATTR_MS_NOAUTOMOUNT)
+                                       printf("NoAutoMount ");
+                       }
                        printf("\n");
                }
        }
index cff3d00..e66559b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: disklabel.h,v 1.81 2022/09/11 11:47:55 krw Exp $      */
+/*     $OpenBSD: disklabel.h,v 1.82 2022/09/15 10:10:14 krw Exp $      */
 /*     $NetBSD: disklabel.h,v 1.41 1996/05/10 23:07:37 mark Exp $      */
 
 /*
@@ -340,9 +340,14 @@ struct partinfo {
                                /* ASCII string "EFI PART" encoded as 64-bit */
 #define        GPTREVISION             0x10000         /* GPT header version 1.0 */
 #define        NGPTPARTITIONS          128
-#define        GPTPARTATTR_REQUIRED    (1 << 0)
-#define        GPTPARTATTR_IGNORE      (1 << 1)
-#define        GPTPARTATTR_BOOTABLE    (1 << 2)
+#define        GPTPARTATTR_REQUIRED            (1ULL << 0)
+#define        GPTPARTATTR_IGNORE              (1ULL << 1)
+#define        GPTPARTATTR_BOOTABLE            (1ULL << 2)
+#define        GPTPARTATTR_MS_READONLY         (1ULL << 60)
+#define        GPTPARTATTR_MS_SHADOW           (1ULL << 61)
+#define        GPTPARTATTR_MS_HIDDEN           (1ULL << 62)
+#define        GPTPARTATTR_MS_NOAUTOMOUNT      (1ULL << 63)
+
 #define        GPTDOSACTIVE            0x2
 #define        GPTMINHDRSIZE           92
 #define        GPTMINPARTSIZE          128