|
|
1.1 ! root 1: /* @(#)test9.c 1.4 90/01/03 NFS Rev 2 Testsuite ! 2: * 1.4 Lachman ONC Test Suite source ! 3: * ! 4: * Test statfs ! 5: * ! 6: * Uses the following important system calls against the server: ! 7: * ! 8: * chdir() ! 9: * mkdir() (for initial directory creation if not -m) ! 10: * statfs() ! 11: */ ! 12: ! 13: #include <sys/param.h> ! 14: #ifdef SVR3 ! 15: #include <sys/types.h> ! 16: #include <sys/fs/nfs/time.h> ! 17: #include <sys/statfs.h> ! 18: #else ! 19: #include <sys/vfs.h> ! 20: #include <sys/time.h> ! 21: #endif ! 22: #include <sys/errno.h> ! 23: #include <stdio.h> ! 24: #include "tests.h" ! 25: ! 26: int Tflag = 0; /* print timing */ ! 27: int Hflag = 0; /* print help message */ ! 28: int Fflag = 0; /* test function only; set count to 1, negate -t */ ! 29: int Nflag = 0; /* Suppress directory operations */ ! 30: ! 31: usage() ! 32: { ! 33: fprintf(stdout, "usage: %s [-htfn] [count]\n", Myname); ! 34: fprintf(stdout, " Flags: h Help - print this usage info\n"); ! 35: fprintf(stdout, " t Print execution time statistics\n"); ! 36: fprintf(stdout, " f Test function only (negate -t)\n"); ! 37: fprintf(stdout, " n Suppress test directory create operations\n"); ! 38: } ! 39: ! 40: main(argc, argv) ! 41: int argc; ! 42: char *argv[]; ! 43: { ! 44: int count = 1500; /* times to do statfs call */ ! 45: int ct; ! 46: struct timeval time; ! 47: struct statfs sfsb; ! 48: char *opts; ! 49: ! 50: umask(0); ! 51: setbuf(stdout, NULL); ! 52: Myname = *argv++; ! 53: argc--; ! 54: while (argc && **argv == '-') { ! 55: for (opts = &argv[0][1]; *opts; opts++) { ! 56: switch (*opts) { ! 57: case 'h': /* help */ ! 58: usage(); ! 59: exit(1); ! 60: ! 61: case 't': /* time */ ! 62: Tflag++; ! 63: break; ! 64: ! 65: case 'f': /* funtionality */ ! 66: Fflag++; ! 67: break; ! 68: ! 69: case 'n': /* No Test Directory create */ ! 70: Nflag++; ! 71: break; ! 72: ! 73: default: ! 74: error("unknown option '%c'", *opts); ! 75: usage(); ! 76: exit(1); ! 77: } ! 78: } ! 79: argc--; ! 80: argv++; ! 81: } ! 82: ! 83: if (argc) { ! 84: count = getparm(*argv, 1, "count"); ! 85: argv++; ! 86: argc--; ! 87: } ! 88: if (argc) { ! 89: usage(); ! 90: exit(1); ! 91: } ! 92: ! 93: if (Fflag) { ! 94: Tflag = 0; ! 95: count = 1; ! 96: } ! 97: ! 98: if (!Nflag) ! 99: testdir(NULL); ! 100: else ! 101: mtestdir(NULL); ! 102: ! 103: fprintf(stdout, "%s: statfs\n", Myname); ! 104: ! 105: if (Tflag) { ! 106: starttime(); ! 107: } ! 108: ! 109: for (ct = 0; ct < count; ct++) { ! 110: #ifdef SVR3 ! 111: if (statfs(".", &sfsb, sizeof(sfsb), 0) < 0) { ! 112: #else ! 113: if (statfs(".", &sfsb) < 0) { ! 114: #endif ! 115: error("can't do statfs on \".\""); ! 116: exit(1); ! 117: } ! 118: } ! 119: ! 120: if (Tflag) { ! 121: endtime(&time); ! 122: } ! 123: #ifdef SVR3 ! 124: #ifdef DEBUG ! 125: fprintf(stdout, "\ttype=%d, bsize=%d, blocks=%d, bfree=%d\n\ ! 126: \t bavail=%d, files=%d, ffree=%d, vol=%s, pack=%s\n", ! 127: sfsb.f_fstyp, sfsb.f_bsize, sfsb.f_blocks, sfsb.f_bfree, ! 128: sfsb.f_bfree, sfsb.f_files, sfsb.f_ffree, sfsb.f_fname, ! 129: sfsb.f_fpack); ! 130: #endif /* DEBUG */ ! 131: #else /* SVR3 */ ! 132: #ifdef DEBUG ! 133: fprintf(stdout, "\ttype=%d, bsize=%d, blocks=%d, bfree=%d\n\ ! 134: \t bavail=%d, files=%d, ffree=%d, fsid=%d %d\n", ! 135: sfsb.f_type, sfsb.f_bsize, sfsb.f_blocks, sfsb.f_bfree, ! 136: sfsb.f_bavail, sfsb.f_files, sfsb.f_ffree, ! 137: #ifdef NFS3_2 ! 138: sfsb.f_fsid.val[0], sfsb.f_fsid.val[1]); ! 139: #else /* NFS3_2 */ ! 140: sfsb.f_fsid[0], sfsb.f_fsid[1]); ! 141: #endif /* NFS3_2 */ ! 142: #endif /* DEBUG */ ! 143: #endif /* SVR3 */ ! 144: fprintf(stdout, "\t%d statfs calls", count); ! 145: if (Tflag) { ! 146: fprintf(stdout, " in %d.%-2d seconds", ! 147: time.tv_sec, time.tv_usec / 10000); ! 148: } ! 149: fprintf(stdout, "\n"); ! 150: complete(); ! 151: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.