/* @(#)test4.c 1.4 90/01/03 NFS Rev 2 Testsuite
* 1.4 Lachman ONC Test Suite source
* Test setattr, getattr and lookup
* Creates the files in the test directory - does not create a directory
* Uses the following important system calls against the server:
* mkdir() (for initial directory creation if not -m)
#include <sys/fs/nfs/time.h>
int Tflag
= 0; /* print timing */
int Hflag
= 0; /* print help message */
int Fflag
= 0; /* test function only; set count to 1, negate -t */
int Nflag
= 0; /* Suppress directory operations */
fprintf(stdout
, "usage: %s [-htfn] [files count]\n", Myname
);
fprintf(stdout
, " Flags: h Help - print this usage info\n");
fprintf(stdout
, " t Print execution time statistics\n");
fprintf(stdout
, " f Test function only (negate -t)\n");
fprintf(stdout
, " n Suppress test directory create operations\n");
int files
= 10; /* number of files in each dir */
int count
= 50; /* times to do each file */
while (argc
&& **argv
== '-') {
for (opts
= &argv
[0][1]; *opts
; opts
++) {
case 'f': /* funtionality */
case 'n': /* suppress initial directory */
error("unknown option '%c'", *opts
);
files
= getparm(*argv
, 1, "files");
count
= getparm(*argv
, 1, "count");
dirtree(1, files
, 0, fname
, DNAME
, &totfiles
, &totdirs
);
fprintf(stdout
, "%s: setattr, getattr, and lookup\n", Myname
);
for (ct
= 0; ct
< count
; ct
++) {
for (fi
= 0; fi
< files
; fi
++) {
sprintf(str
, "%s%d", fname
, fi
);
error("can't chmod 0 %s", str
);
if (stat(str
, &statb
) < 0) {
error("can't stat %s", str
);
if ((statb
.st_mode
& 0777) != 0) {
error("%s has mode %o after chmod 0",
str
, (statb
.st_mode
& 0777));
if (chmod(str
, 0666) < 0) {
error("can't chmod 0666 %s", str
);
if (stat(str
, &statb
) < 0) {
error("can't stat %s", str
);
if ((statb
.st_mode
& 0777) != 0666) {
error("%s has mode %o after chmod 0666",
str
, (statb
.st_mode
& 0777));
fprintf(stdout
, "\t%d chmods and stats on %d files",
files
* count
* 2, files
);
fprintf(stdout
, " in %d.%-2d seconds",
time
.tv_sec
, time
.tv_usec
/ 10000);
/* XXX REMOVE DIRECTORY TREE? */