]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: use 2 decimal places for size in disk summary
authorKarel Zak <kzak@redhat.com>
Tue, 12 Feb 2019 13:21:54 +0000 (14:21 +0100)
committerKarel Zak <kzak@redhat.com>
Tue, 12 Feb 2019 13:21:54 +0000 (14:21 +0100)
 In the disk summary it seems nice, but I'm not sure about lists (SIZE
 columns). It seems more readable to keep the lists with one decimal
 place only. New output:

  # sfdisk --list /dev/sda

 Old output:
  Disk /dev/sda: 223.6 GiB, 240057409536 bytes, 468862128 sectors

 New output:
  Disk /dev/sda: 223.58 GiB, 240057409536 bytes, 468862128 sectors

 The rest is unchanged:
  ...
  Device         Start       End   Sectors   Size Type
  /dev/sda1       2048    411647    409600   200M EFI System
  /dev/sda2     411648    821247    409600   200M Linux filesystem
  /dev/sda3     821248 274087935 273266688 130.3G Linux filesystem
  /dev/sda4  274087936 378945535 104857600    50G Linux filesystem
  /dev/sda5  378945536 468862094  89916559  42.9G Linux filesystem

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1673452
Signed-off-by: Karel Zak <kzak@redhat.com>
disk-utils/cfdisk.c
disk-utils/fdisk-list.c

index 25f8e1a9e8fa4ab106661340f3629d85ea40ea11..ff1bc44c1d635a9632a45d697674f38b2d756847 100644 (file)
@@ -1699,7 +1699,8 @@ static int ui_refresh(struct cfdisk *cf)
        if (!ui_enabled)
                return -EINVAL;
 
-       strsz = size_to_human_string(SIZE_SUFFIX_SPACE
+       strsz = size_to_human_string(SIZE_DECIMAL_2DIGITS
+                               | SIZE_SUFFIX_SPACE
                                | SIZE_SUFFIX_3LETTER, bytes);
 
        lb = fdisk_get_label(cf->cxt, NULL);
index 916621d752aac9537cbe772a44f67328dceabe4e..6bc52d704995f0012ee10960b299c5cfc23e5c7a 100644 (file)
@@ -53,7 +53,8 @@ void list_disk_geometry(struct fdisk_context *cxt)
 {
        struct fdisk_label *lb = fdisk_get_label(cxt, NULL);
        uint64_t bytes = fdisk_get_nsectors(cxt) * fdisk_get_sector_size(cxt);
-       char *strsz = size_to_human_string(SIZE_SUFFIX_SPACE
+       char *strsz = size_to_human_string(SIZE_DECIMAL_2DIGITS
+                                          | SIZE_SUFFIX_SPACE
                                           | SIZE_SUFFIX_3LETTER, bytes);
 
        color_scheme_enable("header", UL_COLOR_BOLD);
@@ -283,8 +284,9 @@ void list_freespace(struct fdisk_context *cxt)
        }
 
        bytes = sumsize * fdisk_get_sector_size(cxt);
-       strsz = size_to_human_string(SIZE_SUFFIX_SPACE
-                                          | SIZE_SUFFIX_3LETTER, bytes);
+       strsz = size_to_human_string(SIZE_DECIMAL_2DIGITS
+                                    | SIZE_SUFFIX_SPACE
+                                    | SIZE_SUFFIX_3LETTER, bytes);
 
        color_scheme_enable("header", UL_COLOR_BOLD);
        fdisk_info(cxt, _("Unpartitioned space %s: %s, %ju bytes, %ju sectors"),