Initial import from FreeBSD RELENG_4:
[games.git] / sys / vfs / coda / coda_venus.c
1 /*
2  * 
3  *             Coda: an Experimental Distributed File System
4  *                              Release 3.1
5  * 
6  *           Copyright (c) 1987-1998 Carnegie Mellon University
7  *                          All Rights Reserved
8  * 
9  * Permission  to  use, copy, modify and distribute this software and its
10  * documentation is hereby granted,  provided  that  both  the  copyright
11  * notice  and  this  permission  notice  appear  in  all  copies  of the
12  * software, derivative works or  modified  versions,  and  any  portions
13  * thereof, and that both notices appear in supporting documentation, and
14  * that credit is given to Carnegie Mellon University  in  all  documents
15  * and publicity pertaining to direct or indirect use of this code or its
16  * derivatives.
17  * 
18  * CODA IS AN EXPERIMENTAL SOFTWARE SYSTEM AND IS  KNOWN  TO  HAVE  BUGS,
19  * SOME  OF  WHICH MAY HAVE SERIOUS CONSEQUENCES.  CARNEGIE MELLON ALLOWS
20  * FREE USE OF THIS SOFTWARE IN ITS "AS IS" CONDITION.   CARNEGIE  MELLON
21  * DISCLAIMS  ANY  LIABILITY  OF  ANY  KIND  FOR  ANY  DAMAGES WHATSOEVER
22  * RESULTING DIRECTLY OR INDIRECTLY FROM THE USE OF THIS SOFTWARE  OR  OF
23  * ANY DERIVATIVE WORK.
24  * 
25  * Carnegie  Mellon  encourages  users  of  this  software  to return any
26  * improvements or extensions that  they  make,  and  to  grant  Carnegie
27  * Mellon the rights to redistribute these changes without encumbrance.
28  * 
29  *      @(#) src/sys/cfs/coda_venus.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
30  * $FreeBSD: src/sys/coda/coda_venus.c,v 1.9 1999/08/28 00:40:56 peter Exp $
31  * 
32  */
33
34 #include <sys/param.h>
35 #include <sys/systm.h>
36 #include <sys/malloc.h>
37 #include <sys/proc.h>
38 #include <sys/select.h>
39 #include <sys/ioccom.h>
40 #include <sys/fcntl.h>
41
42 #include <coda/coda.h>
43 #include <coda/cnode.h>
44 #include <coda/coda_venus.h>
45 #include <coda/coda_pioctl.h>
46
47 #define DECL_NO_IN(name)                                \
48     struct coda_in_hdr *inp;                            \
49     struct name ## _out *outp;                          \
50     int name ## _size = sizeof (struct coda_in_hdr);    \
51     int Isize = sizeof (struct coda_in_hdr);            \
52     int Osize = sizeof (struct name ## _out);           \
53     int error
54
55 #define DECL(name)                                      \
56     struct name ## _in *inp;                            \
57     struct name ## _out *outp;                          \
58     int name ## _size = sizeof (struct name ## _in);    \
59     int Isize = sizeof (struct name ## _in);            \
60     int Osize = sizeof (struct name ## _out);           \
61     int error
62
63 #define DECL_NO_OUT(name)                               \
64     struct name ## _in *inp;                            \
65     struct coda_out_hdr *outp;                          \
66     int name ## _size = sizeof (struct name ## _in);    \
67     int Isize = sizeof (struct name ## _in);            \
68     int Osize = sizeof (struct coda_out_hdr);           \
69     int error
70
71 #define ALLOC_NO_IN(name)                               \
72     if (Osize > name ## _size)                          \
73         name ## _size = Osize;                          \
74     CODA_ALLOC(inp, struct coda_in_hdr *, name ## _size);\
75     outp = (struct name ## _out *) inp
76
77 #define ALLOC(name)                                     \
78     if (Osize > name ## _size)                          \
79         name ## _size = Osize;                          \
80     CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
81     outp = (struct name ## _out *) inp
82
83 #define ALLOC_NO_OUT(name)                              \
84     if (Osize > name ## _size)                          \
85         name ## _size = Osize;                          \
86     CODA_ALLOC(inp, struct name ## _in *, name ## _size);\
87     outp = (struct coda_out_hdr *) inp
88
89 #define STRCPY(struc, name, len) \
90     bcopy(name, (char *)inp + (int)inp->struc, len); \
91     ((char*)inp + (int)inp->struc)[len++] = 0; \
92     Isize += len
93
94 #define INIT_IN(in, op, ident, p) \
95           (in)->opcode = (op); \
96           (in)->pid = p ? p->p_pid : -1; \
97           (in)->pgid = p ? p->p_pgid : -1; \
98           (in)->sid = (p && p->p_session && p->p_session->s_leader) ? (p->p_session->s_leader->p_pid) : -1; \
99           if (ident != NOCRED) {                              \
100               (in)->cred.cr_uid = ident->cr_uid;              \
101               (in)->cred.cr_groupid = ident->cr_gid;          \
102           } else {                                            \
103               bzero(&((in)->cred),sizeof(struct coda_cred));  \
104               (in)->cred.cr_uid = -1;                         \
105               (in)->cred.cr_groupid = -1;                     \
106           }                                                   \
107
108 #define CNV_OFLAG(to, from)                             \
109     do {                                                \
110           to = 0;                                       \
111           if (from & FREAD)   to |= C_O_READ;           \
112           if (from & FWRITE)  to |= C_O_WRITE;          \
113           if (from & O_TRUNC) to |= C_O_TRUNC;          \
114           if (from & O_EXCL)  to |= C_O_EXCL;           \
115           if (from & O_CREAT) to |= C_O_CREAT;          \
116     } while (0)
117
118 #define CNV_VV2V_ATTR(top, fromp) \
119         do { \
120                 (top)->va_type = (fromp)->va_type; \
121                 (top)->va_mode = (fromp)->va_mode; \
122                 (top)->va_nlink = (fromp)->va_nlink; \
123                 (top)->va_uid = (fromp)->va_uid; \
124                 (top)->va_gid = (fromp)->va_gid; \
125                 (top)->va_fsid = VNOVAL; \
126                 (top)->va_fileid = (fromp)->va_fileid; \
127                 (top)->va_size = (fromp)->va_size; \
128                 (top)->va_blocksize = (fromp)->va_blocksize; \
129                 (top)->va_atime = (fromp)->va_atime; \
130                 (top)->va_mtime = (fromp)->va_mtime; \
131                 (top)->va_ctime = (fromp)->va_ctime; \
132                 (top)->va_gen = (fromp)->va_gen; \
133                 (top)->va_flags = (fromp)->va_flags; \
134                 (top)->va_rdev = (fromp)->va_rdev; \
135                 (top)->va_bytes = (fromp)->va_bytes; \
136                 (top)->va_filerev = (fromp)->va_filerev; \
137                 (top)->va_vaflags = VNOVAL; \
138                 (top)->va_spare = VNOVAL; \
139         } while (0)
140
141 #define CNV_V2VV_ATTR(top, fromp) \
142         do { \
143                 (top)->va_type = (fromp)->va_type; \
144                 (top)->va_mode = (fromp)->va_mode; \
145                 (top)->va_nlink = (fromp)->va_nlink; \
146                 (top)->va_uid = (fromp)->va_uid; \
147                 (top)->va_gid = (fromp)->va_gid; \
148                 (top)->va_fileid = (fromp)->va_fileid; \
149                 (top)->va_size = (fromp)->va_size; \
150                 (top)->va_blocksize = (fromp)->va_blocksize; \
151                 (top)->va_atime = (fromp)->va_atime; \
152                 (top)->va_mtime = (fromp)->va_mtime; \
153                 (top)->va_ctime = (fromp)->va_ctime; \
154                 (top)->va_gen = (fromp)->va_gen; \
155                 (top)->va_flags = (fromp)->va_flags; \
156                 (top)->va_rdev = (fromp)->va_rdev; \
157                 (top)->va_bytes = (fromp)->va_bytes; \
158                 (top)->va_filerev = (fromp)->va_filerev; \
159         } while (0)
160
161
162 int coda_kernel_version = CODA_KERNEL_VERSION;
163
164 int
165 venus_root(void *mdp,
166         struct ucred *cred, struct proc *p,
167 /*out*/ ViceFid *VFid)
168 {
169     DECL_NO_IN(coda_root);              /* sets Isize & Osize */
170     ALLOC_NO_IN(coda_root);             /* sets inp & outp */
171
172     /* send the open to venus. */
173     INIT_IN(inp, CODA_ROOT, cred, p);  
174
175     error = coda_call(mdp, Isize, &Osize, (char *)inp);
176     if (!error)
177         *VFid = outp->VFid;
178
179     CODA_FREE(inp, coda_root_size);
180     return error;
181 }
182
183 int
184 venus_open(void *mdp, ViceFid *fid, int flag,
185         struct ucred *cred, struct proc *p,
186 /*out*/ dev_t *dev, ino_t *inode)
187 {
188     int cflag;
189     DECL(coda_open);                    /* sets Isize & Osize */
190     ALLOC(coda_open);                   /* sets inp & outp */
191
192     /* send the open to venus. */
193     INIT_IN(&inp->ih, CODA_OPEN, cred, p);
194     inp->VFid = *fid;
195     CNV_OFLAG(cflag, flag);
196     inp->flags = cflag;
197
198     error = coda_call(mdp, Isize, &Osize, (char *)inp);
199     if (!error) {
200 /* 5/11 *dev =  udev2dev(outp->dev, 2); */
201         *dev =  udev2dev(outp->dev, 0);
202         *inode = outp->inode;
203     }
204
205     CODA_FREE(inp, coda_open_size);
206     return error;
207 }
208
209 int
210 venus_close(void *mdp, ViceFid *fid, int flag,
211         struct ucred *cred, struct proc *p)
212 {
213     int cflag;
214     DECL_NO_OUT(coda_close);            /* sets Isize & Osize */
215     ALLOC_NO_OUT(coda_close);           /* sets inp & outp */
216
217     INIT_IN(&inp->ih, CODA_CLOSE, cred, p);
218     inp->VFid = *fid;
219     CNV_OFLAG(cflag, flag);
220     inp->flags = cflag;
221
222     error = coda_call(mdp, Isize, &Osize, (char *)inp);
223
224     CODA_FREE(inp, coda_close_size);
225     return error;
226 }
227
228 /*
229  * these two calls will not exist!!!  the container file is read/written
230  * directly.
231  */
232 void
233 venus_read(void)
234 {
235 }
236
237 void
238 venus_write(void)
239 {
240 }
241
242 /*
243  * this is a bit sad too.  the ioctl's are for the control file, not for
244  * normal files.
245  */
246 int
247 venus_ioctl(void *mdp, ViceFid *fid,
248         int com, int flag, caddr_t data,
249         struct ucred *cred, struct proc *p)
250 {
251     DECL(coda_ioctl);                   /* sets Isize & Osize */
252     struct PioctlData *iap = (struct PioctlData *)data;
253     int tmp;
254
255     coda_ioctl_size = VC_MAXMSGSIZE;
256     ALLOC(coda_ioctl);                  /* sets inp & outp */
257
258     INIT_IN(&inp->ih, CODA_IOCTL, cred, p);
259     inp->VFid = *fid;
260
261     /* command was mutated by increasing its size field to reflect the  
262      * path and follow args. we need to subtract that out before sending
263      * the command to venus.
264      */
265     inp->cmd = (com & ~(IOCPARM_MASK << 16));
266     tmp = ((com >> 16) & IOCPARM_MASK) - sizeof (char *) - sizeof (int);
267     inp->cmd |= (tmp & IOCPARM_MASK) << 16;
268
269     inp->rwflag = flag;
270     inp->len = iap->vi.in_size;
271     inp->data = (char *)(sizeof (struct coda_ioctl_in));
272
273     error = copyin(iap->vi.in, (char*)inp + (int)inp->data, 
274                    iap->vi.in_size);
275     if (error) {
276         CODA_FREE(inp, coda_ioctl_size);
277         return(error);
278     }
279
280     Osize = VC_MAXMSGSIZE;
281     error = coda_call(mdp, Isize + iap->vi.in_size, &Osize, (char *)inp);
282
283         /* copy out the out buffer. */
284     if (!error) {
285         if (outp->len > iap->vi.out_size) {
286             error = EINVAL;
287         } else {
288             error = copyout((char *)outp + (int)outp->data, 
289                             iap->vi.out, iap->vi.out_size);
290         }
291     }
292
293     CODA_FREE(inp, coda_ioctl_size);
294     return error;
295 }
296
297 int
298 venus_getattr(void *mdp, ViceFid *fid,
299         struct ucred *cred, struct proc *p,
300 /*out*/ struct vattr *vap)
301 {
302     DECL(coda_getattr);                 /* sets Isize & Osize */
303     ALLOC(coda_getattr);                        /* sets inp & outp */
304
305     /* send the open to venus. */
306     INIT_IN(&inp->ih, CODA_GETATTR, cred, p);
307     inp->VFid = *fid;
308
309     error = coda_call(mdp, Isize, &Osize, (char *)inp);
310     if (!error) {
311         CNV_VV2V_ATTR(vap, &outp->attr);
312     }
313
314     CODA_FREE(inp, coda_getattr_size);
315     return error;
316 }
317
318 int
319 venus_setattr(void *mdp, ViceFid *fid, struct vattr *vap,
320         struct ucred *cred, struct proc *p)
321 {
322     DECL_NO_OUT(coda_setattr);          /* sets Isize & Osize */
323     ALLOC_NO_OUT(coda_setattr);         /* sets inp & outp */
324
325     /* send the open to venus. */
326     INIT_IN(&inp->ih, CODA_SETATTR, cred, p);
327     inp->VFid = *fid;
328     CNV_V2VV_ATTR(&inp->attr, vap);
329
330     error = coda_call(mdp, Isize, &Osize, (char *)inp);
331
332     CODA_FREE(inp, coda_setattr_size);
333     return error;
334 }
335
336 int
337 venus_access(void *mdp, ViceFid *fid, int mode,
338         struct ucred *cred, struct proc *p)
339 {
340     DECL_NO_OUT(coda_access);           /* sets Isize & Osize */
341     ALLOC_NO_OUT(coda_access);          /* sets inp & outp */
342
343     /* send the open to venus. */
344     INIT_IN(&inp->ih, CODA_ACCESS, cred, p);
345     inp->VFid = *fid;
346     /* NOTE:
347      * NetBSD and Venus internals use the "data" in the low 3 bits.
348      * Hence, the conversion.
349      */
350     inp->flags = mode>>6;
351
352     error = coda_call(mdp, Isize, &Osize, (char *)inp);
353
354     CODA_FREE(inp, coda_access_size);
355     return error;
356 }
357
358 int
359 venus_readlink(void *mdp, ViceFid *fid,
360         struct ucred *cred, struct proc *p,
361 /*out*/ char **str, int *len)
362 {
363     DECL(coda_readlink);                        /* sets Isize & Osize */
364     coda_readlink_size += CODA_MAXPATHLEN;
365     ALLOC(coda_readlink);               /* sets inp & outp */
366
367     /* send the open to venus. */
368     INIT_IN(&inp->ih, CODA_READLINK, cred, p);
369     inp->VFid = *fid;
370
371     Osize += CODA_MAXPATHLEN;
372     error = coda_call(mdp, Isize, &Osize, (char *)inp);
373     if (!error) {
374             CODA_ALLOC(*str, char *, outp->count);
375             *len = outp->count;
376             bcopy((char *)outp + (int)outp->data, *str, *len);
377     }
378
379     CODA_FREE(inp, coda_readlink_size);
380     return error;
381 }
382
383 int
384 venus_fsync(void *mdp, ViceFid *fid,
385         struct ucred *cred, struct proc *p)
386 {
387     DECL_NO_OUT(coda_fsync);            /* sets Isize & Osize */
388     ALLOC_NO_OUT(coda_fsync);           /* sets inp & outp */
389
390     /* send the open to venus. */
391     INIT_IN(&inp->ih, CODA_FSYNC, cred, p);
392     inp->VFid = *fid;
393
394     error = coda_call(mdp, Isize, &Osize, (char *)inp);
395
396     CODA_FREE(inp, coda_fsync_size);
397     return error;
398 }
399
400 int
401 venus_lookup(void *mdp, ViceFid *fid,
402         const char *nm, int len,
403         struct ucred *cred, struct proc *p,
404 /*out*/ ViceFid *VFid, int *vtype)
405 {
406     DECL(coda_lookup);                  /* sets Isize & Osize */
407     coda_lookup_size += len + 1;
408     ALLOC(coda_lookup);                 /* sets inp & outp */
409
410     /* send the open to venus. */
411     INIT_IN(&inp->ih, CODA_LOOKUP, cred, p);
412     inp->VFid = *fid;
413
414     /* NOTE:
415      * Between version 1 and version 2 we have added an extra flag field
416      * to this structure.  But because the string was at the end and because
417      * of the wierd way we represent strings by having the slot point to
418      * where the string characters are in the "heap", we can just slip the
419      * flag parameter in after the string slot pointer and veni that don't
420      * know better won't see this new flag field ...
421      * Otherwise we'd need two different venus_lookup functions.
422      */
423     inp->name = Isize;
424     inp->flags = CLU_CASE_SENSITIVE;    /* doesn't really matter for BSD */
425     STRCPY(name, nm, len);              /* increments Isize */
426
427     error = coda_call(mdp, Isize, &Osize, (char *)inp);
428     if (!error) {
429         *VFid = outp->VFid;
430         *vtype = outp->vtype;
431     }
432
433     CODA_FREE(inp, coda_lookup_size);
434     return error;
435 }
436
437 int
438 venus_create(void *mdp, ViceFid *fid,
439         const char *nm, int len, int exclusive, int mode, struct vattr *va,
440         struct ucred *cred, struct proc *p,
441 /*out*/ ViceFid *VFid, struct vattr *attr)
442 {
443     DECL(coda_create);                  /* sets Isize & Osize */
444     coda_create_size += len + 1;
445     ALLOC(coda_create);                 /* sets inp & outp */
446
447     /* send the open to venus. */
448     INIT_IN(&inp->ih, CODA_CREATE, cred, p);
449     inp->VFid = *fid;
450     inp->excl = exclusive ? C_O_EXCL : 0;
451     inp->mode = mode;
452     CNV_V2VV_ATTR(&inp->attr, va);
453
454     inp->name = Isize;
455     STRCPY(name, nm, len);              /* increments Isize */
456
457     error = coda_call(mdp, Isize, &Osize, (char *)inp);
458     if (!error) {
459         *VFid = outp->VFid;
460         CNV_VV2V_ATTR(attr, &outp->attr);
461     }
462
463     CODA_FREE(inp, coda_create_size);
464     return error;
465 }
466
467 int
468 venus_remove(void *mdp, ViceFid *fid,
469         const char *nm, int len,
470         struct ucred *cred, struct proc *p)
471 {
472     DECL_NO_OUT(coda_remove);           /* sets Isize & Osize */
473     coda_remove_size += len + 1;
474     ALLOC_NO_OUT(coda_remove);          /* sets inp & outp */
475
476     /* send the open to venus. */
477     INIT_IN(&inp->ih, CODA_REMOVE, cred, p);
478     inp->VFid = *fid;
479
480     inp->name = Isize;
481     STRCPY(name, nm, len);              /* increments Isize */
482
483     error = coda_call(mdp, Isize, &Osize, (char *)inp);
484
485     CODA_FREE(inp, coda_remove_size);
486     return error;
487 }
488
489 int
490 venus_link(void *mdp, ViceFid *fid, ViceFid *tfid,
491         const char *nm, int len,
492         struct ucred *cred, struct proc *p)
493 {
494     DECL_NO_OUT(coda_link);             /* sets Isize & Osize */
495     coda_link_size += len + 1;
496     ALLOC_NO_OUT(coda_link);            /* sets inp & outp */
497
498     /* send the open to venus. */
499     INIT_IN(&inp->ih, CODA_LINK, cred, p);
500     inp->sourceFid = *fid;
501     inp->destFid = *tfid;
502
503     inp->tname = Isize;
504     STRCPY(tname, nm, len);             /* increments Isize */
505
506     error = coda_call(mdp, Isize, &Osize, (char *)inp);
507
508     CODA_FREE(inp, coda_link_size);
509     return error;
510 }
511
512 int
513 venus_rename(void *mdp, ViceFid *fid, ViceFid *tfid,
514         const char *nm, int len, const char *tnm, int tlen,
515         struct ucred *cred, struct proc *p)
516 {
517     DECL_NO_OUT(coda_rename);           /* sets Isize & Osize */
518     coda_rename_size += len + 1 + tlen + 1;
519     ALLOC_NO_OUT(coda_rename);          /* sets inp & outp */
520
521     /* send the open to venus. */
522     INIT_IN(&inp->ih, CODA_RENAME, cred, p);
523     inp->sourceFid = *fid;
524     inp->destFid = *tfid;
525
526     inp->srcname = Isize;
527     STRCPY(srcname, nm, len);           /* increments Isize */
528
529     inp->destname = Isize;
530     STRCPY(destname, tnm, tlen);        /* increments Isize */
531
532     error = coda_call(mdp, Isize, &Osize, (char *)inp);
533
534     CODA_FREE(inp, coda_rename_size);
535     return error;
536 }
537
538 int
539 venus_mkdir(void *mdp, ViceFid *fid,
540         const char *nm, int len, struct vattr *va,
541         struct ucred *cred, struct proc *p,
542 /*out*/ ViceFid *VFid, struct vattr *ova)
543 {
544     DECL(coda_mkdir);                   /* sets Isize & Osize */
545     coda_mkdir_size += len + 1;
546     ALLOC(coda_mkdir);                  /* sets inp & outp */
547
548     /* send the open to venus. */
549     INIT_IN(&inp->ih, CODA_MKDIR, cred, p);
550     inp->VFid = *fid;
551     CNV_V2VV_ATTR(&inp->attr, va);
552
553     inp->name = Isize;
554     STRCPY(name, nm, len);              /* increments Isize */
555
556     error = coda_call(mdp, Isize, &Osize, (char *)inp);
557     if (!error) {
558         *VFid = outp->VFid;
559         CNV_VV2V_ATTR(ova, &outp->attr);
560     }
561
562     CODA_FREE(inp, coda_mkdir_size);
563     return error;
564 }
565
566 int
567 venus_rmdir(void *mdp, ViceFid *fid,
568         const char *nm, int len,
569         struct ucred *cred, struct proc *p)
570 {
571     DECL_NO_OUT(coda_rmdir);            /* sets Isize & Osize */
572     coda_rmdir_size += len + 1;
573     ALLOC_NO_OUT(coda_rmdir);           /* sets inp & outp */
574
575     /* send the open to venus. */
576     INIT_IN(&inp->ih, CODA_RMDIR, cred, p);
577     inp->VFid = *fid;
578
579     inp->name = Isize;
580     STRCPY(name, nm, len);              /* increments Isize */
581
582     error = coda_call(mdp, Isize, &Osize, (char *)inp);
583
584     CODA_FREE(inp, coda_rmdir_size);
585     return error;
586 }
587
588 int
589 venus_symlink(void *mdp, ViceFid *fid,
590         const char *lnm, int llen, const char *nm, int len, struct vattr *va,
591         struct ucred *cred, struct proc *p)
592 {
593     DECL_NO_OUT(coda_symlink);          /* sets Isize & Osize */
594     coda_symlink_size += llen + 1 + len + 1;
595     ALLOC_NO_OUT(coda_symlink);         /* sets inp & outp */
596
597     /* send the open to venus. */
598     INIT_IN(&inp->ih, CODA_SYMLINK, cred, p);
599     inp->VFid = *fid;
600     CNV_V2VV_ATTR(&inp->attr, va);
601
602     inp->srcname = Isize;
603     STRCPY(srcname, lnm, llen);         /* increments Isize */
604
605     inp->tname = Isize;
606     STRCPY(tname, nm, len);             /* increments Isize */
607
608     error = coda_call(mdp, Isize, &Osize, (char *)inp);
609
610     CODA_FREE(inp, coda_symlink_size);
611     return error;
612 }
613
614 int
615 venus_readdir(void *mdp, ViceFid *fid,
616         int count, int offset,
617         struct ucred *cred, struct proc *p,
618 /*out*/ char *buffer, int *len)
619 {
620     DECL(coda_readdir);                 /* sets Isize & Osize */
621     coda_readdir_size = VC_MAXMSGSIZE;
622     ALLOC(coda_readdir);                        /* sets inp & outp */
623
624     /* send the open to venus. */
625     INIT_IN(&inp->ih, CODA_READDIR, cred, p);
626     inp->VFid = *fid;
627     inp->count = count;
628     inp->offset = offset;
629
630     Osize = VC_MAXMSGSIZE;
631     error = coda_call(mdp, Isize, &Osize, (char *)inp);
632     if (!error) {
633         bcopy((char *)outp + (int)outp->data, buffer, outp->size);
634         *len = outp->size;
635     }
636
637     CODA_FREE(inp, coda_readdir_size);
638     return error;
639 }
640
641 int
642 venus_fhtovp(void *mdp, ViceFid *fid,
643         struct ucred *cred, struct proc *p,
644 /*out*/ ViceFid *VFid, int *vtype)
645 {
646     DECL(coda_vget);                    /* sets Isize & Osize */
647     ALLOC(coda_vget);                   /* sets inp & outp */
648
649     /* Send the open to Venus. */
650     INIT_IN(&inp->ih, CODA_VGET, cred, p);
651     inp->VFid = *fid;
652
653     error = coda_call(mdp, Isize, &Osize, (char *)inp);
654     if (!error) {
655         *VFid = outp->VFid;
656         *vtype = outp->vtype;
657     }
658
659     CODA_FREE(inp, coda_vget_size);
660     return error;
661 }