From b83baa43dc8eae078a58b3c2db06d93ca3776623 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Fri, 17 Feb 2017 10:53:24 -0600 Subject: [PATCH] examples/stat: Add test for fstatfs(). --- examples/stat/stat_main.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/examples/stat/stat_main.c b/examples/stat/stat_main.c index a0aca2504..94dbd6933 100644 --- a/examples/stat/stat_main.c +++ b/examples/stat/stat_main.c @@ -281,7 +281,7 @@ int stat_main(int argc, char *argv[]) { int fd; - printf("\nOpen(%s) and test fstat()\n", path); + printf("\nOpen(%s)\n", path); fd = open(path, O_RDONLY); if (fd < 0) { @@ -292,6 +292,9 @@ int stat_main(int argc, char *argv[]) return EXIT_FAILURE; } + /* Try fstat */ + + printf("\nTest fstat(%s)\n", path); ret = fstat(fd, &statbuf); if (ret < 0) { @@ -305,6 +308,22 @@ int stat_main(int argc, char *argv[]) dump_stat(&statbuf); } + /* Try fstatfs */ + + printf("\nTest fstatfs(%s)\n", path); + ret = fstatfs(fd, &statfsbuf); + if (ret < 0) + { + int errcode = errno; + fprintf(stderr, + "ERROR: fstatfs(%s) failed: %d\n", + path, errcode); + } + else + { + dump_statfs(&statfsbuf); + } + close(fd); stepusage(); }