From bcf1bfabdef4481d4748e6c4a82b579af628fd75 Mon Sep 17 00:00:00 2001 From: Bernhard Reutner-Fischer Date: Thu, 17 Jan 2013 22:44:00 +0100 Subject: statfs: support f_frsize closes bugzilla #5834 Signed-off-by: Bernhard Reutner-Fischer --- test/misc/Makefile.in | 6 ++++++ test/misc/tst-statfs.c | 33 +++++++++++++++++++++++++++++++++ test/misc/tst-statvfs.c | 28 ++++++++++++++++++++++++++++ 3 files changed, 67 insertions(+) create mode 100644 test/misc/tst-statfs.c create mode 100644 test/misc/tst-statvfs.c (limited to 'test/misc') diff --git a/test/misc/Makefile.in b/test/misc/Makefile.in index 226321131..9b74d222a 100644 --- a/test/misc/Makefile.in +++ b/test/misc/Makefile.in @@ -9,6 +9,12 @@ CFLAGS_dirent64 := -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS DODIFF_dirent := 1 DODIFF_dirent64 := 1 +DODIFF_tst-statfs := 1 +DODIFF_tst-statvfs := 1 OPTS_bug-glob1 := $(PWD) OPTS_tst-fnmatch := < tst-fnmatch.input + +MNTENTS = $(shell mount | while read dev on mp rest; do echo $$mp; done) +OPTS_tst-statfs := $(MNTENTS) +OPTS_tst-statvfs := $(MNTENTS) diff --git a/test/misc/tst-statfs.c b/test/misc/tst-statfs.c new file mode 100644 index 000000000..44ab3aa77 --- /dev/null +++ b/test/misc/tst-statfs.c @@ -0,0 +1,33 @@ +#define _FILE_OFFSET_BITS 64 + +#include +#include +#include +#include +#include + +int +main(int argc, char* argv[]) +{ + struct statfs s; + int ret = 0, i; + + for (i = 1; i < argc; i++) { + if (statfs(argv[i], &s) != 0) { + fprintf(stderr, "%s: %s: statfs failed. %s\n", + *argv, argv[i], strerror(errno)); + exit(EXIT_FAILURE); + } + ++ret; + printf("statfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n", + argv[i], s.f_blocks, s.f_bfree, s.f_bsize); +#ifdef _STATFS_F_FRSIZE + printf("\tfrsize=%lld\n", s.f_frsize); +#elif defined __mips__ + printf("\tfrsize=mips, unsupported?\n"); +#else +# error no _STATFS_F_FRSIZE +#endif + } + exit(ret ? EXIT_SUCCESS : EXIT_FAILURE); +} diff --git a/test/misc/tst-statvfs.c b/test/misc/tst-statvfs.c new file mode 100644 index 000000000..c1e8fde4e --- /dev/null +++ b/test/misc/tst-statvfs.c @@ -0,0 +1,28 @@ +#define _FILE_OFFSET_BITS 64 + +#include +#include +#include +#include +#include + +int +main(int argc, char* argv[]) +{ + struct statvfs s; + int i; + + for (i = 1; i < argc; i++) { + if (statvfs(argv[i], &s) != 0) { + fprintf(stderr, "%s: %s: statvfs failed. %s\n", + *argv, argv[i], strerror(errno)); + exit(EXIT_FAILURE); + } + printf("statvfs %s:\n\tblocks=%lld\n\tblkfree=%lld\n\tbsize=%d\n", + argv[i], s.f_blocks, s.f_bfree, s.f_bsize); +#if 1 // def _STATFS_F_FRSIZE + printf("\tfrsize=%lld\n", s.f_frsize); +#endif + } + exit(EXIT_SUCCESS); +} -- cgit v1.2.3