blob: 84dd0acc5c06b4882723d3f6e2f079f529ea7317 [file] [log] [blame]
vapierd13d74b2006-02-11 07:24:00 +00001/*
2 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
Zeng Linggangfa9a6312014-05-30 10:56:54 +08003 * AUTHOR: Prashant P Yendigeri <prashant.yendigeri@wipro.com>
vapierd13d74b2006-02-11 07:24:00 +00004 *
5 * This program is free software; you can redistribute it and/or modify it
6 * under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
8 *
9 * This program is distributed in the hope that it would be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12 *
13 * You should have received a copy of the GNU General Public License along
Wanlong Gaofed96412012-10-24 10:10:29 +080014 * with this program; if not, write the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
vapierd13d74b2006-02-11 07:24:00 +000016 *
17 */
Zeng Linggangfa9a6312014-05-30 10:56:54 +080018/*
vapierd13d74b2006-02-11 07:24:00 +000019 * DESCRIPTION
20 * This is a Phase I test for the statvfs(2) system call.
21 * It is intended to provide a limited exposure of the system call.
22 * This call behaves similar to statfs.
Zeng Linggangfa9a6312014-05-30 10:56:54 +080023 */
vapierd13d74b2006-02-11 07:24:00 +000024
25#include <stdio.h>
26#include <unistd.h>
27#include <errno.h>
28#include <sys/statvfs.h>
subrata_modak923b23f2009-11-02 13:57:16 +000029#include <stdint.h>
vapierd13d74b2006-02-11 07:24:00 +000030
31#include "test.h"
vapierd13d74b2006-02-11 07:24:00 +000032
Zeng Linggangfa9a6312014-05-30 10:56:54 +080033#define TEST_PATH "/"
vapierd13d74b2006-02-11 07:24:00 +000034
Zeng Linggangfa9a6312014-05-30 10:56:54 +080035static void setup(void);
36static void cleanup(void);
vapierd13d74b2006-02-11 07:24:00 +000037
Cyril Hrubisfdce7d52013-04-04 18:35:48 +020038char *TCID = "statvfs01";
39int TST_TOTAL = 1;
vapierd13d74b2006-02-11 07:24:00 +000040
subrata_modak56207ce2009-03-23 13:35:39 +000041int main(int ac, char **av)
vapierd13d74b2006-02-11 07:24:00 +000042{
43 struct statvfs buf;
Cyril Hrubis89af32a2012-10-24 16:39:11 +020044 int lc;
Cyril Hrubis0b9589f2014-05-27 17:40:33 +020045 const char *msg;
vapierd13d74b2006-02-11 07:24:00 +000046
Garrett Cooper45e285d2010-11-22 12:19:25 -080047 if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
Garrett Cooper60fa8012010-11-22 13:50:58 -080048 tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
vapierd13d74b2006-02-11 07:24:00 +000049
subrata_modak56207ce2009-03-23 13:35:39 +000050 setup();
vapierd13d74b2006-02-11 07:24:00 +000051
subrata_modak56207ce2009-03-23 13:35:39 +000052 for (lc = 0; TEST_LOOPING(lc); lc++) {
vapierd13d74b2006-02-11 07:24:00 +000053
Caspar Zhangd59a6592013-03-07 14:59:12 +080054 tst_count = 0;
vapierd13d74b2006-02-11 07:24:00 +000055
subrata_modak56207ce2009-03-23 13:35:39 +000056 TEST(statvfs(TEST_PATH, &buf));
vapierd13d74b2006-02-11 07:24:00 +000057
Zeng Linggangfa9a6312014-05-30 10:56:54 +080058 if (TEST_RETURN == -1) {
Wanlong Gao354ebb42012-12-07 10:10:04 +080059 tst_resm(TFAIL | TERRNO, "statvfs(%s, ...) failed",
60 TEST_PATH);
Zeng Linggangfa9a6312014-05-30 10:56:54 +080061 } else {
Garrett Cooperf2083ba2010-12-19 10:08:54 -080062 tst_resm(TPASS, "statvfs(%s, ...) passed", TEST_PATH);
Zeng Linggangfa9a6312014-05-30 10:56:54 +080063 }
vapierd13d74b2006-02-11 07:24:00 +000064
Garrett Cooper2c282152010-12-16 00:55:50 -080065 }
vapierd13d74b2006-02-11 07:24:00 +000066
subrata_modak56207ce2009-03-23 13:35:39 +000067 tst_resm(TINFO, "This call is similar to statfs");
68 tst_resm(TINFO, "Extracting info about the '%s' file system",
69 TEST_PATH);
subrata_modak923b23f2009-11-02 13:57:16 +000070 tst_resm(TINFO, "file system block size = %lu bytes", buf.f_bsize);
71 tst_resm(TINFO, "file system fragment size = %lu bytes", buf.f_frsize);
Wanlong Gao354ebb42012-12-07 10:10:04 +080072 tst_resm(TINFO, "file system free blocks = %ju",
73 (uintmax_t) buf.f_bfree);
74 tst_resm(TINFO, "file system total inodes = %ju",
75 (uintmax_t) buf.f_files);
76 tst_resm(TINFO, "file system free inodes = %ju",
77 (uintmax_t) buf.f_ffree);
subrata_modak923b23f2009-11-02 13:57:16 +000078 tst_resm(TINFO, "file system id = %lu", buf.f_fsid);
79 tst_resm(TINFO, "file system max filename length = %lu", buf.f_namemax);
vapierd13d74b2006-02-11 07:24:00 +000080
subrata_modak56207ce2009-03-23 13:35:39 +000081 cleanup();
Garrett Cooper63c6a7b2010-12-19 10:09:30 -080082 tst_exit();
Garrett Cooper43088e12010-12-13 23:30:59 -080083}
vapierd13d74b2006-02-11 07:24:00 +000084
Zeng Linggangfa9a6312014-05-30 10:56:54 +080085static void setup(void)
vapierd13d74b2006-02-11 07:24:00 +000086{
subrata_modak56207ce2009-03-23 13:35:39 +000087 tst_sig(NOFORK, DEF_HANDLER, cleanup);
vapierd13d74b2006-02-11 07:24:00 +000088
subrata_modak56207ce2009-03-23 13:35:39 +000089 TEST_PAUSE;
Garrett Cooper43088e12010-12-13 23:30:59 -080090}
vapierd13d74b2006-02-11 07:24:00 +000091
Zeng Linggangfa9a6312014-05-30 10:56:54 +080092static void cleanup(void)
vapierd13d74b2006-02-11 07:24:00 +000093{
Garrett Cooperf2083ba2010-12-19 10:08:54 -080094}