]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fstrim: use human readable sizes in verbose output
authorKarel Zak <kzak@redhat.com>
Mon, 28 Jan 2013 08:25:08 +0000 (09:25 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 28 Jan 2013 08:25:08 +0000 (09:25 +0100)
  # fstrim -v /home
  /home: 513.9 MiB (538828800 bytes) were trimmed

Reported-by: member graysky <graysky@archlinux.us>
Signed-off-by: Karel Zak <kzak@redhat.com>
sys-utils/fstrim.c

index d3e446bd8fcf3ea865b0fdec38198a1e535b0ec1..3fe52fc62b9dbc2624eb2d7580f54fc1eaf55b39 100644 (file)
@@ -144,10 +144,16 @@ int main(int argc, char **argv)
        if (ioctl(fd, FITRIM, &range))
                err(EXIT_FAILURE, _("%s: FITRIM ioctl failed"), path);
 
-       if (verbose)
+       if (verbose) {
+               char *str = size_to_human_string(SIZE_SUFFIX_3LETTER |
+                                                SIZE_SUFFIX_SPACE,
+                                                (uint64_t) range.len);
                /* TRANSLATORS: The standard value here is a very large number. */
-               printf(_("%s: %" PRIu64 " bytes were trimmed\n"),
-                                               path, (uint64_t) range.len);
+               printf(_("%s: %s (%" PRIu64 " bytes) were trimmed\n"),
+                                               path, str,
+                                               (uint64_t) range.len);
+               free(str);
+       }
        close(fd);
        return EXIT_SUCCESS;
 }