1 /*
2 * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved.
3 * AUTHOR: Prashant P Yendigeri <prashant.yendigeri@wipro.com>
4 *
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
14 * with this program; if not, write the Free Software Foundation, Inc.,
15 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 *
17 */
18 /*
19 * 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.
23 */
24
25 #include <stdio.h>
26 #include <unistd.h>
27 #include <errno.h>
28 #include <sys/statvfs.h>
29 #include <stdint.h>
30
31 #include "test.h"
32
33 #define TEST_PATH "/"
34
35 static void setup(void);
36 static void cleanup(void);
37
38 char *TCID = "statvfs01";
39 int TST_TOTAL = 1;
40
main(int ac,char ** av)41 int main(int ac, char **av)
42 {
43 struct statvfs buf;
44 int lc;
45
46 tst_parse_opts(ac, av, NULL, NULL);
47
48 setup();
49
50 for (lc = 0; TEST_LOOPING(lc); lc++) {
51
52 tst_count = 0;
53
54 TEST(statvfs(TEST_PATH, &buf));
55
56 if (TEST_RETURN == -1) {
57 tst_resm(TFAIL | TTERRNO, "statvfs(%s, ...) failed",
58 TEST_PATH);
59 } else {
60 tst_resm(TPASS, "statvfs(%s, ...) passed", TEST_PATH);
61 }
62
63 }
64
65 tst_resm(TINFO, "This call is similar to statfs");
66 tst_resm(TINFO, "Extracting info about the '%s' file system",
67 TEST_PATH);
68 tst_resm(TINFO, "file system block size = %lu bytes", buf.f_bsize);
69 tst_resm(TINFO, "file system fragment size = %lu bytes", buf.f_frsize);
70 tst_resm(TINFO, "file system free blocks = %ju",
71 (uintmax_t) buf.f_bfree);
72 tst_resm(TINFO, "file system total inodes = %ju",
73 (uintmax_t) buf.f_files);
74 tst_resm(TINFO, "file system free inodes = %ju",
75 (uintmax_t) buf.f_ffree);
76 tst_resm(TINFO, "file system id = %lu", buf.f_fsid);
77 tst_resm(TINFO, "file system max filename length = %lu", buf.f_namemax);
78
79 cleanup();
80 tst_exit();
81 }
82
setup(void)83 static void setup(void)
84 {
85 tst_sig(NOFORK, DEF_HANDLER, cleanup);
86
87 TEST_PAUSE;
88 }
89
cleanup(void)90 static void cleanup(void)
91 {
92 }
93