nvram: fix displayed info about NVRAM size
authorRafał Miłecki <zajec5@gmail.com>
Wed, 8 Jul 2015 05:45:09 +0000 (05:45 +0000)
committerRafał Miłecki <zajec5@gmail.com>
Wed, 8 Jul 2015 05:45:09 +0000 (05:45 +0000)
Use actual partition size and content offset to calculate it.

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Backport of r46260

SVN-Revision: 46261

package/utils/nvram/src/cli.c

index 66ef904885854894b3d9dda6b40a1bd3e5c832f2..488d641cfcfef49751dd94c2481d3617d5eb6cfb 100644 (file)
@@ -123,8 +123,8 @@ static int do_info(nvram_handle_t *nvram)
        printf("NCDL values:   0x%08X\n\n", hdr->config_ncdl);
 
        printf("%i bytes used / %i bytes available (%.2f%%)\n",
-               hdr->len, NVRAM_SPACE - hdr->len,
-               (100.00 / (double)NVRAM_SPACE) * (double)hdr->len);
+               hdr->len, nvram->length - nvram->offset - hdr->len,
+               (100.00 / (double)(nvram->length - nvram->offset)) * (double)hdr->len);
 
        return 0;
 }