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