Import TBBT (NFS trace replay).
[bluesky.git] / TBBT / trace_play / rfs_3_ops.c.old
1 #ifndef lint
2 static char sfs_3_opsSid[] = "@(#)sfs_3_ops.c   2.1     97/10/23";
3 #endif
4
5 /*
6  *   Copyright (c) 1992-1997,2001 by Standard Performance Evaluation Corporation
7  *      All rights reserved.
8  *              Standard Performance Evaluation Corporation (SPEC)
9  *              6585 Merchant Place, Suite 100
10  *              Warrenton, VA 20187
11  *
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.
15  *
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.
19  *
20  *      The source code is provided to the user or company under the license
21  *      agreement for the SPEC Benchmark Suite for this product.
22  */
23
24 /*****************************************************************
25  *                                                               *
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.              *
32  *                                                               *
33  *****************************************************************/
34
35 #include <stdio.h>
36 #include <stdlib.h>
37 #include <string.h>
38 #include <errno.h>
39
40 #include <sys/types.h>
41 #include <sys/stat.h>
42
43 #include <unistd.h>
44 #include "sfs_c_def.h"
45 #include "rfs_c_def.h"
46
47 extern fh_map_t * lookup_fh (char * trace_fh);
48
49 char * lookup_fhandle(char * fhandle)
50 {
51         fh_map_t * fh;
52         fh = lookup_fh(fhandle);
53         RFS_ASSERT (fh);
54         return ((char *)&fh->play_fh);
55 }
56
57
58 #define setarg_fhandle(fhp) \
59         fh_map_t * fh; \
60         t = strstr (line, "fh");        \
61         RFS_ASSERT (t);                         \
62         t += 3;                                         \
63         fh = lookup_fh(t);                      \
64         RFS_ASSERT (fh);                        \
65         (void) memmove((char *)fhp, &(fh->play_fh),                     \
66                                                                        sizeof (nfs_fh3));       \
67         t+=TRACE_FH_SIZE+1;
68
69 void setarg_getattr (int index, char * line, GETATTR3args * args)
70 {
71         char * t;
72         setarg_fhandle(&args->object);
73 }
74
75 struct ladtime * adjust_time (struct timeval tm, int * sec, int * usec)
76 {
77         struct ladtime trace_pkt_time;
78         static struct ladtime trace_arg_time;
79         struct timeval curtmp;
80         struct ladtime cur;
81
82         /* not sure whether sec ==0 means anything special, do not adjust the timestamp for this */
83         if (*sec ==0) {
84                 RFS_ASSERT (0);
85                 RFS_ASSERT (*usec == 0);
86                 trace_arg_time.sec = 0;
87                 trace_arg_time.usec = 0;
88                 return (&trace_arg_time);
89         }
90         trace_pkt_time.sec = tm.tv_sec;
91         trace_pkt_time.usec = tm.tv_usec;
92
93         trace_arg_time.sec = *sec;
94         trace_arg_time.usec = *usec;
95
96         gettimeofday(&curtmp, NULL);
97         cur.sec = curtmp.tv_sec;
98         cur.usec = curtmp.tv_usec;
99
100         //fprintf (stderr, "trace_pkt_time %d.%d trace_arg_time %d.%d cur %d.%d\n", trace_pkt_time.sec, trace_pkt_time.usec, trace_arg_time.sec, trace_arg_time.usec, cur.sec, cur.usec);
101
102         ADDTIME (trace_arg_time, cur);
103         //fprintf(stderr, "after add, %d.%d\n", trace_arg_time.sec, trace_arg_time.usec);
104         RFS_ASSERT (LARGERTIME (trace_arg_time, trace_pkt_time));
105         SUBTIME (trace_arg_time, trace_pkt_time);
106         return (&trace_arg_time);
107 }
108
109 char * parse_create_mode(char * t, createmode3 * mode)
110 {
111         *mode = UNCHECKED;
112         return (t+2);
113         /* anyway, we can not get concrete result from the trace, just chose this mode */
114         RFS_ASSERT (0);
115 }
116
117 char * parse_sattr3(char * t, sattr3 * args, sattrguard3 * guard, int index)
118 {
119         int i,j;
120         struct ladtime * tm;
121
122         /* set the default value of SETATTR3args->*/
123     args->mode.set_it = FALSE;
124     args->uid.set_it = FALSE;
125     args->gid.set_it = FALSE;
126     args->size.set_it = FALSE;
127     args->atime.set_it = FALSE;
128     args->mtime.set_it = FALSE;
129
130         //fprintf(stderr, "parse_sattr: line %s\n", t);
131         while (1) {
132                 if (!strncmp (t, "mode", 4)) {
133                         t+=5;
134                         sscanf(t, "%x", &i); 
135                         args->mode.set_it = TRUE;
136                         args->mode.mode = i;            // (uint32_t) 0666;
137                 } else if (!strncmp (t, "ctime", 5)) {
138                         RFS_ASSERT (guard);
139                         t+=6;
140                         RFS_ASSERT (strncmp(t, "SERVER", 6));
141                         sscanf (t, "%d.%d", &i, &j);
142                         tm = adjust_time (dep_tab[index].timestamp, &i, &j);
143 #ifndef IGNORE_SETATTR_CTIME
144                         guard->check = TRUE;
145 #endif
146                         guard->obj_ctime.seconds = tm->sec;
147                         guard->obj_ctime.nseconds = tm->usec*1000;
148                 } else if (!strncmp (t, "atime", 5)) {
149                         t+=6;
150                         if (!strncmp(t, "SERVER", 6)) {
151                                 args->atime.set_it = SET_TO_SERVER_TIME;
152                         } else {
153                                 args->atime.set_it = SET_TO_CLIENT_TIME;
154                                 sscanf (t, "%d.%d", &i, &j);
155                                 if (i==0) {
156                                         RFS_ASSERT (j==0);
157                                         args->atime.atime.seconds = 0;
158                                         args->atime.atime.nseconds = 0;
159                                 } else {
160                                         tm = adjust_time (dep_tab[index].timestamp, &i, &j);
161                                         args->atime.atime.seconds = tm->sec;
162                                         args->atime.atime.nseconds = tm->usec * 1000;
163                                 }
164                         }
165                 } else if (!strncmp (t, "mtime", 5)) {
166                         t+=6;
167                         if (!strncmp(t, "SERVER", 6)) {
168                                 args->mtime.set_it = SET_TO_SERVER_TIME;
169                         } else {
170                                 args->mtime.set_it = SET_TO_CLIENT_TIME;
171                                 sscanf (t, "%d.%d", &i, &j);
172                                 if (i==0) {
173                                         RFS_ASSERT (j==0);
174                                         args->mtime.mtime.seconds = 0;
175                                         args->mtime.mtime.nseconds = 0;
176                                 } else {
177                                         tm = adjust_time (dep_tab[index].timestamp, &i, &j);
178                                         args->mtime.set_it = TRUE;
179                                         args->mtime.mtime.seconds = tm->sec;
180                                         args->mtime.mtime.nseconds = tm->usec * 1000;
181                                 }
182                         }
183                 } else if (!strncmp (t, "size", 4)) {
184                                 t+=5;
185                         sscanf(t, "%x", &i); 
186                         args->size.set_it = TRUE;
187                         args->size.size._p._u = (uint32_t) 0;
188                         args->size.size._p._l = (uint32_t) i;
189                 } else if (!strncmp (t, "gid", 3)) {
190                         t+=4;
191                         sscanf(t, "%x", &i); 
192                         args->gid.set_it = TRUE;
193 #ifdef TAKE_CARE_SETATTR_GID
194                         args->gid.gid = i;
195 #else
196                         args->gid.gid = 513;
197 #endif
198                 } else if ( !strncmp (t, "uid", 3)) {
199                         t+=4;
200                         sscanf(t, "%x", &i); 
201                         args->uid.set_it = TRUE;
202 #ifdef TAKE_CARE_SETATTR_UID
203                         args->uid.uid = i;
204 #else
205                         args->uid.uid = 513;
206 #endif
207                 } else if (!strncmp (t, "con", 3)) {
208                         break;
209                 } else if (!strncmp (t, "sdata", 5)) {
210                         break;
211                 } else {
212                         fprintf(stderr, "parse_sattr t: %s\n", t);
213                         RFS_ASSERT (0);
214                 }
215
216                 while (*t!=' ')
217                         t++;
218                 t++;
219         }
220         return t;
221 }
222
223 char * parse_name (char * t, char * buf)
224 {
225         int i;
226         if (!strncmp(t, "fn2", 3))
227                 t+=4;
228         else if (!strncmp(t, "fn", 2))
229                 t+=3;
230         else if (!strncmp(t, "name2", 5))
231                 t+=6;
232         else if (!strncmp(t, "name", 4))
233                 t+=5;
234         else if (!strncmp(t, "sdata", 5))
235                 t+=6;
236         else {
237                 fprintf(stderr, "%s\n", t);
238                 RFS_ASSERT (0);
239         }
240
241         RFS_ASSERT (*t=='"');
242         t++;
243         i = 0;
244         while (*t!='"')
245                 buf[i++] = *t++; // ??? name buffer?    
246         RFS_ASSERT ((*t)=='"');
247         buf[i] = 0;
248         return (t+2);
249 }
250
251 char * parse_access_mode (char * line, int * mode)
252 {
253         *mode = ACCESS3_READ;   
254         return line+2;
255         /* anyway the information in the trace is not enough, so we just make up something */
256 }
257
258 char * parse_stable_mode (char * line, stable_how * mode)
259 {
260         switch (*line) {
261         case 'U': *mode = UNSTABLE;
262                           break;
263         case 'F': *mode = FILE_SYNC;
264                           break;
265         case 'D': *mode = DATA_SYNC;
266                           break;
267         default:
268                 RFS_ASSERT (0);
269         }
270         return line +2;
271 }
272
273
274 void setarg_setattr (int index, char * line, SETATTR3args * args)
275 {
276         char * t;
277         int i, j;
278         
279         setarg_fhandle(&args->object);
280         args->guard.check = FALSE;
281         t = parse_sattr3 (t, &(args->new_attributes), &(args->guard), index);
282 }
283
284 void setarg_lookup (int index, char * line, LOOKUP3args * args, char * Cur_filename)
285 {
286         char * t;
287         setarg_fhandle(&args->what.dir)
288         t = parse_name (t, Cur_filename);
289         args->what.name = Cur_filename;
290 }
291
292 void setarg_access (int index, char * line, ACCESS3args * args)
293 {
294         char * t;
295
296         setarg_fhandle (&args->object);
297         parse_access_mode (t, &args->access);   //ACCESS3_MODIFY;       // ??? the actual parameter can be different
298 }
299
300 void setarg_readlink (int index, char * line, READLINK3args * args)
301 {
302         char * t;
303         setarg_fhandle (&args->symlink);
304 }
305
306 void setarg_read (int index, char * line, READ3args * args, char * buf)
307 {
308         char * t;
309         int i;
310         setarg_fhandle (&args->file);
311
312         if (line[TRACE_VERSION_POS]=='3') {
313                 t = strstr (t, "off");
314                 RFS_ASSERT (t);
315                 t+=4;
316         } else {
317                 t = strstr (t, "offset");
318                 RFS_ASSERT (t);
319                 t+=7;
320         }
321         sscanf (t, "%x", &i);
322
323         RFS_ASSERT (i>=0 && i<0x7FFFFFFF)
324         args->offset._p._u = 0;
325         args->offset._p._l = i;
326         t = strstr (t, "count");
327         RFS_ASSERT (t);
328         t+=6;
329         sscanf (t, "%x", &i);
330
331         RFS_ASSERT (i <= 32768);
332         if (i > NFS_MAXDATA) {
333                 read_data_owe += (i-NFS_MAXDATA);
334                 read_data_adjust_times ++;
335                 if (read_data_owe > 1073741824) {
336                         read_data_owe -= 1073741824;
337                         read_data_owe_GB ++;
338                 }
339                 
340                 //printf ("adjust read count from %d to %d\n", i, NFS_MAXDATA);
341                 i = NFS_MAXDATA;
342         }
343         read_data_total += i;
344         RFS_ASSERT (read_data_total <1073741824);
345
346         args->count = i;
347 }
348
349 void setarg_write (int index, char * line, WRITE3args * args, char * buf)
350 {
351         char * t;
352         int i;
353         setarg_fhandle (&args->file);
354
355         //fprintf (stderr, "process write: %s\n", line);
356         if (line[TRACE_VERSION_POS]=='3') {
357                 t = strstr (t, "off");
358                 RFS_ASSERT (t);
359                 t+=4;
360         } else {
361                 RFS_ASSERT (line[TRACE_VERSION_POS]=='2');
362                 t = strstr (t, "offset");
363                 RFS_ASSERT (t);
364                 t+=7;
365         }
366
367         sscanf (t, "%x", &i);
368         RFS_ASSERT (i>=0 && i<0x7FFFFFFF)
369         args->offset._p._u = 0;
370         args->offset._p._l = i;
371
372         t = strstr (t, "count");
373         RFS_ASSERT (t);
374         t+=6;
375         sscanf (t, "%x", &i);
376         RFS_ASSERT (i <= 32768);
377         if (i > NFS_MAXDATA) {
378                 write_data_owe += (i-NFS_MAXDATA);
379                 if (write_data_owe > 1073741824) {
380                         write_data_owe -= 1073741824;
381                         write_data_owe_GB ++;
382                 }
383                 write_data_adjust_times ++;
384                 //printf ("adjust write count from %d to %d\n", i, NFS_MAXDATA);
385                 i = NFS_MAXDATA;
386         }
387         write_data_total += i;
388         RFS_ASSERT (write_data_total <1073741824);
389
390         RFS_ASSERT (i < MAX_BUF1_SIZE-128);     /* 128 is some random safe number to add */
391         args->count = i;
392
393         if (line[TRACE_VERSION_POS]==3) {
394                 t = strstr (t, "stable");
395                 RFS_ASSERT (t);
396                 t+=7;
397                 parse_stable_mode(t, &args->stable);    /* *t can be F, U, etc */ 
398         } else
399                 args->stable = UNSTABLE;
400         args->data.data_len = args->count;
401         args->data.data_val = buf;
402 }
403
404 void setarg_create (int index, char * line, CREATE3args * args, char * Cur_filename)
405 {
406         char * t;
407         //fprintf(stderr, "process create %s\n", line);
408         setarg_fhandle (&args->where.dir);
409         t = parse_name (t, Cur_filename);
410         args->where.name = Cur_filename;
411         if (line[TRACE_VERSION_POS]=='3') {
412                 RFS_ASSERT (!strncmp(t, "how", 3));
413                 t+=4;
414         t = parse_create_mode (t, &args->how.mode);
415         } else
416                 args->how.mode = UNCHECKED;
417         t = parse_sattr3 (t, &(args->how.createhow3_u.obj_attributes), NULL, index);
418 }
419
420 void setarg_create_old (int index, char * line, CREATE3args * retargs, char * Cur_filename)
421 {
422         CREATE3args args;
423
424         sprintf(Cur_filename, "%d", index);
425         if (rfs_debug)
426                 printf ("create file %s\n", Cur_filename);
427
428     /* set up the arguments */
429     (void) memmove((char *)&args.where.dir, (char *) &Cur_file_ptr->dir->fh3,
430                 sizeof (nfs_fh3));
431     args.where.name = Cur_filename; //RFS need a buffer for the name 
432     args.how.mode = UNCHECKED;
433     args.how.createhow3_u.obj_attributes.mode.set_it = TRUE;
434     args.how.createhow3_u.obj_attributes.mode.mode = (NFSMODE_REG | 0666);
435     args.how.createhow3_u.obj_attributes.uid.set_it = TRUE;
436     args.how.createhow3_u.obj_attributes.uid.uid = Cur_uid;
437     args.how.createhow3_u.obj_attributes.gid.set_it = TRUE;
438     args.how.createhow3_u.obj_attributes.gid.gid = Cur_gid;
439     args.how.createhow3_u.obj_attributes.atime.set_it = TRUE;
440     args.how.createhow3_u.obj_attributes.atime.atime.seconds = Cur_time.esec;
441     args.how.createhow3_u.obj_attributes.atime.atime.nseconds =
442                                                 Cur_time.usec * 1000;
443     args.how.createhow3_u.obj_attributes.mtime.set_it = TRUE;
444     args.how.createhow3_u.obj_attributes.mtime.mtime.seconds = Cur_time.esec;
445     args.how.createhow3_u.obj_attributes.mtime.mtime.nseconds =
446                                                 Cur_time.usec * 1000;
447     args.how.createhow3_u.obj_attributes.size.set_it = TRUE;
448     args.how.createhow3_u.obj_attributes.size.size._p._u = (uint32_t) 0;
449     args.how.createhow3_u.obj_attributes.size.size._p._l = (uint32_t) 0;
450
451         memcpy (retargs, &args, sizeof (CREATE3args));
452 }
453
454 void setarg_mkdir (int index, char * line, MKDIR3args * args, char * Cur_filename)
455 {
456         char * t;
457         setarg_fhandle (&args->where.dir);
458         t = parse_name (t, Cur_filename);
459         args->where.name = Cur_filename;
460         t = parse_sattr3 (t, &(args->attributes), NULL, index);
461 }
462
463 void setarg_symlink(int index, char * line, SYMLINK3args * args, char * Cur_filename, char * sym_data)
464 {
465         char * t;
466         setarg_fhandle (&args->where.dir);
467         t = parse_name (t, Cur_filename);
468         args->where.name = Cur_filename;
469         if (line[TRACE_VERSION_POS]=='2') {
470                 t = parse_name (t, sym_data);
471                 t = parse_sattr3 (t, &(args->symlink.symlink_attributes), NULL, index);
472         } else {
473                 t = parse_sattr3 (t, &(args->symlink.symlink_attributes), NULL, index);
474                 t = parse_name (t, sym_data);
475         }
476     args->symlink.symlink_data = sym_data;
477 }
478
479 void setarg_mknod(int index, char * line, MKNOD3args * args, char * Cur_filename)
480 {
481         RFS_ASSERT (0);
482
483 #ifdef notdef
484         /* set up the arguments */
485     (void) memmove((char *) &args.where.dir, (char *) &Cur_file_ptr->dir->fh3,
486                 sizeof (nfs_fh3));
487     args.where.name = Cur_filename;
488     args.what.type = NF3FIFO;
489     args.what.mknoddata3_u.pipe_attributes.mode.set_it = TRUE;
490     args.what.mknoddata3_u.pipe_attributes.mode.mode = (NFSMODE_FIFO | 0777);
491     args.what.mknoddata3_u.pipe_attributes.uid.set_it = TRUE;
492     args.what.mknoddata3_u.pipe_attributes.uid.uid = Cur_uid;
493     args.what.mknoddata3_u.pipe_attributes.gid.set_it = TRUE;
494     args.what.mknoddata3_u.pipe_attributes.gid.gid = Cur_gid;
495     args.what.mknoddata3_u.pipe_attributes.size.set_it = TRUE;
496     args.what.mknoddata3_u.pipe_attributes.size.size._p._u = (uint32_t) 0;
497     args.what.mknoddata3_u.pipe_attributes.size.size._p._l =
498                                                         (uint32_t) 512;
499     args.what.mknoddata3_u.pipe_attributes.atime.set_it = TRUE;
500     args.what.mknoddata3_u.pipe_attributes.atime.atime.seconds =
501                                                         Cur_time.esec;
502     args.what.mknoddata3_u.pipe_attributes.atime.atime.nseconds =
503                                                         Cur_time.usec * 1000;
504     args.what.mknoddata3_u.pipe_attributes.mtime.set_it = TRUE;
505     args.what.mknoddata3_u.pipe_attributes.mtime.mtime.seconds =
506                                                                 Cur_time.esec;
507     args.what.mknoddata3_u.pipe_attributes.mtime.mtime.nseconds =
508                                                         Cur_time.usec * 1000;
509 #endif
510 }
511
512 void setarg_remove (int index, char * line, REMOVE3args * args, char * Cur_filename)
513 {
514         char * t;
515         setarg_fhandle(&args->object.dir)
516         t = parse_name (t, Cur_filename);
517         args->object.name = Cur_filename;
518 }
519
520 void setarg_rmdir (int index, char * line, RMDIR3args * args, char * Cur_filename)
521 {
522         char * t;
523         setarg_fhandle(&args->object.dir)
524         t = parse_name (t, Cur_filename);
525         args->object.name = Cur_filename;
526 }
527
528 void setarg_rename (int index, char * line, RENAME3args * args, char * fromname, char * toname)
529 {
530         char * t;
531         setarg_fhandle(&args->from.dir)
532         t = parse_name (t, fromname);
533         args->from.name = fromname;
534
535         t = strstr (t, "fh2");  
536         RFS_ASSERT (t);                         
537         t += 4;                                         
538         memmove((char *)&args->to.dir, lookup_fhandle(t), sizeof (nfs_fh3));    
539         t+=65;
540
541         t = parse_name (t, toname);
542         args->to.name = toname;
543 }
544
545 void setarg_link (int index, char * line, LINK3args * args, char * Cur_filename)
546 {
547         char * t;
548
549         setarg_fhandle(&args->file)
550
551         t = strstr (t, "fh2");  
552         RFS_ASSERT (t);                         
553         t += 4;                                         
554         memmove((char *)&args->link.dir, lookup_fhandle(t), sizeof (nfs_fh3));  
555         t+=65;
556
557         t = parse_name (t, Cur_filename);
558         args->link.name = Cur_filename;
559 }
560
561 void  setarg_readdir (int index, char * line, READDIR3args * args)
562 {
563         char * t;
564
565         setarg_fhandle(&args->dir);
566         /* args->cookieverf is notset, it is not implemented in the linux-2.4.7 */
567         sscanf(t, "cookie %d count %d", &args->cookie._p._l, &args->count);
568     (void) memset((char *) args->cookieverf, '\0', NFS3_COOKIEVERFSIZE);
569         args->cookie._p._u = (uint32_t) 0;
570 }
571
572 void  setarg_readdirplus (int index, char * line, READDIRPLUS3args * args)
573 {
574         char * t;
575
576         setarg_fhandle(&args->dir);
577         /* args->cookieverf is notset, it is not implemented in the linux-2.4.7 */
578         sscanf(t, "cookie %d count %d maxcnt", &args->cookie._p._l, &args->dircount, &args->maxcount);
579     (void) memset((char *) args->cookieverf, '\0', NFS3_COOKIEVERFSIZE);
580         args->cookie._p._u = (uint32_t) 0;
581
582 #ifdef notdef
583     /* set up the arguments */
584     (void) memmove((char *) &args.dir, (char *) &Cur_file_ptr->dir->fh3,
585                 sizeof (nfs_fh3));
586     args.cookie._p._l = args.cookie._p._u = (uint32_t) 0;
587     (void) memset((char *) args.cookieverf, '\0', NFS3_COOKIEVERFSIZE);
588         args.dircount = DEFAULT_MAX_BUFSIZE;
589         args.maxcount = DEFAULT_MAX_BUFSIZE;
590 #endif
591 }
592
593 void setarg_fsstat (int index, char * line, FSSTAT3args * args)
594 {
595         char * t;
596         setarg_fhandle(&args->fsroot);
597 }
598
599 void setarg_fsinfo (int index, char * line, FSINFO3args * args)
600 {
601         char * t;
602         setarg_fhandle(&args->fsroot);
603 }
604
605 void setarg_pathconf (int index, char * line, PATHCONF3args * args)
606 {
607         char * t;
608         setarg_fhandle(&args->object);
609 }
610
611 void setarg_commit (int index, char * line, COMMIT3args * args)
612 {
613         RFS_ASSERT (0);
614
615 #ifdef notdef
616         /* set up the arguments */
617         (void) memmove((char *) &args.file, (char *) &Cur_file_ptr->fh3,
618                    sizeof (nfs_fh3));
619         args.offset._p._u = args.offset._p._l = (uint32_t) 0;
620         args.count = Cur_file_ptr->attributes3.size._p._l;
621 #endif
622 }
623
624 void setbuf_void (char * buf)
625 {
626         return;
627 }
628
629 void setbuf_invalid (char * buf)
630 {
631         RFS_ASSERT (0);
632 }
633
634 void setres_lookup (LOOKUP3res * reply)
635 {
636     (void) memset((char *) &(reply->resok.object), '\0', sizeof (nfs_fh3));
637 }
638
639 void setres_readlink (READLINK3res * reply, char * sym_data)
640 {
641     /* Have lower layers fill in the data directly. */
642     reply->resok.data = sym_data;
643 }
644
645 void setres_read (READ3res * reply, char * buf)
646 {
647         /* Have lower layers fill in the data directly.  */
648         reply->resok.data.data_len = 0;
649         reply->resok.data.data_val = buf;
650 }
651
652 void setres_readdir (READDIR3res * reply, entry3 * entry_stream)
653 {
654     /* Have lower layers fill in the data directly.  */
655     (void) memset((char *) reply, '\0', sizeof (READDIR3res));
656     (void) memset((char *) entry_stream, '\0',
657                                         sizeof (entry3) * SFS_MAXDIRENTS);
658     reply->resok.count = SFS_MAXDIRENTS;
659     reply->resok.reply.entries = entry_stream;
660 }
661
662 void setres_readdirplus (READDIRPLUS3res * reply, entryplus3 * entry_stream)
663 {
664     (void) memset((char *) reply, '\0', sizeof (READDIRPLUS3res));
665         //printf ("sizeof(entryplus3) %d SFS_MAXDIRENT %d\n", sizeof (entryplus3), SFS_MAXDIRENTS);
666     (void) memset((char *) entry_stream, '\0',
667                                 sizeof (entryplus3) * SFS_MAXDIRENTS);
668     reply->resok.count = SFS_MAXDIRENTS;
669     reply->resok.reply.entries = entry_stream;
670 }
671
672 #define NFSPROC3_INVALID -1
673 /* the array is indexed by sfs operation number */
674 rfs_op_type rfs_Ops[TOTAL] = {
675 {NFSPROC3_NULL,         setbuf_void,            setbuf_void, xdr_void, xdr_void},
676 {NFSPROC3_GETATTR,      setarg_getattr,         setbuf_void, xdr_GETATTR3args, xdr_GETATTR3res},
677 {NFSPROC3_SETATTR,      setarg_setattr,         setbuf_void, xdr_SETATTR3args, xdr_SETATTR3res},
678 {NFSPROC3_INVALID,      setbuf_invalid,         setbuf_invalid, NULL, NULL},
679 {NFSPROC3_LOOKUP,       setarg_lookup,          setres_lookup, xdr_LOOKUP3args, xdr_LOOKUP3res},
680 {NFSPROC3_READLINK, setarg_readlink,    setres_readlink, xdr_READLINK3args, xdr_READLINK3res},
681 {NFSPROC3_READ,         setarg_read,            setres_read, xdr_READ3args, xdr_READ3res},
682 {NFSPROC3_INVALID,      setbuf_invalid,         setbuf_invalid, NULL, NULL},
683 {NFSPROC3_WRITE,        setarg_write,           setbuf_void, xdr_WRITE3args, xdr_WRITE3res},
684 {NFSPROC3_CREATE,       setarg_create,          setbuf_void, xdr_CREATE3args, xdr_CREATE3res},
685 {NFSPROC3_REMOVE,       setarg_remove,          setbuf_void, xdr_REMOVE3args, xdr_REMOVE3res},
686 {NFSPROC3_RENAME,       setarg_rename,          setbuf_void, xdr_RENAME3args, xdr_RENAME3res},
687 {NFSPROC3_LINK,         setarg_link,            setbuf_void, xdr_LINK3args, xdr_LINK3res},
688 {NFSPROC3_SYMLINK,      setarg_symlink,         setbuf_void, xdr_SYMLINK3args, xdr_SYMLINK3res},
689 {NFSPROC3_MKDIR,        setarg_mkdir,           setbuf_void, xdr_MKDIR3args, xdr_MKDIR3res},
690 {NFSPROC3_RMDIR,        setarg_rmdir,           setbuf_void, xdr_RMDIR3args, xdr_RMDIR3res},
691 {NFSPROC3_READDIR,      setarg_readdir,         setres_readdir, xdr_READDIR3args, xdr_READDIR3res},
692 {NFSPROC3_FSSTAT,       setarg_fsstat,          setbuf_void, xdr_FSSTAT3args, xdr_FSSTAT3res},
693 {NFSPROC3_ACCESS,       setarg_access,          setbuf_void, xdr_ACCESS3args, xdr_ACCESS3res},
694 {NFSPROC3_COMMIT,       setarg_commit,          setbuf_void, xdr_COMMIT3args, xdr_COMMIT3res},
695 {NFSPROC3_FSINFO,       setarg_fsinfo,          setbuf_void,  xdr_FSINFO3args, xdr_FSINFO3res},
696 {NFSPROC3_MKNOD,        setarg_mknod,           setbuf_void, xdr_MKNOD3args, xdr_MKNOD3res},
697 {NFSPROC3_PATHCONF, setarg_pathconf,    setbuf_void, xdr_PATHCONF3args, xdr_PATHCONF3res},
698 {NFSPROC3_READDIRPLUS, setarg_readdirplus, setres_readdirplus, xdr_READDIRPLUS3args, xdr_READDIRPLUS3res}};
699
700 /*
701  * --------------------  NFS ops vector --------------------
702  */
703 /*
704  * per operation information
705  */
706 sfs_op_type nfsv3_Ops[] = {
707
708 /* name        mix    op    call  no  req  req  req  results */
709 /*             pcnt  class  targ call pcnt cnt  targ         */
710
711  { "null",        0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
712  { "getattr",    11, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
713  { "setattr",     1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
714  { "root",        0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
715  { "lookup",     27, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
716  { "readlink",    7, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
717  { "read",       18, Read,    0,  0,  0.0,  0,   0,  { 0, }},
718  { "wrcache",     0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
719  { "write",       9, Write,   0,  0,  0.0,  0,   0,  { 0, }},
720  { "create",      1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
721  { "remove",      1, Write,   0,  0,  0.0,  0,   0,  { 0, }},
722  { "rename",      0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
723  { "link",        0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
724  { "symlink",     0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
725  { "mkdir",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
726  { "rmdir",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
727  { "readdir",     2, Read,    0,  0,  0.0,  0,   0,  { 0, }},
728  { "fsstat",      1, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
729  { "access",      7, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
730  { "commit",      5, Write,   0,  0,  0.0,  0,   0,  { 0, }},
731  { "fsinfo",      1, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
732  { "mknod",       0, Write,   0,  0,  0.0,  0,   0,  { 0, }},
733  { "pathconf",    0, Lookup,  0,  0,  0.0,  0,   0,  { 0, }},
734  { "readdirplus", 9, Read,   0,  0,  0.0,  0,   0,  { 0, }},
735  { "TOTAL",     100, Lookup,  0,  0,  0.0,  0,   0,  { 0, }}
736 };
737
738 sfs_op_type *Ops;
739