/* @(#)test8.c 1.4 90/01/03 NFS Rev 2 Testsuite
* 1.4 Lachman ONC Test Suite source
* 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 */
#define SNAME "/this/is/a/symlink" /* symlink prefix */
fprintf(stdout
, "usage: %s [-htfn] [files count fname sname]\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
= 20; /* times to do each file */
while (argc
&& **argv
== '-') {
for (opts
= &argv
[0][1]; *opts
; opts
++) {
case 'f': /* funtionality */
case 'n': /* No Test Directory create */
error("unknown option '%c'", *opts
);
files
= getparm(*argv
, 1, "files");
count
= getparm(*argv
, 1, "count");
%s: symlink and readlink not supported on this client\n", Myname
);
fprintf(stdout
, "%s: symlink and readlink\n", Myname
);
for (ct
= 0; ct
< count
; ct
++) {
for (fi
= 0; fi
< files
; fi
++) {
sprintf(str
, "%s%d", fname
, fi
);
sprintf(new, "%s%d", sname
, fi
);
if (symlink(new, str
) < 0) {
error("can't make symlink %s", str
);
if (lstat(str
, &statb
) < 0) {
error("can't stat %s after symlink", str
);
if ((statb
.st_mode
& S_IFMT
) != S_IFLNK
) {
error("mode of %s not symlink");
if ((ret
= readlink(str
, buf
, MAXPATHLEN
))
error("readlink %s ret %d, expect %d",
if (strncmp(new, buf
, ret
) != NULL
) {
error("readlink %s returned bad linkname",
error("can't unlink %s", str
);
fprintf(stdout
, "\t%d symlinks and readlinks on %d files",
files
* count
* 2, files
);
fprintf(stdout
, " in %d.%-2d seconds",
time
.tv_sec
, time
.tv_usec
/ 10000);