Hi! > -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; > -} > diff --git a/lib/tst_fs_has_free.c b/lib/tst_fs_has_free.c > new file mode 100644 > index 0000000..16169ba > --- /dev/null > +++ b/lib/tst_fs_has_free.c > @@ -0,0 +1,40 @@ > +/* > + * Copyright (c) 2014 Fujitsu Ltd. > + * Author: Xiaoguang Wang <wangxg.f...@cn.fujitsu.com> > + * > + * This program is free software; you can redistribute it and/or modify it > + * under the terms of version 2 of the GNU General Public License as > + * published by the Free Software Foundation. > + * > + * This program is distributed in the hope that it would be useful, but > + * WITHOUT ANY WARRANTY; without even the implied warranty of > + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. > + * > + * You should have received a copy of the GNU General Public License along > + * with this program; if not, write the Free Software Foundation, Inc., > + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. > + */ > + > +/* > + * DESCRIPTION > + * Check if the mounted file system has enough free space, > + * if it is, tst_fs_has_free() returns 1, otherwise 0. > + */ > + > +#include <stdint.h> /* for uint64_t */ ^ This comment falls into the "Commenting the obvious" category. Please remove it.
> +#include <sys/vfs.h> > +#include "test.h" > + > +int tst_fs_has_free(void (*cleanup)(void), const char *path, > + uint64_t required_kib) > +{ > + struct statfs sf; > + > + if (statfs(path, &sf)) { > + tst_brkm(TBROK | TERRNO, cleanup, > + "tst_fs_has_free: failed to statfs(%s)", path); > + } > + > + return ((uint64_t)sf.f_bfree * sf.f_bsize / 1024) >= > + required_kib ? 1 : 0; This line is too long, maybe this would be more readable as regular if. The rest looks good. -- Cyril Hrubis chru...@suse.cz ------------------------------------------------------------------------------ Start Your Social Network Today - Download eXo Platform Build your Enterprise Intranet with eXo Platform Software Java Based Open Source Intranet - Social, Extensible, Cloud Ready Get Started Now And Turn Your Intranet Into A Collaboration Platform http://p.sf.net/sfu/ExoPlatform _______________________________________________ Ltp-list mailing list Ltp-list@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/ltp-list