blob: e44c31f9e924a732e7903fdc1cac2156a42dae3d [file] [log] [blame]
plars8505e2a2005-02-01 15:01:42 +00001/*
2 * AUTHOR
3 * Ricky Ng-Adam <rngadam@yahoo.com>, 2005-01-01
4 *
5 * DESCRIPTION
6 * Check if there is enough blocks to fill number of KiB specified
7 * If current directory has enough blocks, return 1
8 * If current directory has NOT enough blocks, return 0
9 *
10 *
11 */
12#include <sys/vfs.h>
13
Wanlong Gao354ebb42012-12-07 10:10:04 +080014int tst_cwd_has_free(int required_kib)
plars8505e2a2005-02-01 15:01:42 +000015{
16 struct statfs sf;
17 statfs(".", &sf);
18
19 /* check that we have enough blocks to create swap file */
Wanlong Gao354ebb42012-12-07 10:10:04 +080020 return ((float)sf.f_bfree) / (1024 / sf.f_bsize) >=
21 required_kib ? 1 : 0;
Chris Dearmanec6edca2012-10-17 19:54:01 -070022}