2 static char sfs_3_vldSid[] = "@(#)sfs_3_vld.c 2.1 97/10/23";
6 * Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
8 * Standard Performance Evaluation Corporation (SPEC)
9 * 6585 Merchant Place, Suite 100
12 * This product contains benchmarks acquired from several sources who
13 * understand and agree with SPEC's goal of creating fair and objective
14 * benchmarks to measure computer performance.
16 * This copyright notice is placed here only to protect SPEC in the
17 * event the source is misused in any manner that is contrary to the
18 * spirit, the goals and the intent of SPEC.
20 * The source code is provided to the user or company under the license
21 * agreement for the SPEC Benchmark Suite for this product.
24 /*****************************************************************
26 * Copyright 1991,1992 Legato Systems, Inc. *
27 * Copyright 1991,1992 Auspex Systems, Inc. *
28 * Copyright 1991,1992 Data General Corporation *
29 * Copyright 1991,1992 Digital Equipment Corporation *
30 * Copyright 1991,1992 Interphase Corporation *
31 * Copyright 1991,1992 Sun Microsystems, Inc. *
33 *****************************************************************/
36 * ------------------------------ sfs_3_vld.c ---------------------------
38 * Validation suite for sfs.
41 * void Validate_ops(int, char **)
44 * void validate_init_rpc()
45 * void validate_creation(void)
46 * void validate_attributes(void)
47 * void validate_read_write(void)
48 * void validate_rename(void)
49 * int compare_sattr(char *, char *, sattr3 *, fattr3 *)
50 * int compare_fattr(char *, char *, fattr3 *, fattr3 *)
51 * uint16_t sum(unsigned char *, int)
52 * void validate_remove(void)
53 * void validate_cleanup(void)
54 * void validate_exit(void)
55 * void verror(int, ValMsgType, char *, ...)
58 * 11-Jul-94 ChakChung Ng Created
63 * ------------------------- Include Files -------------------------
77 #include <sys/types.h>
80 #include "sfs_c_def.h"
82 extern struct hostent *Server_hostent;
85 * ----------------------- External Definitions -----------------------
88 /* forward definitions for local routines */
91 * BATCH - do complete pass of validation, reporting errors if any
92 * VERBOSE - prints step-by-step validation actions being performed
93 * INTERACTIVE - VERBOSE and if any errors encountered, ask to continue
98 #define VAL_INTERACTIVE 3
106 #define NUMREGFILES 21
109 #define NUMSYMLINKS 10
110 #define NUMFILES NUMREGFILES + NUMDIRS + NUMLINKS + NUMSYMLINKS
113 static void val_op_null(void);
114 static void val_op_getattr(GETATTR3args *, GETATTR3res *);
115 static void val_op_setattr(SETATTR3args *, SETATTR3res *);
116 static void val_op_lookup(LOOKUP3args *, LOOKUP3res *);
117 static void val_op_access(ACCESS3args *, ACCESS3res *);
118 static void val_op_readlink(READLINK3args *, READLINK3res *);
119 static void val_op_read(READ3args *, READ3res *);
120 static void val_op_write(WRITE3args *, WRITE3res *);
121 static void val_op_create(CREATE3args *, CREATE3res *);
122 static void val_op_mkdir(MKDIR3args *, MKDIR3res *);
123 static void val_op_symlink(SYMLINK3args *, SYMLINK3res *);
124 static void val_op_mknod(MKNOD3args *, MKNOD3res *);
125 static void val_op_remove(REMOVE3args *, REMOVE3res *);
126 static void val_op_rmdir(RMDIR3args *, RMDIR3res *);
127 static void val_op_rename(RENAME3args *, RENAME3res *);
128 static void val_op_link(LINK3args *, LINK3res *);
129 static void val_op_readdir(READDIR3args *, READDIR3res *);
130 static void val_op_readdirplus(READDIRPLUS3args *, READDIRPLUS3res *);
131 static void val_op_fsstat(FSSTAT3args *, FSSTAT3res *);
132 static void val_op_fsinfo(FSINFO3args *, FSINFO3res *);
133 static void val_op_pathconf(PATHCONF3args *, PATHCONF3res *);
134 static void val_op_commit(COMMIT3args *, COMMIT3res *);
136 static void validate_init_rpc(void);
137 static void validate_exit(void);
138 static void validate_creation(void);
139 static void validate_attributes(void);
140 static void validate_read_write(void);
141 static void validate_rename(void);
142 static void validate_remove(void);
143 static void validate_cleanup(void);
144 static int compare_sattr(char *, char *, sattr3 *, fattr3 *);
145 static int compare_fattr(char *, char *, fattr3 *, fattr3 *);
146 static uint16_t sum(unsigned char *, int);
147 static void verror(int, ValMsgType, char *, ...);
148 static void create_3tmp_handles(void);
149 static void delete_3tmp_handles(void);
152 * ---------------------- Static Declarations ----------------------
157 static int Validate_errors = 0;
158 static char Testdirname[SFS_MAXPATHLEN]; /* test dir component name */
160 * packed structure to keep track of file status
162 struct sfs_fileinfo {
163 int file_found:1, /* file has been found */
164 file_is_dup:1, /* file has a duplicate */
165 pad:30; /* pad the rest */
168 typedef struct sfs_fileinfo sfs_fileinfo;
170 * This vector is used for readdirplus validation currently, but could be
171 * extended to keep track of other interesting pieces of information.
173 static sfs_fileinfo check_files[NUMFILES];
176 * ---------------------- SFS Validation Suite ----------------------
180 * XXXXX Must make sure that we validate that all servers return back
181 * XXXXX All optional values
189 CLIENT * mount_client_ptr;
193 verror(VAL_BATCH, E, "Can only validate one directory at a time.\n");
197 Num_io_files = NUMFILES;
199 nfs_version = NFS_V3;
206 (void) sprintf(Testdirname, "%s/validatedir", valdir);
209 verror(VAL_BATCH, I, "validating sfs on \"%s\" directory ...\n",
213 create_3tmp_handles();
216 * need priv port to do following
218 mount_client_ptr = lad_getmnt_hand(valdir);
219 if (mount_client_ptr == NULL) {
225 * should be all done doing priv port stuff
227 if (setuid(Real_uid) != 0) {
228 (void) fprintf(stderr,"%s: %s%s\n",
229 sfs_Myname, "cannot perform setuid operation.\n",
230 "Do `make install` as root.\n");
233 init_mount_point(0, valdir, mount_client_ptr);
236 * initialize the check_file array
238 (void) memset((void *) check_files, '\0', sizeof(check_files));
240 verror(VAL_VERBOSE, I, "validating null operation ...\n");
244 validate_attributes();
245 validate_read_write();
252 * Cleanup mount client handle
254 clnt_destroy(mount_client_ptr);
256 delete_3tmp_handles();
266 * allocate and initialize client handles
269 validate_init_rpc(void)
271 NFS_client = lad_clnt_create(Tcp? 1: 0, Server_hostent,
272 (uint32_t) NFS_PROGRAM,
274 RPC_ANYSOCK, &Nfs_timers[0]);
276 if (NFS_client == ((CLIENT *) NULL)) {
278 "portmap/nfsd server not responding\n");
282 NFS_client->cl_auth = authunix_create(lad_hostname, Real_uid,
284 } /* validate_init_rpc */
288 validate_creation(void)
304 char sl_target_path[NFS_MAXPATHLEN];
305 char sym_data[NFS_MAXPATHLEN];
307 for (filenum=0; filenum < NUMFILES ; filenum++) {
309 Cur_file_ptr = &Io_files[filenum];
310 sfs_gettime(&Cur_time);
312 if (filenum < NUMREGFILES) {
314 (void) sprintf(Cur_filename, Filespec, filenum);
316 /* regular file creation */
317 (void) memmove((char *) &argcr.where.dir, (char *) &Export_dir.fh3,
319 argcr.where.name = Cur_filename;
320 argcr.how.mode = UNCHECKED;
321 argcr.how.createhow3_u.obj_attributes.mode.set_it = TRUE;
322 argcr.how.createhow3_u.obj_attributes.mode.mode =
323 (NFSMODE_REG | 0666);
324 argcr.how.createhow3_u.obj_attributes.uid.set_it = TRUE;
325 argcr.how.createhow3_u.obj_attributes.uid.uid = Cur_uid;
326 argcr.how.createhow3_u.obj_attributes.gid.set_it = TRUE;
327 argcr.how.createhow3_u.obj_attributes.gid.gid = Cur_gid;
328 argcr.how.createhow3_u.obj_attributes.atime.set_it = TRUE;
329 argcr.how.createhow3_u.obj_attributes.atime.atime.seconds =
331 argcr.how.createhow3_u.obj_attributes.atime.atime.nseconds =
332 Cur_time.usec * 1000;
333 argcr.how.createhow3_u.obj_attributes.mtime.set_it = TRUE;
334 argcr.how.createhow3_u.obj_attributes.mtime.mtime.seconds =
336 argcr.how.createhow3_u.obj_attributes.mtime.mtime.nseconds =
337 Cur_time.usec * 1000;
338 argcr.how.createhow3_u.obj_attributes.size.set_it = TRUE;
339 argcr.how.createhow3_u.obj_attributes.size.size._p._u =
341 argcr.how.createhow3_u.obj_attributes.size.size._p._l =
344 (void) memset((char *) &repcr.resok.obj.handle, '\0',
346 verror(VAL_VERBOSE, I, "validating create file %s ...\n",
348 val_op_create(&argcr, &repcr);
350 if (repcr.status == NFS3_OK) {
351 Cur_file_ptr->state = Exists;
352 (void) memmove((char *) &Cur_file_ptr->fh3,
353 (char *) &repcr.resok.obj.handle,
355 (void) strcpy(Cur_file_ptr->file_name, Cur_filename);
356 (void) memmove((char *) &Cur_file_ptr->attributes3,
357 (char *) &repcr.resok.obj_attributes.attr,
358 sizeof(Cur_file_ptr->attributes3));
359 (void) compare_sattr(Ops[CREATE].name, Io_files[filenum].file_name,
360 &argcr.how.createhow3_u.obj_attributes,
361 &Cur_file_ptr->attributes3);
363 Cur_file_ptr->state = Nonexistent;
364 errno = (int)repcr.status;
365 verror(VAL_BATCH, E, "create %s failed: %m\n",
368 * An error in file creation is fatal, because we use the
369 * created files to validate the other operations.
374 } else if (filenum < NUMREGFILES + NUMDIRS) {
376 (void) sprintf(Cur_filename, Dirspec, filenum - NUMREGFILES);
378 /* directory creation */
379 (void) memmove((char *) &argmk.where.dir, (char *) &Export_dir.fh3,
381 argmk.where.name = Cur_filename;
382 argmk.attributes.mode.set_it = TRUE;
383 argmk.attributes.mode.mode = (NFSMODE_DIR | 0777);
384 argmk.attributes.uid.set_it = TRUE;
385 argmk.attributes.uid.uid = Cur_uid;
386 argmk.attributes.gid.set_it = TRUE;
387 argmk.attributes.gid.gid = Cur_gid;
388 argmk.attributes.size.set_it = FALSE;
389 argmk.attributes.size.size._p._u = (uint32_t) 0;
390 argmk.attributes.size.size._p._l = (uint32_t) 0;
391 argmk.attributes.atime.set_it = TRUE;
392 argmk.attributes.atime.atime.seconds = Cur_time.esec;
393 argmk.attributes.atime.atime.nseconds = Cur_time.usec * 1000;
394 argmk.attributes.mtime.set_it = TRUE;
395 argmk.attributes.mtime.mtime.seconds = Cur_time.esec;
396 argmk.attributes.mtime.mtime.nseconds = Cur_time.usec * 1000;
398 (void) memset((char *) &repmk.resok.obj.handle, '\0', sizeof (nfs_fh3));
399 verror(VAL_VERBOSE, I, "validating mkdir %s ...\n", Cur_filename);
400 val_op_mkdir(&argmk, &repmk);
402 if (repmk.status == NFS3_OK) {
403 Cur_file_ptr->state = Exists;
404 (void) memmove((char *) &Cur_file_ptr->fh3,
405 (char *) &repmk.resok.obj.handle,
407 (void) strcpy(Cur_file_ptr->file_name, Cur_filename);
408 (void) memmove((char *) &Cur_file_ptr->attributes3,
409 (char *) &repmk.resok.obj_attributes.attr,
410 sizeof(Cur_file_ptr->attributes3));
411 (void) compare_sattr(Ops[MKDIR].name, Io_files[filenum].file_name,
412 &argmk.attributes, &Cur_file_ptr->attributes3);
414 Cur_file_ptr->state = Nonexistent;
415 verror(VAL_BATCH, W, "mkdir %s failed:%m\n", Cur_filename);
418 } else if (filenum < NUMREGFILES + NUMDIRS + NUMLINKS ) {
420 (void) sprintf(Cur_filename, Filespec, filenum - NUMDIRS);
422 /* hard link creation */
423 target_filenum = NUMFILES-NUMSYMLINKS-1-filenum;
424 (void) memmove((char *) &argln.file,
425 (char *) &Io_files[target_filenum].fh3,
427 (void) memmove((char *) &argln.link.dir, (char *) &Export_dir.fh3,
429 argln.link.name = Cur_filename;
431 verror(VAL_VERBOSE, I, "validating link %s %s ...\n",
432 Io_files[target_filenum].file_name, Cur_filename);
433 val_op_link(&argln, &repln);
435 if (repln.status == NFS3_OK) {
436 Cur_file_ptr->state = Exists;
437 (void) memmove((char *) &Cur_file_ptr->fh3,
438 (char *) &Io_files[target_filenum].fh3,
440 (void) strcpy(Cur_file_ptr->file_name, Cur_filename);
441 Cur_file_ptr->attributes3 = Io_files[target_filenum].attributes3;
442 Io_files[target_filenum].attributes3.nlink++;
443 Cur_file_ptr->attributes3.nlink++;
445 Cur_file_ptr->state = Nonexistent;
446 verror(VAL_BATCH, W, "link %s failed: %m\n", Cur_filename);
452 (void) sprintf(Cur_filename, Symspec, filenum -
453 (NUMREGFILES + NUMDIRS + NUMLINKS));
455 /* symbolic link creation */
456 target_filenum = NUMFILES-1-filenum;
457 (void) memmove((char *) &argsl.where.dir, (char *) &Export_dir.fh3,
459 argsl.where.name = Cur_filename;
460 (void) sprintf(sl_target_path,
461 "./%s", Io_files[target_filenum].file_name);
462 argsl.symlink.symlink_attributes.size.set_it = TRUE;
463 argsl.symlink.symlink_attributes.size.size._p._u =
465 argsl.symlink.symlink_attributes.size.size._p._l =
466 (uint32_t) strlen(sl_target_path);
467 argsl.symlink.symlink_data = sl_target_path;
468 argsl.symlink.symlink_attributes.mode.set_it = TRUE;
469 argsl.symlink.symlink_attributes.mode.mode = (NFSMODE_LNK | 0777);
470 argsl.symlink.symlink_attributes.uid.set_it = TRUE;
471 argsl.symlink.symlink_attributes.uid.uid = Cur_uid;
472 argsl.symlink.symlink_attributes.gid.set_it = TRUE;
473 argsl.symlink.symlink_attributes.gid.gid = Cur_gid;
474 argsl.symlink.symlink_attributes.atime.set_it = TRUE;
475 argsl.symlink.symlink_attributes.atime.atime.seconds =
477 argsl.symlink.symlink_attributes.atime.atime.nseconds =
478 Cur_time.usec * 1000;
479 argsl.symlink.symlink_attributes.mtime.set_it = TRUE;
480 argsl.symlink.symlink_attributes.mtime.mtime.seconds =
482 argsl.symlink.symlink_attributes.mtime.mtime.nseconds =
483 Cur_time.usec * 1000;
485 verror(VAL_VERBOSE, I, "validating symlink %s %s ...\n",
486 sl_target_path, Cur_filename);
487 val_op_symlink(&argsl, &repsl);
489 if (repsl.status == NFS3_OK) {
490 Cur_file_ptr->state = Exists;
492 /* do a lookup to get file handle and attributes */
493 (void) memmove((char *) &arglp.what.dir, (char *) &Export_dir.fh3,
495 arglp.what.name = Cur_filename;
496 (void) memset((char *) &replp.resok.object, '\0', sizeof (nfs_fh3));
498 val_op_lookup(&arglp, &replp);
500 if (replp.status == NFS3_OK) {
501 (void) memmove((char *) &Cur_file_ptr->fh3,
502 (char *) &replp.resok.object,
504 (void) strcpy(Cur_file_ptr->file_name, Cur_filename);
505 (void) memmove((char *) &Cur_file_ptr->attributes3,
506 (char *) &replp.resok.obj_attributes.attr,
507 sizeof (Cur_file_ptr->attributes3));
508 (void) compare_sattr(Ops[SYMLINK].name,
509 Io_files[filenum].file_name,
510 &argsl.symlink.symlink_attributes,
511 &Cur_file_ptr->attributes3);
513 verror(VAL_BATCH, W, "lookup %s failed: %m\n",
518 /* validate readlink */
519 (void) memmove((char *) &argrl.symlink,
520 (char *) &Cur_file_ptr->fh3,
522 reprl.resok.data = sym_data;
524 verror(VAL_VERBOSE, I, "validating readlink %s ...\n",
526 val_op_readlink(&argrl, &reprl);
528 if (reprl.status == NFS3_OK) {
529 if (strcmp(sl_target_path, sym_data)) {
531 "readlink %s error, result = %s, should be %s\n",
532 Cur_filename, reprl.resok.data,
536 verror(VAL_BATCH, W, "readlink %s failed:%m\n",
541 Cur_file_ptr->state = Nonexistent;
542 verror(VAL_BATCH, W, "symlink %s failed: %m\n", Cur_filename);
545 } /* end for each file */
547 } /* validate_creation */
551 validate_attributes(void)
561 /* validate fsstat */
563 /* validate lookup */
564 for (filenum = 0; filenum < NUMFILES; filenum++) {
565 (void) memmove((char *) &arglp.what.dir, (char *) &Export_dir.fh3,
567 arglp.what.name = Io_files[filenum].file_name;
568 (void) memset((char *) &replp.resok.object, '\0', sizeof (nfs_fh3));
570 verror(VAL_VERBOSE, I, "validating lookup %s ...\n",
571 Io_files[filenum].file_name);
572 val_op_lookup(&arglp, &replp);
574 if (replp.status == NFS3_OK) {
575 if (memcmp((char *) &(Io_files[filenum].fh3),
576 (char *) &(replp.resok.object), sizeof (nfs_fh3))) {
577 verror(VAL_BATCH, W, "lookup %s: file handle mismatch\n",
578 Io_files[filenum].file_name);
581 (void) compare_fattr(Ops[LOOKUP].name, Io_files[filenum].file_name,
582 &Io_files[filenum].attributes3,
583 &replp.resok.obj_attributes.attr);
585 verror(VAL_BATCH, W, "lookup %s failed:%m\n",
586 Io_files[filenum].file_name);
590 /* validate getattr */
591 for (filenum = 0; filenum < NUMFILES; filenum++) {
592 (void) memmove((char *) &argga.object,
593 (char *) &Io_files[filenum].fh3,
596 verror(VAL_VERBOSE, I, "validating getattr %s ...\n",
597 Io_files[filenum].file_name);
598 val_op_getattr(&argga, &repga);
600 if (repga.status == NFS3_OK) {
601 (void) compare_fattr(Ops[GETATTR].name, Io_files[filenum].file_name,
602 &Io_files[filenum].attributes3,
603 &repga.resok.obj_attributes);
605 verror(VAL_BATCH, W, "getattr %s failed: %m\n",
606 Io_files[filenum].file_name);
610 /*validate setattr */
611 for (filenum = 0; filenum < NUMFILES; filenum++) {
612 sfs_gettime(&Cur_time);
613 (void) memmove((char *) &argsa.object,
614 (char *) &Io_files[filenum].fh3,
616 argsa.new_attributes.mode.set_it = TRUE;
617 if (filenum >= NUMREGFILES && filenum < NUMREGFILES + NUMDIRS)
618 argsa.new_attributes.mode.mode = 0777;
620 argsa.new_attributes.mode.mode = 0666;
621 argsa.new_attributes.uid.set_it = FALSE;
622 argsa.new_attributes.uid.uid = 0;
623 argsa.new_attributes.gid.set_it = FALSE;
624 argsa.new_attributes.gid.gid = 0;
625 argsa.new_attributes.size.set_it = FALSE;
626 argsa.new_attributes.size.size._p._u = 0;
627 argsa.new_attributes.size.size._p._l = 0;
628 argsa.new_attributes.atime.set_it = TRUE;
629 argsa.new_attributes.atime.atime.seconds = Cur_time.esec;
630 argsa.new_attributes.atime.atime.nseconds = Cur_time.usec * 1000;
631 argsa.new_attributes.mtime.set_it = TRUE;
632 argsa.new_attributes.mtime.mtime.seconds = Cur_time.esec;
633 argsa.new_attributes.mtime.mtime.nseconds = Cur_time.usec * 1000;
634 argsa.guard.check = FALSE;
636 verror(VAL_VERBOSE, I, "validating setattr %s ...\n",
637 Io_files[filenum].file_name);
638 val_op_setattr(&argsa, &repsa);
640 if (repsa.status == NFS3_OK) {
641 (void) memmove((char *) &Io_files[filenum].attributes3,
642 (char *) &repsa.resok.obj_wcc.after.attr,
643 sizeof (Io_files[filenum].attributes3));
644 (void) compare_sattr(Ops[SETATTR].name, Io_files[filenum].file_name,
645 &argsa.new_attributes, &repsa.resok.obj_wcc.after.attr);
647 (void) memmove((char *) &argga.object,
648 (char *) &Io_files[filenum].fh3,
651 val_op_getattr(&argga, &repga);
653 if (repga.status == NFS3_OK) {
654 (void) compare_fattr(Ops[GETATTR].name, Io_files[filenum].file_name,
655 &Io_files[filenum].attributes3,
656 &repga.resok.obj_attributes);
658 verror(VAL_BATCH, W, "getattr %s failed: %m\n",
659 Io_files[filenum].file_name);
662 verror(VAL_BATCH, W, "setattr %s failed: %m\n",
663 Io_files[filenum].file_name);
668 } /* validate_attributes */
672 * need to check if readdirplus returns a reasonable amount of data.
675 val_rddirplus_retsize(uint32_t dircount, uint32_t maxcount,
676 READDIRPLUS3resok *rp)
679 static int eof_wait = 0;
686 esp = rp->reply.entries;
688 for (i = 0; i < rp->count; i++) {
689 size += sizeof(esp[i].fileid);
690 size += strlen(esp[i].name) * sizeof(char);
691 size += sizeof(esp[i].cookie);
692 tsize += sizeof(esp[i].name_attributes);
693 tsize += sizeof(esp[i].name_handle.handle_follows);
694 tsize += esp[i].name_handle.handle.fh3_length * sizeof(char);
697 msize = size + tsize;
698 mpcnt = (double) msize / (double) maxcount * 100;
701 verror(VAL_VERBOSE, I, "readdirplus on %s returned EOF.\n"
702 "\treceived %d bytes of directory information and %d bytes including\n"
703 "\tpost op attributes and filehandle.\n",
704 Testdirname, size, msize);
705 } else if (mpcnt < 80) {
707 if (eof_wait > WAITFOREOF) {
709 "readdirplus on %s did not return a reasonable amount of data.\n"
710 "\treceived %d bytes. should receive close to %d bytes.\n",
711 Testdirname, msize, maxcount);
713 verror(VAL_VERBOSE, I, "readdirplus on %s did not return EOF.\n"
714 "\treceived %d bytes of directory information and %d bytes including\n"
715 "\tpost op attributes and filehandle.\n",
716 Testdirname, size, msize);
719 verror(VAL_VERBOSE, I, "readdirplus on %s did not return EOF.\n"
720 "\treceived %d bytes of directory information and %d bytes including\n"
721 "\tpost op attributes and filehandle.\n",
722 Testdirname, size, msize);
727 validate_read_write(void)
730 uint16_t sum; /* checksum of data */
731 uint16_t len; /* length of len and data */
732 char data[DEFAULT_MAX_BUFSIZE - 2 * sizeof(uint16_t)];
740 READDIRPLUS3args argdrp;
741 READDIRPLUS3res repdrp;
748 entry3 entry_stream[SFS_MAXDIRENTS];
749 entryplus3 entryplus_stream[SFS_MAXDIRENTS];
753 /* get the maximum number of blocks sfs will write */
754 maxblks = Io_dist_ptr->max_bufs;
755 maxfiles = maxblks > NUMREGFILES ? NUMREGFILES : maxblks;
757 /* write maxblks - filenum + 1 blocks to each regular file */
758 argwr.offset._p._u = argwr.offset._p._l = (uint32_t) 0;
759 argwr.stable = FILE_SYNC;
760 argwr.data.data_val = (char *)█
762 for (blocknum = 0; blocknum <= maxblks ; blocknum++) {
764 for (i=0; i < sizeof(block.data); i++)
765 block.data[i] = (char)blocknum;
767 for (filenum=0; filenum < maxfiles; filenum++) {
768 /* Write fewer blocks to files with higher numbers. */
769 if (blocknum > (maxblks - filenum))
772 /* set the length field */
773 if (blocknum == (maxblks - filenum)) {
774 block.len = ((maxfiles - filenum) *
775 (Bytes_per_block/Kb_per_block)) - (sizeof(block.len) +
778 * XXX - write kludge.
780 * Writes must be less than 8K in
781 * size or else the checksum will incur a buffer overflow
783 block.len = (block.len % DEFAULT_MAX_BUFSIZE) -
784 (sizeof(block.len) + sizeof(block.sum));
786 block.len = Bytes_per_block - (sizeof(block.len)
787 + sizeof(block.sum));
789 block.sum = sum((unsigned char *) &block.len,
790 (int)(block.len + sizeof(block.len)));
792 (void) memmove((char *) &argwr.file,
793 (char *) &Io_files[filenum].fh3,
795 argwr.data.data_len = block.len +
796 sizeof(block.len) + sizeof(block.sum);
797 argwr.count = argwr.data.data_len;
799 verror(VAL_VERBOSE, I,
800 "validating write %d bytes @ offset %lu to %s ...\n",
801 argwr.data.data_len, argwr.offset._p._l,
802 Io_files[filenum].file_name);
804 val_op_write(&argwr, &repwr);
806 if (repwr.status == NFS3_OK) {
807 (void) compare_fattr(Ops[WRITE].name, Io_files[filenum].file_name,
808 &Io_files[filenum].attributes3,
809 &repwr.resok.file_wcc.after.attr);
810 Io_files[filenum].attributes3 = repwr.resok.file_wcc.after.attr;
812 * XXX-bookeeping kludge.
814 * Need to update hardlink attributes, so readdirplus vali-
815 * dation doesn't barf. This is necessary because setattr was
816 * validated on all the test files and the attributes in
817 * Io_files[] were updated accordingly. Since the write
818 * op has been validated on just the regular files, we have to
819 * make sure that the corresponding indexes in Io_files[] that
820 * point to the hard links reflect the current file attributes.
822 if (filenum < NUMLINKS) {
823 Io_files[NUMREGFILES+NUMDIRS+NUMLINKS-1-filenum].attributes3 = Io_files[filenum].attributes3;
827 verror(VAL_BATCH, W, "write %s failed: %m\n",
828 Io_files[filenum].file_name);
831 argwr.offset._p._l += Bytes_per_block;
836 for (filenum = 0; filenum < maxfiles; filenum++) {
837 (void) memmove((char *) &argrd.file,
838 (char *) &Io_files[filenum].fh3,
840 argrd.offset._p._u = argrd.offset._p._l = (uint32_t) 0;
842 reprd.resok.data.data_len = 0;
843 maxblks = Io_files[filenum].attributes3.size._p._l / Bytes_per_block;
844 for (blocknum = 0; blocknum <= maxblks; blocknum ++) {
846 if (argrd.count != reprd.resok.data.data_len) {
847 argrd.count -= reprd.resok.data.data_len;
848 reprd.resok.data.data_val = (char *)&block +
849 reprd.resok.data.data_len;
852 if (blocknum < maxblks)
853 argrd.count = Bytes_per_block;
855 argrd.count = (maxfiles - filenum)
856 * (Bytes_per_block/Kb_per_block);
857 reprd.resok.data.data_val = (char *)█
860 verror(VAL_VERBOSE, I,
861 "validating read %lu bytes @ offset %lu from %s ...\n",
862 argrd.count, argrd.offset._p._l,
863 Io_files[filenum].file_name);
865 val_op_read(&argrd, &reprd);
867 if (reprd.status == NFS3_OK) {
868 (void) compare_fattr(Ops[READ].name, Io_files[filenum].file_name,
869 &Io_files[filenum].attributes3,
870 &reprd.resok.file_attributes.attr);
871 Io_files[filenum].attributes3 = reprd.resok.file_attributes.attr;
872 argrd.offset._p._l += reprd.resok.data.data_len;
874 verror(VAL_BATCH, W, "read %s failed: %m\n",
875 Io_files[filenum].file_name);
879 (block.sum != sum((unsigned char *) &block.len,
880 (int)(block.len + sizeof(block.len)))))) {
881 verror(VAL_BATCH, W, "read %s checksum mismatch\n",
882 Io_files[filenum].file_name);
887 /* validate readdir */
888 (void) memmove((char *) &argdr.dir, (char *) &Export_dir.fh3,
890 argdr.cookie._p._l = argdr.cookie._p._u = (uint32_t) 0;
891 (void) memset((char *) argdr.cookieverf, '\0', NFS3_COOKIEVERFSIZE);
892 argdr.count = DEFAULT_MAX_BUFSIZE;
895 (void) memset((char *) entry_stream, '\0', sizeof (entry3) * SFS_MAXDIRENTS);
896 (void) memset((char *) &repdr, '\0', sizeof(repdr));
897 repdr.resok.count = SFS_MAXDIRENTS;
898 repdr.resok.reply.entries = entry_stream;
899 verror(VAL_VERBOSE, I, "validating readdir on %s ...\n", Testdirname);
900 val_op_readdir(&argdr, &repdr);
903 if (repdr.status == NFS3_OK) {
904 for (i = 0; i < repdr.resok.count; i++) {
905 for (filenum = 0; filenum < NUMFILES; filenum++) {
906 if (!strcmp(entry_stream[i].name, Io_files[filenum].file_name)) { if (entry_stream[i].fileid._p._l !=
907 Io_files[filenum].attributes3.fileid._p._l) {
909 "readdir %s error: file %s fileid mismatch\n",
910 Testdirname, entry_stream[i].name);
912 " fileid: got = %lu, original = %lu\n",
913 entry_stream[i].fileid._p._l,
914 Io_files[filenum].attributes3.fileid._p._l);
917 * mark file as either found or dup
919 if (check_files[filenum].file_found &&
920 !check_files[filenum].file_is_dup)
921 check_files[filenum].file_is_dup = 1;
923 check_files[filenum].file_found = 1;
929 verror(VAL_BATCH, W, "readdir %s failed: %m\n", Testdirname);
932 argdr.cookie = entry_stream[repdr.resok.count-1].cookie;
934 } while (repdr.resok.reply.eof == 0);
937 * check if any known files have not been found
939 for (i = 0; i < NUMFILES; i++) {
940 if (!check_files[i].file_found)
942 "readdir %s error: file %s not found\n",
943 Testdirname, Io_files[i].file_name);
945 if (check_files[i].file_is_dup)
947 "readdir %s error: file %s returned more than once\n",
948 Testdirname, Io_files[i].file_name);
952 /* validate readdirplus */
953 (void) memset((void *) check_files, '\0', sizeof(check_files));
955 argdrp.cookie._p._l = argdrp.cookie._p._u = (uint32_t) 0;
956 (void) memmove((char *) &argdrp.dir, (char *) &Export_dir.fh3,
958 (void) memset((char *) argdrp.cookieverf, '\0', NFS3_COOKIEVERFSIZE);
960 * We validate readdirplus with dircount and maxcount both set at 8K.
961 * This is not the most efficient way, but this is how readdirplus is
962 * called in SFS. With the numbers set as such, maxcount becomes the
963 * bottleneck and we will not get 8K worth of directory info. What we
964 * should get is 8K worth which includes directory info plus post_op_
965 * attributes and filehandle.
967 argdrp.dircount = DEFAULT_MAX_BUFSIZE;
968 argdrp.maxcount = DEFAULT_MAX_BUFSIZE;
970 (void) memset((char *) entryplus_stream, '\0',
971 sizeof (entryplus_stream));
973 (void) memset((char *) &repdrp, '\0', sizeof(repdrp));
974 repdrp.resok.count = SFS_MAXDIRENTS;
975 repdrp.resok.reply.entries = entryplus_stream;
977 verror(VAL_VERBOSE, I, "validating readdirplus on %s ...\n",
979 val_op_readdirplus(&argdrp, &repdrp);
981 if (repdrp.status == NFS3_OK) {
982 verror(VAL_VERBOSE, I, "readdirplus found %d entries in %s...\n",
983 repdrp.resok.count, Testdirname);
984 val_rddirplus_retsize(argdrp.dircount, argdrp.maxcount,
986 for (i = 0; i < repdrp.resok.count; i++) {
987 for (filenum = 0; filenum < NUMFILES; filenum++) {
988 if (!strcmp(entryplus_stream[i].name,
989 Io_files[filenum].file_name)) {
990 if (entryplus_stream[i].fileid._p._l !=
991 Io_files[filenum].attributes3.fileid._p._l) {
993 "readdirplus %s error: file %s fileid mismatch\n",
994 Testdirname, entryplus_stream[i].name);
996 " fileid: got = %lu, original = %lu\n",
997 entryplus_stream[i].fileid._p._l,
998 Io_files[filenum].attributes3.fileid._p._l);
1002 * mark file as either found or dup
1004 if (check_files[filenum].file_found &&
1005 !check_files[filenum].file_is_dup)
1006 check_files[filenum].file_is_dup = 1;
1008 check_files[filenum].file_found = 1;
1011 * check to make sure post op attributes and
1012 * file handle are returned.
1014 if (!entryplus_stream[i].name_attributes.attributes)
1015 verror(VAL_BATCH, E,
1016 "readdirplus %s warning: did not receive post op attributes for file %s\n\n",
1017 Testdirname, entryplus_stream[i].name);
1019 (void) compare_fattr(Ops[READDIRPLUS].name,
1020 Io_files[filenum].file_name,
1021 &Io_files[filenum].attributes3, &entryplus_stream[i].name_attributes.attr);
1023 if (!entryplus_stream[i].name_handle.handle_follows)
1024 verror(VAL_BATCH, E,
1025 "readdirplus %s warning: did not receive file handle for file %s\n\n",
1026 Testdirname, entryplus_stream[i].name);
1028 if (memcmp((void *) &Io_files[filenum].fh3.fh3_u.data,
1029 (void *) &entryplus_stream[i].name_handle.handle.fh3_u.data, Io_files[filenum].fh3.fh3_length) != 0)
1030 verror(VAL_BATCH, E,
1031 "readdirplus %s error: file %s, filehandles do not match\n\n",
1032 Testdirname, entryplus_stream[i].name);
1038 verror(VAL_BATCH, W, "readdirplus %s failed: %m\n", Testdirname);
1040 argdrp.cookie = entryplus_stream[repdrp.resok.count-1].cookie;
1042 } while (repdrp.resok.reply.eof == 0);
1044 * check if any known files have not been found
1046 for (i = 0; i < NUMFILES; i++) {
1047 if (!check_files[i].file_found)
1048 verror(VAL_BATCH, E,
1049 "readdirplus %s error: file %s not found\n",
1050 Testdirname, Io_files[i].file_name);
1052 if (check_files[i].file_is_dup)
1053 verror(VAL_BATCH, E,
1054 "readdirplus %s error: file %s returned more than once\n",
1055 Testdirname, Io_files[i].file_name);
1058 } /* validate_read_write */
1062 validate_rename(void)
1067 char newname[SFS_MAXNAMLEN];
1070 (void) memmove((char *) &argrn.from.dir, (char *) &Export_dir.fh3,
1072 (void) memmove((char *) &argrn.to.dir, (char *) &Export_dir.fh3,
1075 for (filenum=0; filenum < NUMFILES; filenum++) {
1076 if (Io_files[filenum].state != Exists)
1080 (void) sprintf(newname, "n%s", Io_files[filenum].file_name);
1081 argrn.from.name = Io_files[filenum].file_name;
1082 argrn.to.name = newname;
1084 verror(VAL_VERBOSE, I, "validating rename %s %s ...\n",
1085 argrn.from.name, argrn.to.name);
1087 val_op_rename(&argrn, &reprn);
1089 if (reprn.status == NFS3_OK) {
1090 (void) strcpy(Io_files[filenum].file_name, newname);
1092 verror(VAL_BATCH, W, "rename %s to %s failed: %m\n",
1093 Io_files[filenum].file_name, newname);
1099 verror(VAL_BATCH, E, "validate_rename: no files renamed\n");
1100 verror(VAL_BATCH, W, " due to previous operation error\n");
1103 } /* validate_rename */
1114 int prev_warn = FALSE; /* -1 info warning */
1115 int flag_error = FALSE;
1117 if (attr1->type != attr2->type) {
1118 if (attr1->type == 0xFFFFFFFF) {
1121 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1124 verror(VAL_BATCH, I, " type: current = %d, previous = %d\n",
1125 attr2->type, attr1->type);
1126 attr1->type = attr2->type;
1131 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1134 verror(VAL_BATCH, E, " type: current = %d, previous = %d\n",
1135 attr2->type, attr1->type);
1141 if ((attr1->mode & NFSMODE_MASK) != (attr2->mode & NFSMODE_MASK)) {
1142 if (attr1->mode == (unsigned int)0xFFFFFFFF) {
1145 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1148 verror(VAL_BATCH, I, " mode: current = %7lo, previous = %7lo\n",
1149 attr2->mode, attr1->mode);
1150 attr1->mode = attr2->mode;
1155 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1158 verror(VAL_BATCH, E, " mode: current = %7lo, previous = %7lo\n",
1159 attr2->mode, attr1->mode);
1165 if (attr1->nlink != attr2->nlink) {
1166 if (attr1->nlink == (unsigned int)0xFFFFFFFF) {
1169 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1172 verror(VAL_BATCH, I,
1173 " nlink: current = %lu, previous = %lu\n",
1174 attr2->nlink, attr1->nlink);
1176 attr1->nlink = attr2->nlink;
1180 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1183 verror(VAL_BATCH, E,
1184 " nlink: current = %lu, previous = %lu\n",
1185 attr2->nlink, attr1->nlink);
1193 * Check for user "nobody", UID -2, which may be untranslated from
1194 * sixteen-bit two's complement.
1196 if (attr1->uid != attr2->uid && !((attr2->uid == (unsigned int)0xFFFFFFFE ||
1197 attr2->uid == 65534) && attr1->uid ==0)) {
1198 if (attr1->uid == (unsigned int)0xFFFFFFFF) {
1201 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1204 verror(VAL_BATCH, I,
1205 " uid: current = %lu, previous = %lu\n",
1206 attr2->uid, attr1->uid);
1207 attr1->uid = attr2->uid;
1212 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1215 verror(VAL_BATCH, E,
1216 " uid: current = %lu, previous = %lu\n",
1217 attr2->uid, attr1->uid);
1223 if (attr1->gid != attr2->gid && attr2->gid != 0) {
1225 if (attr1->gid != attr2->gid) {
1227 if (attr1->gid == (unsigned int)0xFFFFFFFF) {
1230 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1233 verror(VAL_BATCH, I,
1234 " gid: current = %lu, previous = %lu\n",
1235 attr2->gid, attr1->gid);
1236 attr1->gid = attr2->gid;
1241 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1244 verror(VAL_BATCH, E,
1245 " gid: current = %lu, previous = %lu\n",
1246 attr2->gid, attr1->gid);
1252 if (attr1->size._p._l != attr2->size._p._l) {
1253 if (strcmp(op, Ops[WRITE].name)) {
1254 if (attr1->size._p._l == (unsigned int)0xFFFFFFFF) {
1257 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1260 verror(VAL_BATCH, I,
1261 " size: current = %lu, previous = %lu\n",
1262 attr2->size._p._l, attr1->size._p._l);
1263 attr1->size._p._l = attr2->size._p._l;
1268 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1271 verror(VAL_BATCH, E,
1272 " size: current = %lu, previous = %lu\n",
1273 attr2->size._p._l, attr1->size._p._l);
1280 /* compare rdev only if type == NFCHR or NFBLK */
1281 if ((attr1->type == NF3CHR || attr1->type == NF3BLK) &&
1282 (attr1->rdev.specdata1 != attr2->rdev.specdata1 ||
1283 attr1->rdev.specdata2 != attr2->rdev.specdata2)) {
1284 if (attr1->rdev.specdata1 == (unsigned int)0xFFFFFFFF) {
1287 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1290 verror(VAL_BATCH, I,
1291 " rdev: current = %lu %lu, previous = %lu %lu\n",
1292 attr2->rdev.specdata1, attr2->rdev.specdata2,
1293 attr1->rdev.specdata1, attr1->rdev.specdata2);
1294 attr1->rdev.specdata1 = attr2->rdev.specdata1;
1295 attr1->rdev.specdata2 = attr2->rdev.specdata2;
1300 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1303 verror(VAL_BATCH, E,
1304 " rdev: current = %lu %lu, previous = %lu %lu\n",
1305 attr2->rdev.specdata1, attr2->rdev.specdata2,
1306 attr1->rdev.specdata1, attr1->rdev.specdata2);
1312 if (attr1->fsid._p._l != attr2->fsid._p._l) {
1313 if (attr1->fsid._p._l == (unsigned int)0xFFFFFFFF) {
1316 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1319 verror(VAL_BATCH, I, " fsid: current = %lu, previous = %lu\n",
1320 attr2->fsid._p._l, attr1->fsid._p._l);
1321 attr1->fsid._p._l = attr2->fsid._p._l;
1326 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1329 verror(VAL_BATCH, E, " fsid: current = %lu, previous = %lu\n",
1330 attr2->fsid._p._l, attr1->fsid._p._l);
1336 if (attr1->fileid._p._l != attr2->fileid._p._l) {
1337 if (attr1->fileid._p._l == (unsigned int)0xFFFFFFFF) {
1340 verror(VAL_BATCH, I, "%s: %s attribute mismatch\n",
1343 verror(VAL_BATCH, I,
1344 " fileid: current = %lu, previous = %lu\n",
1345 attr2->fileid._p._l, attr1->fileid._p._l);
1346 attr1->fileid._p._l = attr2->fileid._p._l;
1351 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1354 verror(VAL_BATCH, E,
1355 " fileid: current = %lu, previous = %lu\n",
1356 attr2->fileid._p._l, attr1->fileid._p._l);
1363 verror(VAL_BATCH, I,
1364 "\n Warning: the previous value of a field is -1,\n");
1365 verror(VAL_BATCH, I,
1366 " this resulted from an unused field returned by\n");
1367 verror(VAL_BATCH, I,
1368 " the previous operation on this file/directory.\n");
1369 verror(VAL_BATCH, I,
1370 " The current value is now stored for future comparison\n\n");
1374 verror(VAL_BATCH, W,"\n");
1378 } /* ckompare_fattr */
1381 uint32_t sattr_types[8] = {
1382 0000000, /* NF3NON */
1383 0100000, /* NF3REG */
1384 0040000, /* NF3DIR */
1385 0060000, /* NF3BLK */
1386 0020000, /* NF3CHR */
1387 0120000, /* NF3LNK */
1388 0140000, /* NF3SOCK */
1389 0010000 }; /* NF3FIFO */
1403 if (attr1->mode.mode.set_it == TRUE &&
1404 (((attr1->mode.mode & NFSTYPE_FMT) != sattr_types[attr2->type]) &&
1405 ((attr1->mode.mode & NFSTYPE_FMT) != sattr_types[0]) ||
1406 ((attr1->mode.mode & NFSMODE_FMT) != (attr2->mode & NFSMODE_FMT)))) {
1408 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1412 verror(VAL_BATCH, E, " mode: returned = %7o, specified = %7o\n",
1413 attr1->mode.mode, attr2->mode);
1419 * Check for user "nobody", UID -2, which may be untranslated from
1420 * sixteen-bit two's complement.
1422 if (attr1->uid.set_it == TRUE && attr1->uid.uid != attr2->uid &&
1423 !((attr2->uid == (unsigned int)0xFFFFFFFE ||
1424 attr2->uid == 65534) &&
1425 attr1->uid.uid == 0)) {
1427 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1430 if (attr1->uid.uid == 0)
1431 (void) strcat(msg," (is root UID mapped to other UID?)");
1432 verror(VAL_BATCH, E, " uid: returned = %lu, specified = %lu %s\n",
1433 attr2->uid, attr1->uid.uid, msg);
1437 if (attr1->gid.set_it == TRUE && attr1->gid.gid != attr2->gid &&
1440 if (attr1->gid.set_it == TRUE && attr1->gid != attr2->gid) {
1443 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1446 verror(VAL_BATCH, E, " gid: returned = %lu, specified = %lu\n",
1447 attr2->gid, attr1->gid.gid);
1451 if (attr1->size.set_it == TRUE &&
1452 attr1->size.size._p._l != attr2->size._p._l) {
1454 verror(VAL_BATCH, E, "%s: %s attribute mismatch\n",
1457 verror(VAL_BATCH, E, " size: returned = %lu, specified = %lu\n",
1458 attr2->size._p._l, attr1->size.size._p._l);
1463 verror(VAL_BATCH, W,"\n");
1467 } /* compare_sattr */
1471 * Return the BSD checksum of buf[0..len-1]
1475 unsigned char * buf,
1481 for (; len--; buf++) {
1483 cksum = (cksum >> 1) + 0x8000;
1486 cksum += (uint16_t) *buf;
1495 validate_remove(void)
1507 for (filenum = 0; filenum < NUMFILES; filenum++) {
1509 if (Io_files[filenum].state != Exists)
1512 if (Io_files[filenum].attributes3.type == NF3DIR) {
1513 op = Ops[RMDIR].name;
1514 verror(VAL_VERBOSE, I, "validating rmdir %s ...\n",
1515 Io_files[filenum].file_name);
1517 (void) memmove((char *) &argrd.object.dir,
1518 (char *) &Export_dir.fh3,
1520 argrd.object.name = Io_files[filenum].file_name;
1521 val_op_rmdir(&argrd, &reprd);
1522 reply = reprd.status;
1524 op = Ops[REMOVE].name;
1525 verror(VAL_VERBOSE, I, "validating remove %s ...\n",
1526 Io_files[filenum].file_name);
1528 (void) memmove((char *) &argrm.object.dir, (char *) &Export_dir.fh3,
1530 argrm.object.name = Io_files[filenum].file_name;
1531 val_op_remove(&argrm, &reprm);
1532 reply = reprm.status;
1535 if (reply == NFS3_OK) {
1536 /* make sure the file is removed from the directory */
1537 (void) memmove((char *) &arglp.what.dir, (char *) &Export_dir.fh3,
1539 arglp.what.name = Io_files[filenum].file_name;
1540 val_op_lookup(&arglp, &replp);
1542 if (replp.status == NFS3ERR_NOENT) {
1543 Io_files[filenum].state = Nonexistent;
1544 } else if (replp.status == NFS3_OK) {
1545 verror(VAL_BATCH, W, "%s %s: file not removed\n",
1546 op, Io_files[filenum].file_name);
1548 verror(VAL_BATCH, W, "lookup %s failed: %m\n",
1549 Io_files[filenum].file_name);
1553 verror(VAL_BATCH, W, "%s %s failed: %m\n", op,
1554 Io_files[filenum].file_name);
1559 } /* validate_remove */
1563 validate_cleanup(void)
1569 clnt_destroy(NFS_client);
1570 } /* validate_cleanup */
1576 if (!Validate_errors) {
1577 verror(VAL_BATCH, I, "validation completed successfully.\n");
1580 verror(VAL_BATCH, I, "validation terminated with errors\n");
1584 } /* validate_exit */
1605 * Expand the "%m" format character into the descriptive string
1606 * for the current value of errno. Printf handles the other "%"
1607 * formatting characters.
1609 if (Validate >= opt) {
1610 for (fp = fmt; *fp; fp++) {
1611 if (*fp == '%' && fp[1] == 'm') {
1612 if ((sp = strerror(errno)) == NULL) {
1613 (void) sprintf(bp, "unknown error %d", errno);
1615 (void) strcpy(bp, sp);
1617 bp = buf + strlen(buf);
1624 (void) vfprintf(stderr, buf, ap);
1631 if (msgtype == W && Validate == VAL_INTERACTIVE) {
1636 (void) fprintf(stderr, "continue? (y or n) ");
1637 if (!fgets(ans,80,stdin)) {
1638 (void) fprintf(stderr, "\n");
1641 if (ans[0] == 'n' || ans[0] == 'N') {
1644 } else if (ans[0] == 'y' || ans[0] == 'Y') {
1661 rpc_stat = clnt_call(NFS_client, NFSPROC3_NULL,
1662 xdr_void, (char *)0, xdr_void, (char *)0,
1663 Nfs_timers[Ops[NULLCALL].call_class]);
1664 if (rpc_stat == RPC_SUCCESS)
1666 if (rpc_stat != RPC_TIMEDOUT) {
1667 clnt_perror(NFS_client, "null");
1675 val_op_getattr(GETATTR3args *args, GETATTR3res *reply)
1681 rpc_stat = clnt_call(NFS_client, NFSPROC3_GETATTR,
1682 xdr_GETATTR3args, (char *)args, xdr_GETATTR3res, (char *)reply,
1683 Nfs_timers[Ops[GETATTR].call_class]);
1684 if (rpc_stat == RPC_SUCCESS)
1686 if (rpc_stat != RPC_TIMEDOUT) {
1687 clnt_perror(NFS_client, "getattr");
1695 val_op_setattr(SETATTR3args *args, SETATTR3res *reply)
1701 rpc_stat = clnt_call(NFS_client, NFSPROC3_SETATTR,
1702 xdr_SETATTR3args, (char *)args, xdr_SETATTR3res, (char *)reply,
1703 Nfs_timers[Ops[SETATTR].call_class]);
1704 if (rpc_stat == RPC_SUCCESS)
1706 if (rpc_stat != RPC_TIMEDOUT) {
1707 clnt_perror(NFS_client, "setattr");
1715 val_op_lookup(LOOKUP3args *args, LOOKUP3res *reply)
1721 rpc_stat = clnt_call(NFS_client, NFSPROC3_LOOKUP,
1722 xdr_LOOKUP3args, (char *)args, xdr_LOOKUP3res, (char *)reply,
1723 Nfs_timers[Ops[LOOKUP].call_class]);
1724 if (rpc_stat == RPC_SUCCESS)
1726 if (rpc_stat != RPC_TIMEDOUT) {
1727 clnt_perror(NFS_client, "lookup");
1735 val_op_access(ACCESS3args *args, ACCESS3res *reply)
1741 rpc_stat = clnt_call(NFS_client, NFSPROC3_ACCESS,
1742 xdr_ACCESS3args, (char *)args, xdr_ACCESS3res, (char *)reply,
1743 Nfs_timers[Ops[ACCESS].call_class]);
1744 if (rpc_stat == RPC_SUCCESS)
1746 if (rpc_stat != RPC_TIMEDOUT) {
1747 clnt_perror(NFS_client, "access");
1755 val_op_readlink(READLINK3args *args, READLINK3res *reply)
1761 rpc_stat = clnt_call(NFS_client, NFSPROC3_READLINK,
1762 xdr_READLINK3args, (char *)args, xdr_READLINK3res, (char *)reply,
1763 Nfs_timers[Ops[READLINK].call_class]);
1764 if (rpc_stat == RPC_SUCCESS)
1766 if (rpc_stat != RPC_TIMEDOUT) {
1767 clnt_perror(NFS_client, "readlink");
1775 val_op_read(READ3args *args, READ3res *reply)
1781 rpc_stat = clnt_call(NFS_client, NFSPROC3_READ,
1782 xdr_READ3args, (char *)args, xdr_READ3res, (char *)reply,
1783 Nfs_timers[Ops[READ].call_class]);
1784 if (rpc_stat == RPC_SUCCESS)
1786 if (rpc_stat != RPC_TIMEDOUT) {
1787 clnt_perror(NFS_client, "read");
1795 val_op_write(WRITE3args *args, WRITE3res *reply)
1801 rpc_stat = clnt_call(NFS_client, NFSPROC3_WRITE,
1802 xdr_WRITE3args, (char *)args, xdr_WRITE3res, (char *)reply,
1803 Nfs_timers[Ops[WRITE].call_class]);
1804 if (rpc_stat == RPC_SUCCESS)
1806 if (rpc_stat != RPC_TIMEDOUT) {
1807 clnt_perror(NFS_client, "write");
1815 val_op_create(CREATE3args *args, CREATE3res *reply)
1821 rpc_stat = clnt_call(NFS_client, NFSPROC3_CREATE,
1822 xdr_CREATE3args, (char *)args, xdr_CREATE3res, (char *)reply,
1823 Nfs_timers[Ops[CREATE].call_class]);
1824 if (rpc_stat == RPC_SUCCESS)
1826 if (rpc_stat != RPC_TIMEDOUT) {
1827 clnt_perror(NFS_client, "create");
1835 val_op_mkdir(MKDIR3args *args, MKDIR3res *reply)
1841 rpc_stat = clnt_call(NFS_client, NFSPROC3_MKDIR,
1842 xdr_MKDIR3args, (char *)args, xdr_MKDIR3res, (char *)reply,
1843 Nfs_timers[Ops[MKDIR].call_class]);
1844 if (rpc_stat == RPC_SUCCESS)
1846 if (rpc_stat != RPC_TIMEDOUT) {
1847 clnt_perror(NFS_client, "mkdir");
1855 val_op_symlink(SYMLINK3args *args, SYMLINK3res *reply)
1861 rpc_stat = clnt_call(NFS_client, NFSPROC3_SYMLINK,
1862 xdr_SYMLINK3args, (char *)args, xdr_SYMLINK3res, (char *)reply,
1863 Nfs_timers[Ops[SYMLINK].call_class]);
1864 if (rpc_stat == RPC_SUCCESS)
1866 if (rpc_stat != RPC_TIMEDOUT) {
1867 clnt_perror(NFS_client, "symlink");
1875 val_op_mknod(MKNOD3args *args, MKNOD3res *reply)
1881 rpc_stat = clnt_call(NFS_client, NFSPROC3_MKNOD,
1882 xdr_MKNOD3args, (char *)args, xdr_MKNOD3res, (char *)reply,
1883 Nfs_timers[Ops[MKNOD].call_class]);
1884 if (rpc_stat == RPC_SUCCESS)
1886 if (rpc_stat != RPC_TIMEDOUT) {
1887 clnt_perror(NFS_client, "mknod");
1895 val_op_remove(REMOVE3args *args, REMOVE3res *reply)
1901 rpc_stat = clnt_call(NFS_client, NFSPROC3_REMOVE,
1902 xdr_REMOVE3args, (char *)args, xdr_REMOVE3res, (char *)reply,
1903 Nfs_timers[Ops[REMOVE].call_class]);
1904 if (rpc_stat == RPC_SUCCESS)
1906 if (rpc_stat != RPC_TIMEDOUT) {
1907 clnt_perror(NFS_client, "remove");
1915 val_op_rmdir(RMDIR3args *args, RMDIR3res *reply)
1921 rpc_stat = clnt_call(NFS_client, NFSPROC3_RMDIR,
1922 xdr_RMDIR3args, (char *)args, xdr_RMDIR3res, (char *)reply,
1923 Nfs_timers[Ops[RMDIR].call_class]);
1924 if (rpc_stat == RPC_SUCCESS)
1926 if (rpc_stat != RPC_TIMEDOUT) {
1927 clnt_perror(NFS_client, "rmdir");
1935 val_op_rename(RENAME3args *args, RENAME3res *reply)
1941 rpc_stat = clnt_call(NFS_client, NFSPROC3_RENAME,
1942 xdr_RENAME3args, (char *)args, xdr_RENAME3res, (char *)reply,
1943 Nfs_timers[Ops[RENAME].call_class]);
1944 if (rpc_stat == RPC_SUCCESS)
1946 if (rpc_stat != RPC_TIMEDOUT) {
1947 clnt_perror(NFS_client, "rename");
1955 val_op_link(LINK3args *args, LINK3res *reply)
1961 rpc_stat = clnt_call(NFS_client, NFSPROC3_LINK,
1962 xdr_LINK3args, (char *)args, xdr_LINK3res, (char *)reply,
1963 Nfs_timers[Ops[LINK].call_class]);
1964 if (rpc_stat == RPC_SUCCESS)
1966 if (rpc_stat != RPC_TIMEDOUT) {
1967 clnt_perror(NFS_client,
1976 val_op_readdir(READDIR3args *args, READDIR3res *reply)
1982 rpc_stat = clnt_call(NFS_client, NFSPROC3_READDIR,
1983 xdr_READDIR3args, (char *)args, xdr_READDIR3res, (char *)reply,
1984 Nfs_timers[Ops[READDIR].call_class]);
1985 if (rpc_stat == RPC_SUCCESS)
1987 if (rpc_stat != RPC_TIMEDOUT) {
1988 clnt_perror(NFS_client, "readdir");
1996 val_op_readdirplus(READDIRPLUS3args *args, READDIRPLUS3res *reply)
2002 rpc_stat = clnt_call(NFS_client,
2003 NFSPROC3_READDIRPLUS, xdr_READDIRPLUS3args, (char *)args,
2004 xdr_READDIRPLUS3res, (char *)reply,
2005 Nfs_timers[Ops[READDIRPLUS].call_class]);
2006 if (rpc_stat == RPC_SUCCESS)
2008 if (rpc_stat != RPC_TIMEDOUT) {
2009 clnt_perror(NFS_client,
2018 val_op_fsstat(FSSTAT3args *args, FSSTAT3res *reply)
2024 rpc_stat = clnt_call(NFS_client, NFSPROC3_FSSTAT,
2025 xdr_FSSTAT3args, (char *)args, xdr_FSSTAT3res, (char *)reply,
2026 Nfs_timers[Ops[FSSTAT].call_class]);
2027 if (rpc_stat == RPC_SUCCESS)
2029 if (rpc_stat != RPC_TIMEDOUT) {
2030 clnt_perror(NFS_client, "fsstat");
2038 val_op_fsinfo(FSINFO3args *args, FSINFO3res *reply)
2044 rpc_stat = clnt_call(NFS_client, NFSPROC3_FSINFO,
2045 xdr_FSINFO3args, (char *)args, xdr_FSINFO3res, (char *)reply,
2046 Nfs_timers[Ops[FSINFO].call_class]);
2047 if (rpc_stat == RPC_SUCCESS)
2049 if (rpc_stat != RPC_TIMEDOUT) {
2050 clnt_perror(NFS_client, "fsinfo");
2058 val_op_pathconf(PATHCONF3args *args, PATHCONF3res *reply)
2064 rpc_stat = clnt_call(NFS_client, NFSPROC3_PATHCONF,
2065 xdr_PATHCONF3args, (char *)args, xdr_PATHCONF3res, (char *)reply,
2066 Nfs_timers[Ops[PATHCONF].call_class]);
2067 if (rpc_stat == RPC_SUCCESS)
2069 if (rpc_stat != RPC_TIMEDOUT) {
2070 clnt_perror(NFS_client, "pathconf");
2078 val_op_commit(COMMIT3args *args, COMMIT3res *reply)
2084 rpc_stat = clnt_call(NFS_client, NFSPROC3_COMMIT,
2085 xdr_COMMIT3args, (char *)args, xdr_COMMIT3res, (char *)reply,
2086 Nfs_timers[Ops[COMMIT].call_class]);
2087 if (rpc_stat == RPC_SUCCESS)
2089 if (rpc_stat != RPC_TIMEDOUT) {
2090 clnt_perror(NFS_client, "commit");
2098 create_3tmp_handles(void)
2101 for (filenum = 0; filenum < NUMFILES; filenum++) {
2103 if(Io_files[filenum].fh_data == (sfs_fh_data *)0)
2105 Io_files[filenum].fh_data =
2106 calloc(1,sizeof(sfs_fh_data));
2107 Io_files[filenum].attributes2.type = NFNON;
2108 Io_files[filenum].attributes3.type = NF3NON;
2114 delete_3tmp_handles(void)
2117 for (filenum = 0; filenum < NUMFILES; filenum++) {
2119 if(Io_files[filenum].fh_data != (sfs_fh_data *)0)
2121 free(Io_files[filenum].fh_data);
2122 Io_files[filenum].fh_data= (sfs_fh_data *)0;