plars | 8505e2a | 2005-02-01 15:01:42 +0000 | [diff] [blame] | 1 | /* |
| 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 14 | int tst_cwd_has_free(int required_kib) |
plars | 8505e2a | 2005-02-01 15:01:42 +0000 | [diff] [blame] | 15 | { |
| 16 | struct statfs sf; |
| 17 | statfs(".", &sf); |
| 18 | |
| 19 | /* check that we have enough blocks to create swap file */ |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 20 | return ((float)sf.f_bfree) / (1024 / sf.f_bsize) >= |
| 21 | required_kib ? 1 : 0; |
Chris Dearman | ec6edca | 2012-10-17 19:54:01 -0700 | [diff] [blame] | 22 | } |