vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) Wipro Technologies Ltd, 2005. All Rights Reserved. |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 3 | * AUTHOR: Prashant P Yendigeri <prashant.yendigeri@wipro.com> |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 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 |
Wanlong Gao | fed9641 | 2012-10-24 10:10:29 +0800 | [diff] [blame] | 14 | * with this program; if not, write the Free Software Foundation, Inc., |
| 15 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 16 | * |
| 17 | */ |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 18 | /* |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 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. |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 23 | */ |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 24 | |
| 25 | #include <stdio.h> |
| 26 | #include <unistd.h> |
| 27 | #include <errno.h> |
| 28 | #include <sys/statvfs.h> |
subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 29 | #include <stdint.h> |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 30 | |
| 31 | #include "test.h" |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 32 | |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 33 | #define TEST_PATH "/" |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 34 | |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 35 | static void setup(void); |
| 36 | static void cleanup(void); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 37 | |
Cyril Hrubis | fdce7d5 | 2013-04-04 18:35:48 +0200 | [diff] [blame] | 38 | char *TCID = "statvfs01"; |
| 39 | int TST_TOTAL = 1; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 40 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 41 | int main(int ac, char **av) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 42 | { |
| 43 | struct statvfs buf; |
Cyril Hrubis | 89af32a | 2012-10-24 16:39:11 +0200 | [diff] [blame] | 44 | int lc; |
Cyril Hrubis | 0b9589f | 2014-05-27 17:40:33 +0200 | [diff] [blame] | 45 | const char *msg; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 46 | |
Garrett Cooper | 45e285d | 2010-11-22 12:19:25 -0800 | [diff] [blame] | 47 | if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL) |
Garrett Cooper | 60fa801 | 2010-11-22 13:50:58 -0800 | [diff] [blame] | 48 | tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 49 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 50 | setup(); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 51 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 52 | for (lc = 0; TEST_LOOPING(lc); lc++) { |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 53 | |
Caspar Zhang | d59a659 | 2013-03-07 14:59:12 +0800 | [diff] [blame] | 54 | tst_count = 0; |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 55 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 56 | TEST(statvfs(TEST_PATH, &buf)); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 57 | |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 58 | if (TEST_RETURN == -1) { |
Wanlong Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 59 | tst_resm(TFAIL | TERRNO, "statvfs(%s, ...) failed", |
| 60 | TEST_PATH); |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 61 | } else { |
Garrett Cooper | f2083ba | 2010-12-19 10:08:54 -0800 | [diff] [blame] | 62 | tst_resm(TPASS, "statvfs(%s, ...) passed", TEST_PATH); |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 63 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 64 | |
Garrett Cooper | 2c28215 | 2010-12-16 00:55:50 -0800 | [diff] [blame] | 65 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 66 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 67 | tst_resm(TINFO, "This call is similar to statfs"); |
| 68 | tst_resm(TINFO, "Extracting info about the '%s' file system", |
| 69 | TEST_PATH); |
subrata_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 70 | 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 Gao | 354ebb4 | 2012-12-07 10:10:04 +0800 | [diff] [blame] | 72 | 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_modak | 923b23f | 2009-11-02 13:57:16 +0000 | [diff] [blame] | 78 | tst_resm(TINFO, "file system id = %lu", buf.f_fsid); |
| 79 | tst_resm(TINFO, "file system max filename length = %lu", buf.f_namemax); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 80 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 81 | cleanup(); |
Garrett Cooper | 63c6a7b | 2010-12-19 10:09:30 -0800 | [diff] [blame] | 82 | tst_exit(); |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 83 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 84 | |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 85 | static void setup(void) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 86 | { |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 87 | tst_sig(NOFORK, DEF_HANDLER, cleanup); |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 88 | |
subrata_modak | 56207ce | 2009-03-23 13:35:39 +0000 | [diff] [blame] | 89 | TEST_PAUSE; |
Garrett Cooper | 43088e1 | 2010-12-13 23:30:59 -0800 | [diff] [blame] | 90 | } |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 91 | |
Zeng Linggang | fa9a631 | 2014-05-30 10:56:54 +0800 | [diff] [blame] | 92 | static void cleanup(void) |
vapier | d13d74b | 2006-02-11 07:24:00 +0000 | [diff] [blame] | 93 | { |
Garrett Cooper | f2083ba | 2010-12-19 10:08:54 -0800 | [diff] [blame] | 94 | } |