1570af302Sopenharmony_ci// commit 7673acd31503016f2af93e187aac98da07af42b4 2014-03-12
2570af302Sopenharmony_ci// internal statfs struct was wrong on mips
3570af302Sopenharmony_ci// this test does various sanity checks to catch such bugs
4570af302Sopenharmony_ci#include <string.h>
5570af302Sopenharmony_ci#include <errno.h>
6570af302Sopenharmony_ci#include <sys/statvfs.h>
7570af302Sopenharmony_ci#include "test.h"
8570af302Sopenharmony_ci
9570af302Sopenharmony_ciint main(void)
10570af302Sopenharmony_ci{
11570af302Sopenharmony_ci	struct statvfs f;
12570af302Sopenharmony_ci
13570af302Sopenharmony_ci	if (statvfs("/", &f))
14570af302Sopenharmony_ci		t_error("statvfs(\"/\") failed: %s\n", strerror(errno));
15570af302Sopenharmony_ci	if (f.f_bsize == 0 || f.f_bsize > 1<<28)
16570af302Sopenharmony_ci		t_error("/ has bogus f_bsize: %lu\n", (unsigned long)f.f_bsize);
17570af302Sopenharmony_ci	if (f.f_blocks == 0)
18570af302Sopenharmony_ci		t_error("/ has 0 blocks\n");
19570af302Sopenharmony_ci	if (f.f_blocks < f.f_bfree)
20570af302Sopenharmony_ci		t_error("/ has more free blocks (%llu) than total blocks (%llu)\n",
21570af302Sopenharmony_ci			(unsigned long long)f.f_bfree, (unsigned long long)f.f_blocks);
22570af302Sopenharmony_ci	if (f.f_blocks < f.f_bavail)
23570af302Sopenharmony_ci		t_error("/ has more avail blocks (%llu) than total blocks (%llu)\n",
24570af302Sopenharmony_ci			(unsigned long long)f.f_bavail, (unsigned long long)f.f_blocks);
25570af302Sopenharmony_ci	if (f.f_files == 0)
26570af302Sopenharmony_ci		t_error("/ has 0 file nodes\n");
27570af302Sopenharmony_ci	if (f.f_files < f.f_ffree)
28570af302Sopenharmony_ci		t_error("/ has more free file nodes (%llu) than total file nodes (%llu)\n",
29570af302Sopenharmony_ci			(unsigned long long)f.f_ffree, (unsigned long long)f.f_files);
30570af302Sopenharmony_ci	if (f.f_files < f.f_favail)
31570af302Sopenharmony_ci		t_error("/ has more avail file nodes (%llu) than total file nodes (%llu)\n",
32570af302Sopenharmony_ci			(unsigned long long)f.f_favail, (unsigned long long)f.f_files);
33570af302Sopenharmony_ci	if (f.f_namemax > 1<<16 || f.f_namemax < 8)
34570af302Sopenharmony_ci		t_error("/ has bogus f_namemax: %lu\n", (unsigned long)f.f_namemax);
35570af302Sopenharmony_ci
36570af302Sopenharmony_ci	return t_status;
37570af302Sopenharmony_ci}
38