From 01c165cd1b2ac601d5ae73d3cb5e82ccdd94ac94 Mon Sep 17 00:00:00 2001 From: Le Chi Thu Date: Tue, 3 Apr 2012 01:23:00 +0200 Subject: Initial commit --- ltp_framework/lib/tst_cwd_has_free.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 ltp_framework/lib/tst_cwd_has_free.c (limited to 'ltp_framework/lib/tst_cwd_has_free.c') diff --git a/ltp_framework/lib/tst_cwd_has_free.c b/ltp_framework/lib/tst_cwd_has_free.c new file mode 100644 index 0000000..791df09 --- /dev/null +++ b/ltp_framework/lib/tst_cwd_has_free.c @@ -0,0 +1,22 @@ +/* + * AUTHOR + * Ricky Ng-Adam , 2005-01-01 + * + * DESCRIPTION + * Check if there is enough blocks to fill number of KiB specified + * If current directory has enough blocks, return 1 + * If current directory has NOT enough blocks, return 0 + * + * + */ +#include + +int +tst_cwd_has_free(int required_kib) +{ + struct statfs sf; + statfs(".", &sf); + + /* check that we have enough blocks to create swap file */ + return ((float)sf.f_bfree)/(1024/sf.f_bsize) >= required_kib?1:0; +} \ No newline at end of file -- cgit v1.2.3