From b55fea5379cc05fd0f35e7190c5c1731e92f2a79 Mon Sep 17 00:00:00 2001 From: "S.J.R. van Schaik" Date: Wed, 14 Jun 2017 13:14:34 +0200 Subject: [PATCH] shell: flash: display capacity and usage --- source/shell/flash.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source/shell/flash.c b/source/shell/flash.c index bebffd5..5c491c1 100644 --- a/source/shell/flash.c +++ b/source/shell/flash.c @@ -105,13 +105,14 @@ static void do_flash_probe(const char *s) } if (!(flash = flash_probe())) { - fprintf(stderr, "error: unable to probe flash device.\n"); + fprintf(stderr, "error: unable to probe the flash device.\n"); + return; } } static void do_flash_info(const char *s) { - size_t size; + size_t size, capacity; (void)s; @@ -121,10 +122,10 @@ static void do_flash_info(const char *s) } size = flash_get_size(flash); + capacity = flash_get_capacity(flash); - printf("Capacity: %" PRSZu " blocks (", size / (4 * KIB)); - print_size(size); - printf(")\n"); + printf(" size: %" PRSZu "/%" PRSZu " bytes (%" PRSZu "%% usage)\n", + size, capacity, 100 * size / capacity); } static void do_flash_read(const char *s)