|
Szabolcs Nagy |
9f72a5 |
// commit 7673acd31503016f2af93e187aac98da07af42b4 2014-03-12
|
|
Szabolcs Nagy |
9f72a5 |
// internal statfs struct was wrong on mips
|
|
Szabolcs Nagy |
9f72a5 |
// this test does various sanity checks to catch such bugs
|
|
Szabolcs Nagy |
9f72a5 |
#include <string.h>
|
|
Szabolcs Nagy |
9f72a5 |
#include <errno.h>
|
|
Szabolcs Nagy |
9f72a5 |
#include <sys/statvfs.h>
|
|
Szabolcs Nagy |
9f72a5 |
#include "test.h"
|
|
Szabolcs Nagy |
9f72a5 |
|
|
Szabolcs Nagy |
9f72a5 |
int main(void)
|
|
Szabolcs Nagy |
9f72a5 |
{
|
|
Szabolcs Nagy |
9f72a5 |
struct statvfs f;
|
|
Szabolcs Nagy |
9f72a5 |
|
|
Szabolcs Nagy |
9f72a5 |
if (statvfs("/", &f))
|
|
Szabolcs Nagy |
9f72a5 |
t_error("statvfs(\"/\") failed: %s\n", strerror(errno));
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_bsize == 0 || f.f_bsize > 1<<28)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has bogus f_bsize: %lu\n", (unsigned long)f.f_bsize);
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_blocks == 0)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has 0 blocks\n");
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_blocks < f.f_bfree)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has more free blocks (%llu) than total blocks (%llu)\n",
|
|
Szabolcs Nagy |
9f72a5 |
(unsigned long long)f.f_bfree, (unsigned long long)f.f_blocks);
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_blocks < f.f_bavail)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has more avail blocks (%llu) than total blocks (%llu)\n",
|
|
Szabolcs Nagy |
9f72a5 |
(unsigned long long)f.f_bavail, (unsigned long long)f.f_blocks);
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_files == 0)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has 0 file nodes\n");
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_files < f.f_ffree)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has more free file nodes (%llu) than total file nodes (%llu)\n",
|
|
Szabolcs Nagy |
9f72a5 |
(unsigned long long)f.f_ffree, (unsigned long long)f.f_files);
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_files < f.f_favail)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has more avail file nodes (%llu) than total file nodes (%llu)\n",
|
|
Szabolcs Nagy |
9f72a5 |
(unsigned long long)f.f_favail, (unsigned long long)f.f_files);
|
|
Szabolcs Nagy |
9f72a5 |
if (f.f_namemax > 1<<16 || f.f_namemax < 8)
|
|
Szabolcs Nagy |
9f72a5 |
t_error("/ has bogus f_namemax: %lu\n", (unsigned long)f.f_namemax);
|
|
Szabolcs Nagy |
9f72a5 |
|
|
Szabolcs Nagy |
9f72a5 |
return t_status;
|
|
Szabolcs Nagy |
9f72a5 |
}
|