Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sbin/gpt Improve "show -a" display: split human readable Typ...



details:   https://anonhg.NetBSD.org/src/rev/79fdc5548e89
branches:  trunk
changeset: 812661:79fdc5548e89
user:      martin <martin%NetBSD.org@localhost>
date:      Sat Dec 26 13:08:45 2015 +0000

description:
Improve "show -a" display: split human readable Type: field from the Type-GUID
to avoid wrapping in the common case; add a human readable Size: display.

diffstat:

 sbin/gpt/show.c |  23 +++++++++++++++++++++--
 1 files changed, 21 insertions(+), 2 deletions(-)

diffs (51 lines):

diff -r d5430d127957 -r 79fdc5548e89 sbin/gpt/show.c
--- a/sbin/gpt/show.c   Sat Dec 26 12:59:00 2015 +0000
+++ b/sbin/gpt/show.c   Sat Dec 26 13:08:45 2015 +0000
@@ -33,7 +33,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: show.c,v 1.33 2015/12/25 12:16:03 wiz Exp $");
+__RCSID("$NetBSD: show.c,v 1.34 2015/12/26 13:08:45 martin Exp $");
 #endif
 
 #include <sys/types.h>
@@ -222,6 +222,9 @@
        map_t m;
        struct gpt_ent *ent;
        char s1[128], s2[128];
+#ifdef HN_AUTOSCALE
+       char human_num[8];
+#endif
        uint8_t utfbuf[__arraycount(ent->ent_name) * 3 + 1];
 #define PFX "                                 "
 
@@ -247,11 +250,27 @@
                        gpt_uuid_snprintf(s2, sizeof(s2), "%d", ent->ent_type);
                        if (strcmp(s1, s2) == 0)
                                strlcpy(s1, "unknown", sizeof(s1));
-                       printf(PFX "Type: %s (%s)\n", s1, s2);
+                       printf(PFX "Type: %s\n", s1);
+                       printf(PFX "TypeID: %s\n", s2);
 
                        gpt_uuid_snprintf(s2, sizeof(s1), "%d", ent->ent_guid);
                        printf(PFX "GUID: %s\n", s2);
 
+                       printf(PFX "Size: ");
+#ifdef HN_AUTOSCALE
+                       if (humanize_number(human_num, sizeof(human_num),
+                           (int64_t)(m->map_size * gpt->secsz),
+                           "", HN_AUTOSCALE, HN_B) < 0) {
+#endif
+                               printf("%ju",
+                                   (int64_t)(m->map_size * gpt->secsz));
+#ifdef HN_AUTOSCALE
+                       } else {
+                               printf("%s", human_num);
+                       }
+#endif
+                       putchar('\n');
+
                        utf16_to_utf8(ent->ent_name, utfbuf, sizeof(utfbuf));
                        printf(PFX "Label: %s\n", (char *)utfbuf);
 



Home | Main Index | Thread Index | Old Index