Source-Changes-HG archive

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

[src/trunk]: src/sbin/gpt For the "show -i <entry>" subcommand, print Start a...



details:   https://anonhg.NetBSD.org/src/rev/23ab29424b79
branches:  trunk
changeset: 325150:23ab29424b79
user:      jnemeth <jnemeth%NetBSD.org@localhost>
date:      Mon Dec 09 01:35:02 2013 +0000

description:
For the "show -i <entry>" subcommand, print Start and Size both in
terms of number of sectors and bytes.

diffstat:

 sbin/gpt/gpt.8  |   3 ++-
 sbin/gpt/show.c |  21 +++++++++++++++++----
 2 files changed, 19 insertions(+), 5 deletions(-)

diffs (62 lines):

diff -r e4ae0a7571f2 -r 23ab29424b79 sbin/gpt/gpt.8
--- a/sbin/gpt/gpt.8    Sun Dec 08 21:29:15 2013 +0000
+++ b/sbin/gpt/gpt.8    Mon Dec 09 01:35:02 2013 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: gpt.8,v 1.23 2013/12/08 09:32:51 jnemeth Exp $
+.\" $NetBSD: gpt.8,v 1.24 2013/12/09 01:35:02 jnemeth Exp $
 .\"
 .\" Copyright (c) 2002 Marcel Moolenaar
 .\" All rights reserved.
@@ -365,6 +365,7 @@
 With the
 .Fl i
 option, all the details of a particular GPT partition will be displayed.
+The format of this display is subject to change.
 None of the options have any effect on non-GPT partitions.
 The order of precedence for the options are:
 .Fl i ,
diff -r e4ae0a7571f2 -r 23ab29424b79 sbin/gpt/show.c
--- a/sbin/gpt/show.c   Sun Dec 08 21:29:15 2013 +0000
+++ b/sbin/gpt/show.c   Mon Dec 09 01:35:02 2013 +0000
@@ -29,7 +29,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.13 2013/12/08 08:30:01 jnemeth Exp $");
+__RCSID("$NetBSD: show.c,v 1.14 2013/12/09 01:35:02 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -223,7 +223,7 @@
        map_t *m;
        struct gpt_ent *ent;
        const char *s1;
-       char *s2;
+       char *s2, human_num[5];
 
        for (m = map_first(); m != NULL; m = m->map_next)
                if (entry == m->map_index)
@@ -236,8 +236,21 @@
        ent = m->map_data;
 
        printf("Details for index %d:\n", entry);
-       printf("Start: %llu\n", (long long)m->map_start);
-       printf("Size: %llu\n", (long long)m->map_size);
+       if (humanize_number(human_num, 5, (int64_t)(m->map_start * secsz),
+           "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
+               human_num[0] = '\0';
+       if (human_num[0] != '\0')
+               printf("Start: %llu (%s)\n", (long long)m->map_start,
+                   human_num);
+       else
+               printf("Start: %llu\n", (long long)m->map_start);
+       if (humanize_number(human_num, 5, (int64_t)(m->map_size * secsz),
+           "", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
+               human_num[0] = '\0';
+       if (human_num[0] != '\0')
+               printf("Size: %llu (%s)\n", (long long)m->map_size, human_num);
+       else
+               printf("Size: %llu\n", (long long)m->map_size);
 
        le_uuid_dec(ent->ent_type, &type);
        s1 = friendly(&type);



Home | Main Index | Thread Index | Old Index