From 65d6e8871c95e822ad956b2ec2bfee2a3f3b66bf Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 27 Sep 2018 17:01:10 -0600 Subject: [PATCH] apps/examples/fstest: Call statfs() and show state of file system on each loop. --- examples/fstest/Kconfig | 3 +-- examples/fstest/fstest_main.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/examples/fstest/Kconfig b/examples/fstest/Kconfig index be9f31a5b..28505184c 100644 --- a/examples/fstest/Kconfig +++ b/examples/fstest/Kconfig @@ -42,7 +42,7 @@ config EXAMPLES_FSTEST_NLOOPS config EXAMPLES_FSTEST_SPIFFS bool "Enable SPIFFS testing" - default n + default y depends on FS_SPIFFS ---help--- SPIFFS garbage collection and integrity checking will be performed @@ -51,7 +51,6 @@ config EXAMPLES_FSTEST_SPIFFS If this option is not selected then the SPIFFS FLASH will likely become full before you finish the test. - config EXAMPLES_FSTEST_VERBOSE bool "Verbose output" default n diff --git a/examples/fstest/fstest_main.c b/examples/fstest/fstest_main.c index 5abe902b0..d658da122 100644 --- a/examples/fstest/fstest_main.c +++ b/examples/fstest/fstest_main.c @@ -41,6 +41,7 @@ #include #include +#include #include #include @@ -823,6 +824,7 @@ int main(int argc, FAR char *argv[]) int fstest_main(int argc, char *argv[]) #endif { + struct statfs buf; unsigned int i; int ret; @@ -923,6 +925,24 @@ int fstest_main(int argc, char *argv[]) #endif } + /* Show file system usage */ + + ret = statfs(g_mountdir, &buf); + if (ret < 0) + { + printf("ERROR: statfs failed: %d\n", errno); + } + else + { + printf("File System:\n"); + printf(" Block Size: &lu\n", (unsigned long)buf.f_bsize); + printf(" No. Blocks: %lu\n", (unsigned long)buf.f_blocks); + printf(" Free Blocks: %ld\n", (long)buf.f_bfree); + printf(" Avail. Blocks: %ld\n", (long)buf.f_bavail); + printf(" No. File Nodes: %ld\n", (long)buf.f_files); + printf(" Free File Nodes: %ld\n", (long)buf.f_ffree); + } + /* Show memory usage */ fstest_loopmemusage();