Deleted Added
sdiff udiff text old ( 118047 ) new ( 119832 )
full compact
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/coda/coda_vnops.c,v 1.1.1.1 1998/08/29 21:14:52 rvb Exp $
29 */
30/*
31 * Mach Operating System
32 * Copyright (c) 1990 Carnegie-Mellon University
33 * Copyright (c) 1989 Carnegie-Mellon University
34 * All rights reserved. The CMU software License Agreement specifies
35 * the terms and conditions for use and redistribution.
36 */
37
38/*
39 * This code was written for the Coda filesystem at Carnegie Mellon
40 * University. Contributers include David Steere, James Kistler, and
41 * M. Satyanarayanan.
42 */
43
44#include <sys/cdefs.h>
45__FBSDID("$FreeBSD: head/sys/fs/coda/coda_vnops.c 119832 2003-09-07 07:43:10Z tjr $");
46
47#include <sys/param.h>
48#include <sys/systm.h>
49#include <sys/acct.h>
50#include <sys/errno.h>
51#include <sys/fcntl.h>
52#include <sys/kernel.h>
53#include <sys/lock.h>
54#include <sys/malloc.h>
55#include <sys/file.h> /* Must come after sys/malloc.h */
56#include <sys/mount.h>
57#include <sys/mutex.h>
58#include <sys/namei.h>
59#include <sys/proc.h>
60#include <sys/uio.h>
61#include <sys/unistd.h>
62
63#include <vm/vm.h>
64#include <vm/vm_object.h>
65#include <vm/vm_extern.h>
66
67#include <coda/coda.h>
68#include <coda/cnode.h>
69#include <coda/coda_vnops.h>
70#include <coda/coda_venus.h>
71#include <coda/coda_opstats.h>
72#include <coda/coda_subr.h>
73#include <coda/coda_namecache.h>
74#include <coda/coda_pioctl.h>
75
76/*
77 * These flags select various performance enhancements.
78 */
79int coda_attr_cache = 1; /* Set to cache attributes in the kernel */
80int coda_symlink_cache = 1; /* Set to cache symbolic link information */
81int coda_access_cache = 1; /* Set to handle some access checks directly */
82
83/* structure to keep track of vfs calls */
84
85struct coda_op_stats coda_vnodeopstats[CODA_VNODEOPS_SIZE];
86
87#define MARK_ENTRY(op) (coda_vnodeopstats[op].entries++)
88#define MARK_INT_SAT(op) (coda_vnodeopstats[op].sat_intrn++)
89#define MARK_INT_FAIL(op) (coda_vnodeopstats[op].unsat_intrn++)
90#define MARK_INT_GEN(op) (coda_vnodeopstats[op].gen_intrn++)
91
92/* What we are delaying for in printf */
93int coda_printf_delay = 0; /* in microseconds */
94int coda_vnop_print_entry = 0;
95static int coda_lockdebug = 0;
96
97/* Definition of the vfs operation vector */
98static int (**coda_vnodeop_p)(void *);
99
100/*
101 * Some NetBSD details:
102 *
103 * coda_start is called at the end of the mount syscall.
104 * coda_init is called at boot time.
105 */
106
107#define ENTRY if(coda_vnop_print_entry) myprintf(("Entered %s\n",__func__))
108
109/* Definition of the vnode operation vector */
110
111struct vnodeopv_entry_desc coda_vnodeop_entries[] = {
112 { &vop_default_desc, coda_vop_error },
113 { &vop_lookup_desc, coda_lookup }, /* lookup */
114 { &vop_create_desc, coda_create }, /* create */
115 { &vop_mknod_desc, coda_vop_error }, /* mknod */
116 { &vop_open_desc, coda_open }, /* open */
117 { &vop_close_desc, coda_close }, /* close */
118 { &vop_access_desc, coda_access }, /* access */
119 { &vop_getattr_desc, coda_getattr }, /* getattr */
120 { &vop_setattr_desc, coda_setattr }, /* setattr */
121 { &vop_read_desc, coda_read }, /* read */
122 { &vop_write_desc, coda_write }, /* write */
123 { &vop_ioctl_desc, coda_ioctl }, /* ioctl */
124 { &vop_fsync_desc, coda_fsync }, /* fsync */
125 { &vop_remove_desc, coda_remove }, /* remove */
126 { &vop_link_desc, coda_link }, /* link */
127 { &vop_rename_desc, coda_rename }, /* rename */
128 { &vop_mkdir_desc, coda_mkdir }, /* mkdir */
129 { &vop_rmdir_desc, coda_rmdir }, /* rmdir */
130 { &vop_symlink_desc, coda_symlink }, /* symlink */
131 { &vop_readdir_desc, coda_readdir }, /* readdir */
132 { &vop_readlink_desc, coda_readlink }, /* readlink */
133 { &vop_inactive_desc, coda_inactive }, /* inactive */
134 { &vop_reclaim_desc, coda_reclaim }, /* reclaim */
135 { &vop_lock_desc, coda_lock }, /* lock */
136 { &vop_unlock_desc, coda_unlock }, /* unlock */
137 { &vop_bmap_desc, coda_bmap }, /* bmap */
138 { &vop_print_desc, coda_vop_error }, /* print */
139 { &vop_islocked_desc, coda_islocked }, /* islocked */
140 { &vop_pathconf_desc, coda_pathconf }, /* pathconf */
141 { &vop_advlock_desc, coda_vop_nop }, /* advlock */
142 { &vop_lease_desc, coda_vop_nop }, /* lease */
143 { &vop_poll_desc, (vop_t *) vop_stdpoll },
144 { &vop_getpages_desc, (vop_t*)vop_stdgetpages }, /* pager intf.*/
145 { &vop_putpages_desc, (vop_t*)vop_stdputpages }, /* pager intf.*/
146 { &vop_createvobject_desc, (vop_t*)vop_stdcreatevobject },
147 { &vop_destroyvobject_desc, (vop_t*)vop_stddestroyvobject },
148 { &vop_getvobject_desc, (vop_t*)vop_stdgetvobject },
149
150#if 0
151
152 we need to define these someday
153#define UFS_BLKATOFF(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_blkatoff(aa, bb, cc, dd)
154#define UFS_VALLOC(aa, bb, cc, dd) VFSTOUFS((aa)->v_mount)->um_valloc(aa, bb, cc, dd)
155#define UFS_VFREE(aa, bb, cc) VFSTOUFS((aa)->v_mount)->um_vfree(aa, bb, cc)
156#define UFS_TRUNCATE(aa, bb, cc, dd, ee) VFSTOUFS((aa)->v_mount)->um_truncate(aa, bb, cc, dd, ee)
157#define UFS_UPDATE(aa, bb) VFSTOUFS((aa)->v_mount)->um_update(aa, bb)
158
159 missing
160 { &vop_reallocblks_desc, (vop_t *) ufs_missingop },
161 { &vop_cachedlookup_desc, (vop_t *) ufs_lookup },
162 { &vop_whiteout_desc, (vop_t *) ufs_whiteout },
163#endif
164
165 { &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject },
166 { &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject },
167 { &vop_getvobject_desc, (vop_t *) vop_stdgetvobject },
168 { &vop_getwritemount_desc, (vop_t *) vop_stdgetwritemount },
169 { (struct vnodeop_desc*)NULL, (int(*)(void *))NULL }
170};
171
172static struct vnodeopv_desc coda_vnodeop_opv_desc =
173 { &coda_vnodeop_p, coda_vnodeop_entries };
174
175VNODEOP_SET(coda_vnodeop_opv_desc);
176
177/* A generic panic: we were called with something we didn't define yet */
178int
179coda_vop_error(void *anon) {
180 struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
181
182 myprintf(("coda_vop_error: Vnode operation %s called, but not defined.\n",
183 (*desc)->vdesc_name));
184 /*
185 panic("coda_vop_error");
186 */
187 return EIO;
188}
189
190/* A generic do-nothing. For lease_check, advlock */
191int
192coda_vop_nop(void *anon) {
193 struct vnodeop_desc **desc = (struct vnodeop_desc **)anon;
194
195 if (codadebug) {
196 myprintf(("Vnode operation %s called, but unsupported\n",
197 (*desc)->vdesc_name));
198 }
199 return (0);
200}
201
202int
203coda_vnodeopstats_init(void)
204{
205 register int i;
206
207 for(i=0;i<CODA_VNODEOPS_SIZE;i++) {
208 coda_vnodeopstats[i].opcode = i;
209 coda_vnodeopstats[i].entries = 0;
210 coda_vnodeopstats[i].sat_intrn = 0;
211 coda_vnodeopstats[i].unsat_intrn = 0;
212 coda_vnodeopstats[i].gen_intrn = 0;
213 }
214 return 0;
215}
216
217/*
218 * coda_open calls Venus to return the device, inode pair of the cache
219 * file holding the data. Using iget, coda_open finds the vnode of the
220 * cache file, and then opens it.
221 */
222int
223coda_open(v)
224 void *v;
225{
226 /*
227 * NetBSD can pass the O_EXCL flag in mode, even though the check
228 * has already happened. Venus defensively assumes that if open
229 * is passed the EXCL, it must be a bug. We strip the flag here.
230 */
231/* true args */
232 struct vop_open_args *ap = v;
233 register struct vnode **vpp = &(ap->a_vp);
234 struct cnode *cp = VTOC(*vpp);
235 int flag = ap->a_mode & (~O_EXCL);
236 struct ucred *cred = ap->a_cred;
237 struct thread *td = ap->a_td;
238/* locals */
239 int error;
240 struct vnode *vp;
241 dev_t dev;
242 ino_t inode;
243
244 MARK_ENTRY(CODA_OPEN_STATS);
245
246 /* Check for open of control file. */
247 if (IS_CTL_VP(*vpp)) {
248 /* XXX */
249 /* if (WRITEABLE(flag)) */
250 if (flag & (FWRITE | O_TRUNC | O_CREAT | O_EXCL)) {
251 MARK_INT_FAIL(CODA_OPEN_STATS);
252 return(EACCES);
253 }
254 MARK_INT_SAT(CODA_OPEN_STATS);
255 return(0);
256 }
257
258 error = venus_open(vtomi((*vpp)), &cp->c_fid, flag, cred, td->td_proc, &dev, &inode);
259 if (error)
260 return (error);
261 if (!error) {
262 CODADEBUG( CODA_OPEN,myprintf(("open: dev %#lx inode %lu result %d\n",
263 (u_long)dev2udev(dev), (u_long)inode,
264 error)); )
265 }
266
267 /* Translate the <device, inode> pair for the cache file into
268 an inode pointer. */
269 error = coda_grab_vnode(dev, inode, &vp);
270 if (error)
271 return (error);
272
273 /* We get the vnode back locked. Needs unlocked */
274 VOP_UNLOCK(vp, 0, td);
275 /* Keep a reference until the close comes in. */
276 vref(*vpp);
277
278 /* Save the vnode pointer for the cache file. */
279 if (cp->c_ovp == NULL) {
280 cp->c_ovp = vp;
281 } else {
282 if (cp->c_ovp != vp)
283 panic("coda_open: cp->c_ovp != ITOV(ip)");
284 }
285 cp->c_ocount++;
286
287 /* Flush the attribute cached if writing the file. */
288 if (flag & FWRITE) {
289 cp->c_owrite++;
290 cp->c_flags &= ~C_VATTR;
291 }
292
293 /* Save the <device, inode> pair for the cache file to speed
294 up subsequent page_read's. */
295 cp->c_device = dev;
296 cp->c_inode = inode;
297
298 /* Open the cache file. */
299 error = VOP_OPEN(vp, flag, cred, td, -1);
300 if (error) {
301 printf("coda_open: VOP_OPEN on container failed %d\n", error);
302 return (error);
303 }
304/* grab (above) does this when it calls newvnode unless it's in the cache*/
305 if (vp->v_type == VREG) {
306 error = vfs_object_create(vp, td, cred);
307 if (error != 0) {
308 printf("coda_open: vfs_object_create() returns %d\n", error);
309 vput(vp);
310 }
311 }
312
313 return(error);
314}
315
316/*
317 * Close the cache file used for I/O and notify Venus.
318 */
319int
320coda_close(v)
321 void *v;
322{
323/* true args */
324 struct vop_close_args *ap = v;
325 struct vnode *vp = ap->a_vp;
326 struct cnode *cp = VTOC(vp);
327 int flag = ap->a_fflag;
328 struct ucred *cred = ap->a_cred;
329 struct thread *td = ap->a_td;
330/* locals */
331 int error;
332
333 MARK_ENTRY(CODA_CLOSE_STATS);
334
335 /* Check for close of control file. */
336 if (IS_CTL_VP(vp)) {
337 MARK_INT_SAT(CODA_CLOSE_STATS);
338 return(0);
339 }
340
341 if (IS_UNMOUNTING(cp)) {
342 if (cp->c_ovp) {
343#ifdef CODA_VERBOSE
344 printf("coda_close: destroying container ref %d, ufs vp %p of vp %p/cp %p\n",
345 vrefcnt(vp), cp->c_ovp, vp, cp);
346#endif
347#ifdef hmm
348 vgone(cp->c_ovp);
349#else
350 VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
351 vrele(cp->c_ovp);
352#endif
353 } else {
354#ifdef CODA_VERBOSE
355 printf("coda_close: NO container vp %p/cp %p\n", vp, cp);
356#endif
357 }
358 return ENODEV;
359 } else {
360 VOP_CLOSE(cp->c_ovp, flag, cred, td); /* Do errors matter here? */
361 vrele(cp->c_ovp);
362 }
363
364 if (--cp->c_ocount == 0)
365 cp->c_ovp = NULL;
366
367 if (flag & FWRITE) /* file was opened for write */
368 --cp->c_owrite;
369
370 error = venus_close(vtomi(vp), &cp->c_fid, flag, cred, td->td_proc);
371 vrele(CTOV(cp));
372
373 CODADEBUG(CODA_CLOSE, myprintf(("close: result %d\n",error)); )
374 return(error);
375}
376
377int
378coda_read(v)
379 void *v;
380{
381 struct vop_read_args *ap = v;
382
383 ENTRY;
384 return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_READ,
385 ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td));
386}
387
388int
389coda_write(v)
390 void *v;
391{
392 struct vop_write_args *ap = v;
393
394 ENTRY;
395 return(coda_rdwr(ap->a_vp, ap->a_uio, UIO_WRITE,
396 ap->a_ioflag, ap->a_cred, ap->a_uio->uio_td));
397}
398
399int
400coda_rdwr(vp, uiop, rw, ioflag, cred, td)
401 struct vnode *vp;
402 struct uio *uiop;
403 enum uio_rw rw;
404 int ioflag;
405 struct ucred *cred;
406 struct thread *td;
407{
408/* upcall decl */
409 /* NOTE: container file operation!!! */
410/* locals */
411 struct cnode *cp = VTOC(vp);
412 struct vnode *cfvp = cp->c_ovp;
413 struct proc *p = td->td_proc;
414 struct thread *ltd = td;
415 int igot_internally = 0;
416 int opened_internally = 0;
417 int error = 0;
418 int iscore = 0;
419
420 MARK_ENTRY(CODA_RDWR_STATS);
421
422 CODADEBUG(CODA_RDWR, myprintf(("coda_rdwr(%d, %p, %d, %lld, %d)\n", rw,
423 (void *)uiop->uio_iov->iov_base, uiop->uio_resid,
424 (long long)uiop->uio_offset, uiop->uio_segflg)); )
425
426 /* Check for rdwr of control object. */
427 if (IS_CTL_VP(vp)) {
428 MARK_INT_FAIL(CODA_RDWR_STATS);
429 return(EINVAL);
430 }
431
432 /*
433 * If file is not already open this must be a page
434 * {read,write} request. Iget the cache file's inode
435 * pointer if we still have its <device, inode> pair.
436 * Otherwise, we must do an internal open to derive the
437 * pair.
438 */
439 if (cfvp == NULL) {
440 /*
441 * If we're dumping core, do the internal open. Otherwise
442 * venus won't have the correct size of the core when
443 * it's completely written.
444 */
445 if (p) {
446 PROC_LOCK(p);
447 iscore = (p->p_acflag & ACORE);
448 PROC_UNLOCK(p);
449 }
450 else
451 ltd = curthread;
452
453 if (cp->c_inode != 0 && !iscore) {
454 igot_internally = 1;
455 error = coda_grab_vnode(cp->c_device, cp->c_inode, &cfvp);
456 if (error) {
457 MARK_INT_FAIL(CODA_RDWR_STATS);
458 return(error);
459 }
460 /*
461 * We get the vnode back locked by curthread in both Mach and
462 * NetBSD. Needs unlocked
463 */
464 VOP_UNLOCK(cfvp, 0, ltd);
465 }
466 else {
467 opened_internally = 1;
468 MARK_INT_GEN(CODA_OPEN_STATS);
469 error = VOP_OPEN(vp, (rw == UIO_READ ? FREAD : FWRITE),
470 cred, td, -1);
471printf("coda_rdwr: Internally Opening %p\n", vp);
472 if (error) {
473 printf("coda_rdwr: VOP_OPEN on container failed %d\n", error);
474 return (error);
475 }
476 if (vp->v_type == VREG) {
477 error = vfs_object_create(vp, td, cred);
478 if (error != 0) {
479 printf("coda_rdwr: vfs_object_create() returns %d\n", error);
480 vput(vp);
481 }
482 }
483 if (error) {
484 MARK_INT_FAIL(CODA_RDWR_STATS);
485 return(error);
486 }
487 cfvp = cp->c_ovp;
488 }
489 }
490
491 /* Have UFS handle the call. */
492 CODADEBUG(CODA_RDWR, myprintf(("indirect rdwr: fid = %s, refcnt = %d\n",
493 coda_f2s(&cp->c_fid), CTOV(cp)->v_usecount)); )
494 if (rw == UIO_READ) {
495 error = VOP_READ(cfvp, uiop, ioflag, cred);
496 } else {
497 error = VOP_WRITE(cfvp, uiop, ioflag, cred);
498 /* ufs_write updates the vnode_pager_setsize for the vnode/object */
499
500 { struct vattr attr;
501
502 if (VOP_GETATTR(cfvp, &attr, cred, td) == 0) {
503 vnode_pager_setsize(vp, attr.va_size);
504 }
505 }
506 }
507
508 if (error)
509 MARK_INT_FAIL(CODA_RDWR_STATS);
510 else
511 MARK_INT_SAT(CODA_RDWR_STATS);
512
513 /* Do an internal close if necessary. */
514 if (opened_internally) {
515 MARK_INT_GEN(CODA_CLOSE_STATS);
516 (void)VOP_CLOSE(vp, (rw == UIO_READ ? FREAD : FWRITE), cred, td);
517 }
518
519 /* Invalidate cached attributes if writing. */
520 if (rw == UIO_WRITE)
521 cp->c_flags &= ~C_VATTR;
522 return(error);
523}
524
525
526
527int
528coda_ioctl(v)
529 void *v;
530{
531/* true args */
532 struct vop_ioctl_args *ap = v;
533 struct vnode *vp = ap->a_vp;
534 int com = ap->a_command;
535 caddr_t data = ap->a_data;
536 int flag = ap->a_fflag;
537 struct ucred *cred = ap->a_cred;
538 struct thread *td = ap->a_td;
539/* locals */
540 int error;
541 struct vnode *tvp;
542 struct nameidata ndp;
543 struct PioctlData *iap = (struct PioctlData *)data;
544
545 MARK_ENTRY(CODA_IOCTL_STATS);
546
547 CODADEBUG(CODA_IOCTL, myprintf(("in coda_ioctl on %s\n", iap->path));)
548
549 /* Don't check for operation on a dying object, for ctlvp it
550 shouldn't matter */
551
552 /* Must be control object to succeed. */
553 if (!IS_CTL_VP(vp)) {
554 MARK_INT_FAIL(CODA_IOCTL_STATS);
555 CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: vp != ctlvp"));)
556 return (EOPNOTSUPP);
557 }
558 /* Look up the pathname. */
559
560 /* Should we use the name cache here? It would get it from
561 lookupname sooner or later anyway, right? */
562
563 NDINIT(&ndp, LOOKUP, (iap->follow ? FOLLOW : NOFOLLOW), UIO_USERSPACE, iap->path, td);
564 error = namei(&ndp);
565 tvp = ndp.ni_vp;
566
567 if (error) {
568 MARK_INT_FAIL(CODA_IOCTL_STATS);
569 CODADEBUG(CODA_IOCTL, myprintf(("coda_ioctl error: lookup returns %d\n",
570 error));)
571 return(error);
572 }
573
574 /*
575 * Make sure this is a coda style cnode, but it may be a
576 * different vfsp
577 */
578 if (tvp->v_op != coda_vnodeop_p) {
579 vrele(tvp);
580 NDFREE(&ndp, NDF_ONLY_PNBUF);
581 MARK_INT_FAIL(CODA_IOCTL_STATS);
582 CODADEBUG(CODA_IOCTL,
583 myprintf(("coda_ioctl error: %s not a coda object\n",
584 iap->path));)
585 return(EINVAL);
586 }
587
588 if (iap->vi.in_size > VC_MAXDATASIZE) {
589 NDFREE(&ndp, 0);
590 return(EINVAL);
591 }
592 error = venus_ioctl(vtomi(tvp), &((VTOC(tvp))->c_fid), com, flag, data, cred, td->td_proc);
593
594 if (error)
595 MARK_INT_FAIL(CODA_IOCTL_STATS);
596 else
597 CODADEBUG(CODA_IOCTL, myprintf(("Ioctl returns %d \n", error)); )
598
599 vrele(tvp);
600 NDFREE(&ndp, NDF_ONLY_PNBUF);
601 return(error);
602}
603
604/*
605 * To reduce the cost of a user-level venus;we cache attributes in
606 * the kernel. Each cnode has storage allocated for an attribute. If
607 * c_vattr is valid, return a reference to it. Otherwise, get the
608 * attributes from venus and store them in the cnode. There is some
609 * question if this method is a security leak. But I think that in
610 * order to make this call, the user must have done a lookup and
611 * opened the file, and therefore should already have access.
612 */
613int
614coda_getattr(v)
615 void *v;
616{
617/* true args */
618 struct vop_getattr_args *ap = v;
619 struct vnode *vp = ap->a_vp;
620 struct cnode *cp = VTOC(vp);
621 struct vattr *vap = ap->a_vap;
622 struct ucred *cred = ap->a_cred;
623 struct thread *td = ap->a_td;
624/* locals */
625 int error;
626
627 MARK_ENTRY(CODA_GETATTR_STATS);
628
629 if (IS_UNMOUNTING(cp))
630 return ENODEV;
631
632 /* Check for getattr of control object. */
633 if (IS_CTL_VP(vp)) {
634 MARK_INT_FAIL(CODA_GETATTR_STATS);
635 return(ENOENT);
636 }
637
638 /* Check to see if the attributes have already been cached */
639 if (VALID_VATTR(cp)) {
640 CODADEBUG(CODA_GETATTR, { myprintf(("attr cache hit: %s\n",
641 coda_f2s(&cp->c_fid)));});
642 CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
643 print_vattr(&cp->c_vattr); );
644
645 *vap = cp->c_vattr;
646 MARK_INT_SAT(CODA_GETATTR_STATS);
647 return(0);
648 }
649
650 error = venus_getattr(vtomi(vp), &cp->c_fid, cred, td->td_proc, vap);
651
652 if (!error) {
653 CODADEBUG(CODA_GETATTR, myprintf(("getattr miss %s: result %d\n",
654 coda_f2s(&cp->c_fid), error)); )
655
656 CODADEBUG(CODA_GETATTR, if (!(codadebug & ~CODA_GETATTR))
657 print_vattr(vap); );
658
659 { int size = vap->va_size;
660 struct vnode *convp = cp->c_ovp;
661 if (convp != (struct vnode *)0) {
662 vnode_pager_setsize(convp, size);
663 }
664 }
665 /* If not open for write, store attributes in cnode */
666 if ((cp->c_owrite == 0) && (coda_attr_cache)) {
667 cp->c_vattr = *vap;
668 cp->c_flags |= C_VATTR;
669 }
670
671 }
672 return(error);
673}
674
675int
676coda_setattr(v)
677 void *v;
678{
679/* true args */
680 struct vop_setattr_args *ap = v;
681 register struct vnode *vp = ap->a_vp;
682 struct cnode *cp = VTOC(vp);
683 register struct vattr *vap = ap->a_vap;
684 struct ucred *cred = ap->a_cred;
685 struct thread *td = ap->a_td;
686/* locals */
687 int error;
688
689 MARK_ENTRY(CODA_SETATTR_STATS);
690
691 /* Check for setattr of control object. */
692 if (IS_CTL_VP(vp)) {
693 MARK_INT_FAIL(CODA_SETATTR_STATS);
694 return(ENOENT);
695 }
696
697 if (codadebug & CODADBGMSK(CODA_SETATTR)) {
698 print_vattr(vap);
699 }
700 error = venus_setattr(vtomi(vp), &cp->c_fid, vap, cred, td->td_proc);
701
702 if (!error)
703 cp->c_flags &= ~C_VATTR;
704
705 { int size = vap->va_size;
706 struct vnode *convp = cp->c_ovp;
707 if (size != VNOVAL && convp != (struct vnode *)0) {
708 vnode_pager_setsize(convp, size);
709 }
710 }
711 CODADEBUG(CODA_SETATTR, myprintf(("setattr %d\n", error)); )
712 return(error);
713}
714
715int
716coda_access(v)
717 void *v;
718{
719/* true args */
720 struct vop_access_args *ap = v;
721 struct vnode *vp = ap->a_vp;
722 struct cnode *cp = VTOC(vp);
723 int mode = ap->a_mode;
724 struct ucred *cred = ap->a_cred;
725 struct thread *td = ap->a_td;
726/* locals */
727 int error;
728
729 MARK_ENTRY(CODA_ACCESS_STATS);
730
731 /* Check for access of control object. Only read access is
732 allowed on it. */
733 if (IS_CTL_VP(vp)) {
734 /* bogus hack - all will be marked as successes */
735 MARK_INT_SAT(CODA_ACCESS_STATS);
736 return(((mode & VREAD) && !(mode & (VWRITE | VEXEC)))
737 ? 0 : EACCES);
738 }
739
740 /*
741 * if the file is a directory, and we are checking exec (eg lookup)
742 * access, and the file is in the namecache, then the user must have
743 * lookup access to it.
744 */
745 if (coda_access_cache) {
746 if ((vp->v_type == VDIR) && (mode & VEXEC)) {
747 if (coda_nc_lookup(cp, ".", 1, cred)) {
748 MARK_INT_SAT(CODA_ACCESS_STATS);
749 return(0); /* it was in the cache */
750 }
751 }
752 }
753
754 error = venus_access(vtomi(vp), &cp->c_fid, mode, cred, td->td_proc);
755
756 return(error);
757}
758
759int
760coda_readlink(v)
761 void *v;
762{
763/* true args */
764 struct vop_readlink_args *ap = v;
765 struct vnode *vp = ap->a_vp;
766 struct cnode *cp = VTOC(vp);
767 struct uio *uiop = ap->a_uio;
768 struct ucred *cred = ap->a_cred;
769 struct thread *td = ap->a_uio->uio_td;
770/* locals */
771 int error;
772 char *str;
773 int len;
774
775 MARK_ENTRY(CODA_READLINK_STATS);
776
777 /* Check for readlink of control object. */
778 if (IS_CTL_VP(vp)) {
779 MARK_INT_FAIL(CODA_READLINK_STATS);
780 return(ENOENT);
781 }
782
783 if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) { /* symlink was cached */
784 uiop->uio_rw = UIO_READ;
785 error = uiomove(cp->c_symlink, (int)cp->c_symlen, uiop);
786 if (error)
787 MARK_INT_FAIL(CODA_READLINK_STATS);
788 else
789 MARK_INT_SAT(CODA_READLINK_STATS);
790 return(error);
791 }
792
793 error = venus_readlink(vtomi(vp), &cp->c_fid, cred,
794 td != NULL ? td->td_proc : NULL, &str, &len);
795
796 if (!error) {
797 uiop->uio_rw = UIO_READ;
798 error = uiomove(str, len, uiop);
799
800 if (coda_symlink_cache) {
801 cp->c_symlink = str;
802 cp->c_symlen = len;
803 cp->c_flags |= C_SYMLINK;
804 } else
805 CODA_FREE(str, len);
806 }
807
808 CODADEBUG(CODA_READLINK, myprintf(("in readlink result %d\n",error));)
809 return(error);
810}
811
812int
813coda_fsync(v)
814 void *v;
815{
816/* true args */
817 struct vop_fsync_args *ap = v;
818 struct vnode *vp = ap->a_vp;
819 struct cnode *cp = VTOC(vp);
820 struct ucred *cred = ap->a_cred;
821 struct thread *td = ap->a_td;
822/* locals */
823 struct vnode *convp = cp->c_ovp;
824 int error;
825
826 MARK_ENTRY(CODA_FSYNC_STATS);
827
828 /* Check for fsync on an unmounting object */
829 /* The NetBSD kernel, in it's infinite wisdom, can try to fsync
830 * after an unmount has been initiated. This is a Bad Thing,
831 * which we have to avoid. Not a legitimate failure for stats.
832 */
833 if (IS_UNMOUNTING(cp)) {
834 return(ENODEV);
835 }
836
837 /* Check for fsync of control object. */
838 if (IS_CTL_VP(vp)) {
839 MARK_INT_SAT(CODA_FSYNC_STATS);
840 return(0);
841 }
842
843 if (convp)
844 VOP_FSYNC(convp, cred, MNT_WAIT, td);
845
846 /*
847 * We see fsyncs with usecount == 1 then usecount == 0.
848 * For now we ignore them.
849 */
850 /*
851 VI_LOCK(vp);
852 if (!vp->v_usecount) {
853 printf("coda_fsync on vnode %p with %d usecount. c_flags = %x (%x)\n",
854 vp, vp->v_usecount, cp->c_flags, cp->c_flags&C_PURGING);
855 }
856 VI_UNLOCK(vp);
857 */
858
859 /*
860 * We can expect fsync on any vnode at all if venus is pruging it.
861 * Venus can't very well answer the fsync request, now can it?
862 * Hopefully, it won't have to, because hopefully, venus preserves
863 * the (possibly untrue) invariant that it never purges an open
864 * vnode. Hopefully.
865 */
866 if (cp->c_flags & C_PURGING) {
867 return(0);
868 }
869
870 /* needs research */
871 return 0;
872 error = venus_fsync(vtomi(vp), &cp->c_fid, cred, td->td_proc);
873
874 CODADEBUG(CODA_FSYNC, myprintf(("in fsync result %d\n",error)); );
875 return(error);
876}
877
878int
879coda_inactive(v)
880 void *v;
881{
882 /* XXX - at the moment, inactive doesn't look at cred, and doesn't
883 have a proc pointer. Oops. */
884/* true args */
885 struct vop_inactive_args *ap = v;
886 struct vnode *vp = ap->a_vp;
887 struct cnode *cp = VTOC(vp);
888 struct ucred *cred __attribute__((unused)) = NULL;
889 struct thread *td __attribute__((unused)) = curthread;
890/* upcall decl */
891/* locals */
892
893 /* We don't need to send inactive to venus - DCS */
894 MARK_ENTRY(CODA_INACTIVE_STATS);
895
896 if (IS_CTL_VP(vp)) {
897 MARK_INT_SAT(CODA_INACTIVE_STATS);
898 return 0;
899 }
900
901 CODADEBUG(CODA_INACTIVE, myprintf(("in inactive, %s, vfsp %p\n",
902 coda_f2s(&cp->c_fid), vp->v_mount));)
903
904 /* If an array has been allocated to hold the symlink, deallocate it */
905 if ((coda_symlink_cache) && (VALID_SYMLINK(cp))) {
906 if (cp->c_symlink == NULL)
907 panic("coda_inactive: null symlink pointer in cnode");
908
909 CODA_FREE(cp->c_symlink, cp->c_symlen);
910 cp->c_flags &= ~C_SYMLINK;
911 cp->c_symlen = 0;
912 }
913
914 /* Remove it from the table so it can't be found. */
915 coda_unsave(cp);
916 if ((struct coda_mntinfo *)(vp->v_mount->mnt_data) == NULL) {
917 myprintf(("Help! vfsp->vfs_data was NULL, but vnode %p wasn't dying\n", vp));
918 panic("badness in coda_inactive\n");
919 }
920
921 if (IS_UNMOUNTING(cp)) {
922#ifdef DEBUG
923 printf("coda_inactive: IS_UNMOUNTING use %d: vp %p, cp %p\n", vrefcnt(vp), vp, cp);
924 if (cp->c_ovp != NULL)
925 printf("coda_inactive: cp->ovp != NULL use %d: vp %p, cp %p\n",
926 vrefcnt(vp), vp, cp);
927#endif
928 lockmgr(&cp->c_lock, LK_RELEASE, &vp->v_interlock, td);
929 } else {
930#ifdef OLD_DIAGNOSTIC
931 if (vrefcnt(CTOV(cp))) {
932 panic("coda_inactive: nonzero reference count");
933 }
934 if (cp->c_ovp != NULL) {
935 panic("coda_inactive: cp->ovp != NULL");
936 }
937#endif
938 VOP_UNLOCK(vp, 0, td);
939 vgone(vp);
940 }
941
942 MARK_INT_SAT(CODA_INACTIVE_STATS);
943 return(0);
944}
945
946/*
947 * Remote filesystem operations having to do with directory manipulation.
948 */
949
950/*
951 * It appears that in NetBSD, lookup is supposed to return the vnode locked
952 */
953int
954coda_lookup(v)
955 void *v;
956{
957/* true args */
958 struct vop_lookup_args *ap = v;
959 struct vnode *dvp = ap->a_dvp;
960 struct cnode *dcp = VTOC(dvp);
961 struct vnode **vpp = ap->a_vpp;
962 /*
963 * It looks as though ap->a_cnp->ni_cnd->cn_nameptr holds the rest
964 * of the string to xlate, and that we must try to get at least
965 * ap->a_cnp->ni_cnd->cn_namelen of those characters to macth. I
966 * could be wrong.
967 */
968 struct componentname *cnp = ap->a_cnp;
969 struct ucred *cred = cnp->cn_cred;
970 struct thread *td = cnp->cn_thread;
971/* locals */
972 struct cnode *cp;
973 const char *nm = cnp->cn_nameptr;
974 int len = cnp->cn_namelen;
975 CodaFid VFid;
976 int vtype;
977 int error = 0;
978
979 MARK_ENTRY(CODA_LOOKUP_STATS);
980
981 CODADEBUG(CODA_LOOKUP, myprintf(("lookup: %s in %s\n",
982 nm, coda_f2s(&dcp->c_fid))););
983
984 /* Check for lookup of control object. */
985 if (IS_CTL_NAME(dvp, nm, len)) {
986 *vpp = coda_ctlvp;
987 vref(*vpp);
988 MARK_INT_SAT(CODA_LOOKUP_STATS);
989 goto exit;
990 }
991
992 if (len+1 > CODA_MAXNAMLEN) {
993 MARK_INT_FAIL(CODA_LOOKUP_STATS);
994
995 CODADEBUG(CODA_LOOKUP, myprintf(("name too long: lookup, %s (%s)\n",
996 coda_f2s(&dcp->c_fid), nm)););
997 *vpp = (struct vnode *)0;
998 error = EINVAL;
999 goto exit;
1000 }
1001 /* First try to look the file up in the cfs name cache */
1002 /* lock the parent vnode? */
1003 cp = coda_nc_lookup(dcp, nm, len, cred);
1004 if (cp) {
1005 *vpp = CTOV(cp);
1006 vref(*vpp);
1007 CODADEBUG(CODA_LOOKUP,
1008 myprintf(("lookup result %d vpp %p\n",error,*vpp));)
1009 } else {
1010
1011 /* The name wasn't cached, so we need to contact Venus */
1012 error = venus_lookup(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc, &VFid, &vtype);
1013
1014 if (error) {
1015 MARK_INT_FAIL(CODA_LOOKUP_STATS);
1016
1017 CODADEBUG(CODA_LOOKUP, myprintf(("lookup error on %s (%s)%d\n",
1018 coda_f2s(&dcp->c_fid), nm, error));)
1019 *vpp = (struct vnode *)0;
1020 } else {
1021 MARK_INT_SAT(CODA_LOOKUP_STATS);
1022 CODADEBUG(CODA_LOOKUP,
1023 myprintf(("lookup: %s type %o result %d\n",
1024 coda_f2s(&VFid), vtype, error)); )
1025 cp = make_coda_node(&VFid, dvp->v_mount, vtype);
1026 *vpp = CTOV(cp);
1027
1028 /* enter the new vnode in the Name Cache only if the top bit isn't set */
1029 /* And don't enter a new vnode for an invalid one! */
1030 if (!(vtype & CODA_NOCACHE))
1031 coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
1032 }
1033 }
1034
1035 exit:
1036 /*
1037 * If we are creating, and this was the last name to be looked up,
1038 * and the error was ENOENT, then there really shouldn't be an
1039 * error and we can make the leaf NULL and return success. Since
1040 * this is supposed to work under Mach as well as NetBSD, we're
1041 * leaving this fn wrapped. We also must tell lookup/namei that
1042 * we need to save the last component of the name. (Create will
1043 * have to free the name buffer later...lucky us...)
1044 */
1045 if (((cnp->cn_nameiop == CREATE) || (cnp->cn_nameiop == RENAME))
1046 && (cnp->cn_flags & ISLASTCN)
1047 && (error == ENOENT))
1048 {
1049 error = EJUSTRETURN;
1050 cnp->cn_flags |= SAVENAME;
1051 *ap->a_vpp = NULL;
1052 }
1053
1054 /*
1055 * If we are removing, and we are at the last element, and we
1056 * found it, then we need to keep the name around so that the
1057 * removal will go ahead as planned. Unfortunately, this will
1058 * probably also lock the to-be-removed vnode, which may or may
1059 * not be a good idea. I'll have to look at the bits of
1060 * coda_remove to make sure. We'll only save the name if we did in
1061 * fact find the name, otherwise coda_remove won't have a chance
1062 * to free the pathname.
1063 */
1064 if ((cnp->cn_nameiop == DELETE)
1065 && (cnp->cn_flags & ISLASTCN)
1066 && !error)
1067 {
1068 cnp->cn_flags |= SAVENAME;
1069 }
1070
1071 /*
1072 * If the lookup went well, we need to (potentially?) unlock the
1073 * parent, and lock the child. We are only responsible for
1074 * checking to see if the parent is supposed to be unlocked before
1075 * we return. We must always lock the child (provided there is
1076 * one, and (the parent isn't locked or it isn't the same as the
1077 * parent.) Simple, huh? We can never leave the parent locked unless
1078 * we are ISLASTCN
1079 */
1080 if (!error || (error == EJUSTRETURN)) {
1081 if (!(cnp->cn_flags & LOCKPARENT) || !(cnp->cn_flags & ISLASTCN)) {
1082 if ((error = VOP_UNLOCK(dvp, 0, td))) {
1083 return error;
1084 }
1085 /*
1086 * The parent is unlocked. As long as there is a child,
1087 * lock it without bothering to check anything else.
1088 */
1089 if (*ap->a_vpp) {
1090 if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
1091 printf("coda_lookup: ");
1092 panic("unlocked parent but couldn't lock child");
1093 }
1094 }
1095 } else {
1096 /* The parent is locked, and may be the same as the child */
1097 if (*ap->a_vpp && (*ap->a_vpp != dvp)) {
1098 /* Different, go ahead and lock it. */
1099 if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
1100 printf("coda_lookup: ");
1101 panic("unlocked parent but couldn't lock child");
1102 }
1103 }
1104 }
1105 } else {
1106 /* If the lookup failed, we need to ensure that the leaf is NULL */
1107 /* Don't change any locking? */
1108 *ap->a_vpp = NULL;
1109 }
1110 return(error);
1111}
1112
1113/*ARGSUSED*/
1114int
1115coda_create(v)
1116 void *v;
1117{
1118/* true args */
1119 struct vop_create_args *ap = v;
1120 struct vnode *dvp = ap->a_dvp;
1121 struct cnode *dcp = VTOC(dvp);
1122 struct vattr *va = ap->a_vap;
1123 int exclusive = 1;
1124 int mode = ap->a_vap->va_mode;
1125 struct vnode **vpp = ap->a_vpp;
1126 struct componentname *cnp = ap->a_cnp;
1127 struct ucred *cred = cnp->cn_cred;
1128 struct thread *td = cnp->cn_thread;
1129/* locals */
1130 int error;
1131 struct cnode *cp;
1132 const char *nm = cnp->cn_nameptr;
1133 int len = cnp->cn_namelen;
1134 CodaFid VFid;
1135 struct vattr attr;
1136
1137 MARK_ENTRY(CODA_CREATE_STATS);
1138
1139 /* All creates are exclusive XXX */
1140 /* I'm assuming the 'mode' argument is the file mode bits XXX */
1141
1142 /* Check for create of control object. */
1143 if (IS_CTL_NAME(dvp, nm, len)) {
1144 *vpp = (struct vnode *)0;
1145 MARK_INT_FAIL(CODA_CREATE_STATS);
1146 return(EACCES);
1147 }
1148
1149 error = venus_create(vtomi(dvp), &dcp->c_fid, nm, len, exclusive, mode, va, cred, td->td_proc, &VFid, &attr);
1150
1151 if (!error) {
1152
1153 /* If this is an exclusive create, panic if the file already exists. */
1154 /* Venus should have detected the file and reported EEXIST. */
1155
1156 if ((exclusive == 1) &&
1157 (coda_find(&VFid) != NULL))
1158 panic("cnode existed for newly created file!");
1159
1160 cp = make_coda_node(&VFid, dvp->v_mount, attr.va_type);
1161 *vpp = CTOV(cp);
1162
1163 /* Update va to reflect the new attributes. */
1164 (*va) = attr;
1165
1166 /* Update the attribute cache and mark it as valid */
1167 if (coda_attr_cache) {
1168 VTOC(*vpp)->c_vattr = attr;
1169 VTOC(*vpp)->c_flags |= C_VATTR;
1170 }
1171
1172 /* Invalidate the parent's attr cache, the modification time has changed */
1173 VTOC(dvp)->c_flags &= ~C_VATTR;
1174
1175 /* enter the new vnode in the Name Cache */
1176 coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
1177
1178 CODADEBUG(CODA_CREATE,
1179 myprintf(("create: %s, result %d\n",
1180 coda_f2s(&VFid), error)); )
1181 } else {
1182 *vpp = (struct vnode *)0;
1183 CODADEBUG(CODA_CREATE, myprintf(("create error %d\n", error));)
1184 }
1185
1186 if (!error) {
1187 if (cnp->cn_flags & LOCKLEAF) {
1188 if ((error = VOP_LOCK(*ap->a_vpp, LK_EXCLUSIVE, td))) {
1189 printf("coda_create: ");
1190 panic("unlocked parent but couldn't lock child");
1191 }
1192 }
1193#ifdef OLD_DIAGNOSTIC
1194 else {
1195 printf("coda_create: LOCKLEAF not set!\n");
1196 }
1197#endif
1198 }
1199 return(error);
1200}
1201
1202int
1203coda_remove(v)
1204 void *v;
1205{
1206/* true args */
1207 struct vop_remove_args *ap = v;
1208 struct vnode *dvp = ap->a_dvp;
1209 struct cnode *cp = VTOC(dvp);
1210 struct componentname *cnp = ap->a_cnp;
1211 struct ucred *cred = cnp->cn_cred;
1212 struct thread *td = cnp->cn_thread;
1213/* locals */
1214 int error;
1215 const char *nm = cnp->cn_nameptr;
1216 int len = cnp->cn_namelen;
1217 struct cnode *tp;
1218
1219 MARK_ENTRY(CODA_REMOVE_STATS);
1220
1221 CODADEBUG(CODA_REMOVE, myprintf(("remove: %s in %s\n",
1222 nm, coda_f2s(&cp->c_fid))););
1223 /* Remove the file's entry from the CODA Name Cache */
1224 /* We're being conservative here, it might be that this person
1225 * doesn't really have sufficient access to delete the file
1226 * but we feel zapping the entry won't really hurt anyone -- dcs
1227 */
1228 /* I'm gonna go out on a limb here. If a file and a hardlink to it
1229 * exist, and one is removed, the link count on the other will be
1230 * off by 1. We could either invalidate the attrs if cached, or
1231 * fix them. I'll try to fix them. DCS 11/8/94
1232 */
1233 tp = coda_nc_lookup(VTOC(dvp), nm, len, cred);
1234 if (tp) {
1235 if (VALID_VATTR(tp)) { /* If attrs are cached */
1236 if (tp->c_vattr.va_nlink > 1) { /* If it's a hard link */
1237 tp->c_vattr.va_nlink--;
1238 }
1239 }
1240
1241 coda_nc_zapfile(VTOC(dvp), nm, len);
1242 /* No need to flush it if it doesn't exist! */
1243 }
1244 /* Invalidate the parent's attr cache, the modification time has changed */
1245 VTOC(dvp)->c_flags &= ~C_VATTR;
1246
1247 /* Check for remove of control object. */
1248 if (IS_CTL_NAME(dvp, nm, len)) {
1249 MARK_INT_FAIL(CODA_REMOVE_STATS);
1250 return(ENOENT);
1251 }
1252
1253 error = venus_remove(vtomi(dvp), &cp->c_fid, nm, len, cred, td->td_proc);
1254
1255 CODADEBUG(CODA_REMOVE, myprintf(("in remove result %d\n",error)); )
1256
1257 return(error);
1258}
1259
1260int
1261coda_link(v)
1262 void *v;
1263{
1264/* true args */
1265 struct vop_link_args *ap = v;
1266 struct vnode *vp = ap->a_vp;
1267 struct cnode *cp = VTOC(vp);
1268 struct vnode *tdvp = ap->a_tdvp;
1269 struct cnode *tdcp = VTOC(tdvp);
1270 struct componentname *cnp = ap->a_cnp;
1271 struct ucred *cred = cnp->cn_cred;
1272 struct thread *td = cnp->cn_thread;
1273/* locals */
1274 int error;
1275 const char *nm = cnp->cn_nameptr;
1276 int len = cnp->cn_namelen;
1277
1278 MARK_ENTRY(CODA_LINK_STATS);
1279
1280 if (codadebug & CODADBGMSK(CODA_LINK)) {
1281 myprintf(("nb_link: vp fid: %s\n",
1282 coda_f2s(&cp->c_fid)));
1283 myprintf(("nb_link: tdvp fid: %s)\n",
1284 coda_f2s(&tdcp->c_fid)));
1285 }
1286 if (codadebug & CODADBGMSK(CODA_LINK)) {
1287 myprintf(("link: vp fid: %s\n",
1288 coda_f2s(&cp->c_fid)));
1289 myprintf(("link: tdvp fid: %s\n",
1290 coda_f2s(&tdcp->c_fid)));
1291 }
1292
1293 /* Check for link to/from control object. */
1294 if (IS_CTL_NAME(tdvp, nm, len) || IS_CTL_VP(vp)) {
1295 MARK_INT_FAIL(CODA_LINK_STATS);
1296 return(EACCES);
1297 }
1298
1299 error = venus_link(vtomi(vp), &cp->c_fid, &tdcp->c_fid, nm, len, cred, td->td_proc);
1300
1301 /* Invalidate the parent's attr cache, the modification time has changed */
1302 VTOC(tdvp)->c_flags &= ~C_VATTR;
1303 VTOC(vp)->c_flags &= ~C_VATTR;
1304
1305 CODADEBUG(CODA_LINK, myprintf(("in link result %d\n",error)); )
1306
1307 return(error);
1308}
1309
1310int
1311coda_rename(v)
1312 void *v;
1313{
1314/* true args */
1315 struct vop_rename_args *ap = v;
1316 struct vnode *odvp = ap->a_fdvp;
1317 struct cnode *odcp = VTOC(odvp);
1318 struct componentname *fcnp = ap->a_fcnp;
1319 struct vnode *ndvp = ap->a_tdvp;
1320 struct cnode *ndcp = VTOC(ndvp);
1321 struct componentname *tcnp = ap->a_tcnp;
1322 struct ucred *cred = fcnp->cn_cred;
1323 struct thread *td = fcnp->cn_thread;
1324/* true args */
1325 int error;
1326 const char *fnm = fcnp->cn_nameptr;
1327 int flen = fcnp->cn_namelen;
1328 const char *tnm = tcnp->cn_nameptr;
1329 int tlen = tcnp->cn_namelen;
1330
1331 MARK_ENTRY(CODA_RENAME_STATS);
1332
1333 /* Hmmm. The vnodes are already looked up. Perhaps they are locked?
1334 This could be Bad. XXX */
1335#ifdef OLD_DIAGNOSTIC
1336 if ((fcnp->cn_cred != tcnp->cn_cred)
1337 || (fcnp->cn_thread != tcnp->cn_thread))
1338 {
1339 panic("coda_rename: component names don't agree");
1340 }
1341#endif
1342
1343 /* Check for rename involving control object. */
1344 if (IS_CTL_NAME(odvp, fnm, flen) || IS_CTL_NAME(ndvp, tnm, tlen)) {
1345 MARK_INT_FAIL(CODA_RENAME_STATS);
1346 return(EACCES);
1347 }
1348
1349 /* Problem with moving directories -- need to flush entry for .. */
1350 if (odvp != ndvp) {
1351 struct cnode *ovcp = coda_nc_lookup(VTOC(odvp), fnm, flen, cred);
1352 if (ovcp) {
1353 struct vnode *ovp = CTOV(ovcp);
1354 if ((ovp) &&
1355 (ovp->v_type == VDIR)) /* If it's a directory */
1356 coda_nc_zapfile(VTOC(ovp),"..", 2);
1357 }
1358 }
1359
1360 /* Remove the entries for both source and target files */
1361 coda_nc_zapfile(VTOC(odvp), fnm, flen);
1362 coda_nc_zapfile(VTOC(ndvp), tnm, tlen);
1363
1364 /* Invalidate the parent's attr cache, the modification time has changed */
1365 VTOC(odvp)->c_flags &= ~C_VATTR;
1366 VTOC(ndvp)->c_flags &= ~C_VATTR;
1367
1368 if (flen+1 > CODA_MAXNAMLEN) {
1369 MARK_INT_FAIL(CODA_RENAME_STATS);
1370 error = EINVAL;
1371 goto exit;
1372 }
1373
1374 if (tlen+1 > CODA_MAXNAMLEN) {
1375 MARK_INT_FAIL(CODA_RENAME_STATS);
1376 error = EINVAL;
1377 goto exit;
1378 }
1379
1380 error = venus_rename(vtomi(odvp), &odcp->c_fid, &ndcp->c_fid, fnm, flen, tnm, tlen, cred, td->td_proc);
1381
1382 exit:
1383 CODADEBUG(CODA_RENAME, myprintf(("in rename result %d\n",error));)
1384 /* XXX - do we need to call cache pureg on the moved vnode? */
1385 cache_purge(ap->a_fvp);
1386
1387 /* It seems to be incumbent on us to drop locks on all four vnodes */
1388 /* From-vnodes are not locked, only ref'd. To-vnodes are locked. */
1389
1390 vrele(ap->a_fvp);
1391 vrele(odvp);
1392
1393 if (ap->a_tvp) {
1394 if (ap->a_tvp == ndvp) {
1395 vrele(ap->a_tvp);
1396 } else {
1397 vput(ap->a_tvp);
1398 }
1399 }
1400
1401 vput(ndvp);
1402 return(error);
1403}
1404
1405int
1406coda_mkdir(v)
1407 void *v;
1408{
1409/* true args */
1410 struct vop_mkdir_args *ap = v;
1411 struct vnode *dvp = ap->a_dvp;
1412 struct cnode *dcp = VTOC(dvp);
1413 struct componentname *cnp = ap->a_cnp;
1414 register struct vattr *va = ap->a_vap;
1415 struct vnode **vpp = ap->a_vpp;
1416 struct ucred *cred = cnp->cn_cred;
1417 struct thread *td = cnp->cn_thread;
1418/* locals */
1419 int error;
1420 const char *nm = cnp->cn_nameptr;
1421 int len = cnp->cn_namelen;
1422 struct cnode *cp;
1423 CodaFid VFid;
1424 struct vattr ova;
1425
1426 MARK_ENTRY(CODA_MKDIR_STATS);
1427
1428 /* Check for mkdir of target object. */
1429 if (IS_CTL_NAME(dvp, nm, len)) {
1430 *vpp = (struct vnode *)0;
1431 MARK_INT_FAIL(CODA_MKDIR_STATS);
1432 return(EACCES);
1433 }
1434
1435 if (len+1 > CODA_MAXNAMLEN) {
1436 *vpp = (struct vnode *)0;
1437 MARK_INT_FAIL(CODA_MKDIR_STATS);
1438 return(EACCES);
1439 }
1440
1441 error = venus_mkdir(vtomi(dvp), &dcp->c_fid, nm, len, va, cred, td->td_proc, &VFid, &ova);
1442
1443 if (!error) {
1444 if (coda_find(&VFid) != NULL)
1445 panic("cnode existed for newly created directory!");
1446
1447
1448 cp = make_coda_node(&VFid, dvp->v_mount, va->va_type);
1449 *vpp = CTOV(cp);
1450
1451 /* enter the new vnode in the Name Cache */
1452 coda_nc_enter(VTOC(dvp), nm, len, cred, VTOC(*vpp));
1453
1454 /* as a side effect, enter "." and ".." for the directory */
1455 coda_nc_enter(VTOC(*vpp), ".", 1, cred, VTOC(*vpp));
1456 coda_nc_enter(VTOC(*vpp), "..", 2, cred, VTOC(dvp));
1457
1458 if (coda_attr_cache) {
1459 VTOC(*vpp)->c_vattr = ova; /* update the attr cache */
1460 VTOC(*vpp)->c_flags |= C_VATTR; /* Valid attributes in cnode */
1461 }
1462
1463 /* Invalidate the parent's attr cache, the modification time has changed */
1464 VTOC(dvp)->c_flags &= ~C_VATTR;
1465
1466 CODADEBUG( CODA_MKDIR, myprintf(("mkdir: %s result %d\n",
1467 coda_f2s(&VFid), error)); )
1468 } else {
1469 *vpp = (struct vnode *)0;
1470 CODADEBUG(CODA_MKDIR, myprintf(("mkdir error %d\n",error));)
1471 }
1472
1473 return(error);
1474}
1475
1476int
1477coda_rmdir(v)
1478 void *v;
1479{
1480/* true args */
1481 struct vop_rmdir_args *ap = v;
1482 struct vnode *dvp = ap->a_dvp;
1483 struct cnode *dcp = VTOC(dvp);
1484 struct componentname *cnp = ap->a_cnp;
1485 struct ucred *cred = cnp->cn_cred;
1486 struct thread *td = cnp->cn_thread;
1487/* true args */
1488 int error;
1489 const char *nm = cnp->cn_nameptr;
1490 int len = cnp->cn_namelen;
1491 struct cnode *cp;
1492
1493 MARK_ENTRY(CODA_RMDIR_STATS);
1494
1495 /* Check for rmdir of control object. */
1496 if (IS_CTL_NAME(dvp, nm, len)) {
1497 MARK_INT_FAIL(CODA_RMDIR_STATS);
1498 return(ENOENT);
1499 }
1500
1501 /* We're being conservative here, it might be that this person
1502 * doesn't really have sufficient access to delete the file
1503 * but we feel zapping the entry won't really hurt anyone -- dcs
1504 */
1505 /*
1506 * As a side effect of the rmdir, remove any entries for children of
1507 * the directory, especially "." and "..".
1508 */
1509 cp = coda_nc_lookup(dcp, nm, len, cred);
1510 if (cp) coda_nc_zapParentfid(&(cp->c_fid), NOT_DOWNCALL);
1511
1512 /* Remove the file's entry from the CODA Name Cache */
1513 coda_nc_zapfile(dcp, nm, len);
1514
1515 /* Invalidate the parent's attr cache, the modification time has changed */
1516 dcp->c_flags &= ~C_VATTR;
1517
1518 error = venus_rmdir(vtomi(dvp), &dcp->c_fid, nm, len, cred, td->td_proc);
1519
1520 CODADEBUG(CODA_RMDIR, myprintf(("in rmdir result %d\n", error)); )
1521
1522 return(error);
1523}
1524
1525int
1526coda_symlink(v)
1527 void *v;
1528{
1529/* true args */
1530 struct vop_symlink_args *ap = v;
1531 struct vnode *tdvp = ap->a_dvp;
1532 struct cnode *tdcp = VTOC(tdvp);
1533 struct componentname *cnp = ap->a_cnp;
1534 struct vattr *tva = ap->a_vap;
1535 char *path = ap->a_target;
1536 struct ucred *cred = cnp->cn_cred;
1537 struct thread *td = cnp->cn_thread;
1538 struct vnode **vpp = ap->a_vpp;
1539/* locals */
1540 int error;
1541 /*
1542 * XXX I'm assuming the following things about coda_symlink's
1543 * arguments:
1544 * t(foo) is the new name/parent/etc being created.
1545 * lname is the contents of the new symlink.
1546 */
1547 char *nm = cnp->cn_nameptr;
1548 int len = cnp->cn_namelen;
1549 int plen = strlen(path);
1550
1551 /*
1552 * Here's the strategy for the moment: perform the symlink, then
1553 * do a lookup to grab the resulting vnode. I know this requires
1554 * two communications with Venus for a new sybolic link, but
1555 * that's the way the ball bounces. I don't yet want to change
1556 * the way the Mach symlink works. When Mach support is
1557 * deprecated, we should change symlink so that the common case
1558 * returns the resultant vnode in a vpp argument.
1559 */
1560
1561 MARK_ENTRY(CODA_SYMLINK_STATS);
1562
1563 /* Check for symlink of control object. */
1564 if (IS_CTL_NAME(tdvp, nm, len)) {
1565 MARK_INT_FAIL(CODA_SYMLINK_STATS);
1566 return(EACCES);
1567 }
1568
1569 if (plen+1 > CODA_MAXPATHLEN) {
1570 MARK_INT_FAIL(CODA_SYMLINK_STATS);
1571 return(EINVAL);
1572 }
1573
1574 if (len+1 > CODA_MAXNAMLEN) {
1575 MARK_INT_FAIL(CODA_SYMLINK_STATS);
1576 error = EINVAL;
1577 goto exit;
1578 }
1579
1580 error = venus_symlink(vtomi(tdvp), &tdcp->c_fid, path, plen, nm, len, tva, cred, td->td_proc);
1581
1582 /* Invalidate the parent's attr cache, the modification time has changed */
1583 tdcp->c_flags &= ~C_VATTR;
1584
1585 if (error == 0)
1586 error = VOP_LOOKUP(tdvp, vpp, cnp);
1587
1588 exit:
1589 CODADEBUG(CODA_SYMLINK, myprintf(("in symlink result %d\n",error)); )
1590 return(error);
1591}
1592
1593/*
1594 * Read directory entries.
1595 */
1596int
1597coda_readdir(v)
1598 void *v;
1599{
1600/* true args */
1601 struct vop_readdir_args *ap = v;
1602 struct vnode *vp = ap->a_vp;
1603 struct cnode *cp = VTOC(vp);
1604 register struct uio *uiop = ap->a_uio;
1605 struct ucred *cred = ap->a_cred;
1606 int *eofflag = ap->a_eofflag;
1607 u_long **cookies = ap->a_cookies;
1608 int *ncookies = ap->a_ncookies;
1609 struct thread *td = ap->a_uio->uio_td;
1610/* upcall decl */
1611/* locals */
1612 int error = 0;
1613
1614 MARK_ENTRY(CODA_READDIR_STATS);
1615
1616 CODADEBUG(CODA_READDIR, myprintf(("coda_readdir(%p, %d, %lld, %d)\n",
1617 (void *)uiop->uio_iov->iov_base,
1618 uiop->uio_resid,
1619 (long long)uiop->uio_offset,
1620 uiop->uio_segflg)); )
1621
1622 /* Check for readdir of control object. */
1623 if (IS_CTL_VP(vp)) {
1624 MARK_INT_FAIL(CODA_READDIR_STATS);
1625 return(ENOENT);
1626 }
1627
1628 {
1629 /* If directory is not already open do an "internal open" on it. */
1630 int opened_internally = 0;
1631 if (cp->c_ovp == NULL) {
1632 opened_internally = 1;
1633 MARK_INT_GEN(CODA_OPEN_STATS);
1634 error = VOP_OPEN(vp, FREAD, cred, td, -1);
1635printf("coda_readdir: Internally Opening %p\n", vp);
1636 if (error) {
1637 printf("coda_readdir: VOP_OPEN on container failed %d\n", error);
1638 return (error);
1639 }
1640 if (vp->v_type == VREG) {
1641 error = vfs_object_create(vp, td, cred);
1642 if (error != 0) {
1643 printf("coda_readdir: vfs_object_create() returns %d\n", error);
1644 vput(vp);
1645 }
1646 }
1647 if (error) return(error);
1648 }
1649
1650 /* Have UFS handle the call. */
1651 CODADEBUG(CODA_READDIR, myprintf(("indirect readdir: fid = %s, refcnt = %d\n", coda_f2s(&cp->c_fid), vp->v_usecount)); )
1652 error = VOP_READDIR(cp->c_ovp, uiop, cred, eofflag, ncookies,
1653 cookies);
1654
1655 if (error)
1656 MARK_INT_FAIL(CODA_READDIR_STATS);
1657 else
1658 MARK_INT_SAT(CODA_READDIR_STATS);
1659
1660 /* Do an "internal close" if necessary. */
1661 if (opened_internally) {
1662 MARK_INT_GEN(CODA_CLOSE_STATS);
1663 (void)VOP_CLOSE(vp, FREAD, cred, td);
1664 }
1665 }
1666
1667 return(error);
1668}
1669
1670/*
1671 * Convert from filesystem blocks to device blocks
1672 */
1673int
1674coda_bmap(v)
1675 void *v;
1676{
1677 /* XXX on the global proc */
1678/* true args */
1679 struct vop_bmap_args *ap = v;
1680 struct vnode *vp __attribute__((unused)) = ap->a_vp; /* file's vnode */
1681 daddr_t bn __attribute__((unused)) = ap->a_bn; /* fs block number */
1682 struct vnode **vpp = ap->a_vpp; /* RETURN vp of device */
1683 daddr_t *bnp __attribute__((unused)) = ap->a_bnp; /* RETURN device block number */
1684 struct thread *td __attribute__((unused)) = curthread;
1685/* upcall decl */
1686/* locals */
1687
1688 int ret = 0;
1689 struct cnode *cp;
1690
1691 cp = VTOC(vp);
1692 if (cp->c_ovp) {
1693 return EINVAL;
1694 ret = VOP_BMAP(cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb);
1695#if 0
1696 printf("VOP_BMAP(cp->c_ovp %p, bn %p, vpp %p, bnp %lld, ap->a_runp %p, ap->a_runb %p) = %d\n",
1697 cp->c_ovp, bn, vpp, bnp, ap->a_runp, ap->a_runb, ret);
1698#endif
1699 return ret;
1700 } else {
1701#if 0
1702 printf("coda_bmap: no container\n");
1703#endif
1704 return(EOPNOTSUPP);
1705 }
1706}
1707
1708int
1709coda_reclaim(v)
1710 void *v;
1711{
1712/* true args */
1713 struct vop_reclaim_args *ap = v;
1714 struct vnode *vp = ap->a_vp;
1715 struct cnode *cp = VTOC(vp);
1716/* upcall decl */
1717/* locals */
1718
1719/*
1720 * Forced unmount/flush will let vnodes with non zero use be destroyed!
1721 */
1722 ENTRY;
1723
1724 if (IS_UNMOUNTING(cp)) {
1725#ifdef DEBUG
1726 if (VTOC(vp)->c_ovp) {
1727 if (IS_UNMOUNTING(cp))
1728 printf("coda_reclaim: c_ovp not void: vp %p, cp %p\n", vp, cp);
1729 }
1730#endif
1731 } else {
1732#ifdef OLD_DIAGNOSTIC
1733 if (vrefcnt(vp) != 0)
1734 print("coda_reclaim: pushing active %p\n", vp);
1735 if (VTOC(vp)->c_ovp) {
1736 panic("coda_reclaim: c_ovp not void");
1737 }
1738#endif
1739 }
1740 cache_purge(vp);
1741 lockdestroy(&(VTOC(vp)->c_lock));
1742 coda_free(VTOC(vp));
1743 VTOC(vp) = NULL;
1744 return (0);
1745}
1746
1747int
1748coda_lock(v)
1749 void *v;
1750{
1751/* true args */
1752 struct vop_lock_args *ap = v;
1753 struct vnode *vp = ap->a_vp;
1754 struct cnode *cp = VTOC(vp);
1755 struct thread *td = ap->a_td;
1756/* upcall decl */
1757/* locals */
1758
1759 ENTRY;
1760
1761 if (coda_lockdebug) {
1762 myprintf(("Attempting lock on %s\n",
1763 coda_f2s(&cp->c_fid)));
1764 }
1765
1766#ifndef DEBUG_LOCKS
1767 return (lockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td));
1768#else
1769 return (debuglockmgr(&cp->c_lock, ap->a_flags, &vp->v_interlock, td,
1770 "coda_lock", vp->filename, vp->line));
1771#endif
1772}
1773
1774int
1775coda_unlock(v)
1776 void *v;
1777{
1778/* true args */
1779 struct vop_unlock_args *ap = v;
1780 struct vnode *vp = ap->a_vp;
1781 struct cnode *cp = VTOC(vp);
1782 struct thread *td = ap->a_td;
1783/* upcall decl */
1784/* locals */
1785
1786 ENTRY;
1787 if (coda_lockdebug) {
1788 myprintf(("Attempting unlock on %s\n",
1789 coda_f2s(&cp->c_fid)));
1790 }
1791
1792 return (lockmgr(&cp->c_lock, ap->a_flags | LK_RELEASE, &vp->v_interlock, td));
1793}
1794
1795int
1796coda_islocked(v)
1797 void *v;
1798{
1799/* true args */
1800 struct vop_islocked_args *ap = v;
1801 struct cnode *cp = VTOC(ap->a_vp);
1802 ENTRY;
1803
1804 return (lockstatus(&cp->c_lock, ap->a_td));
1805}
1806
1807/* How one looks up a vnode given a device/inode pair: */
1808int
1809coda_grab_vnode(dev_t dev, ino_t ino, struct vnode **vpp)
1810{
1811 /* This is like VFS_VGET() or igetinode()! */
1812 int error;
1813 struct mount *mp;
1814
1815 if (!(mp = devtomp(dev))) {
1816 myprintf(("coda_grab_vnode: devtomp(%#lx) returns NULL\n",
1817 (u_long)dev2udev(dev)));
1818 return(ENXIO);
1819 }
1820
1821 /* XXX - ensure that nonzero-return means failure */
1822 error = VFS_VGET(mp,ino,LK_EXCLUSIVE,vpp);
1823 if (error) {
1824 myprintf(("coda_grab_vnode: iget/vget(%lx, %lu) returns %p, err %d\n",
1825 (u_long)dev2udev(dev), (u_long)ino, (void *)*vpp, error));
1826 return(ENOENT);
1827 }
1828 return(0);
1829}
1830
1831void
1832print_vattr( attr )
1833 struct vattr *attr;
1834{
1835 char *typestr;
1836
1837 switch (attr->va_type) {
1838 case VNON:
1839 typestr = "VNON";
1840 break;
1841 case VREG:
1842 typestr = "VREG";
1843 break;
1844 case VDIR:
1845 typestr = "VDIR";
1846 break;
1847 case VBLK:
1848 typestr = "VBLK";
1849 break;
1850 case VCHR:
1851 typestr = "VCHR";
1852 break;
1853 case VLNK:
1854 typestr = "VLNK";
1855 break;
1856 case VSOCK:
1857 typestr = "VSCK";
1858 break;
1859 case VFIFO:
1860 typestr = "VFFO";
1861 break;
1862 case VBAD:
1863 typestr = "VBAD";
1864 break;
1865 default:
1866 typestr = "????";
1867 break;
1868 }
1869
1870
1871 myprintf(("attr: type %s mode %d uid %d gid %d fsid %d rdev %d\n",
1872 typestr, (int)attr->va_mode, (int)attr->va_uid,
1873 (int)attr->va_gid, (int)attr->va_fsid, (int)attr->va_rdev));
1874
1875 myprintf((" fileid %d nlink %d size %d blocksize %d bytes %d\n",
1876 (int)attr->va_fileid, (int)attr->va_nlink,
1877 (int)attr->va_size,
1878 (int)attr->va_blocksize,(int)attr->va_bytes));
1879 myprintf((" gen %ld flags %ld vaflags %d\n",
1880 attr->va_gen, attr->va_flags, attr->va_vaflags));
1881 myprintf((" atime sec %d nsec %d\n",
1882 (int)attr->va_atime.tv_sec, (int)attr->va_atime.tv_nsec));
1883 myprintf((" mtime sec %d nsec %d\n",
1884 (int)attr->va_mtime.tv_sec, (int)attr->va_mtime.tv_nsec));
1885 myprintf((" ctime sec %d nsec %d\n",
1886 (int)attr->va_ctime.tv_sec, (int)attr->va_ctime.tv_nsec));
1887}
1888
1889/* How to print a ucred */
1890void
1891print_cred(cred)
1892 struct ucred *cred;
1893{
1894
1895 int i;
1896
1897 myprintf(("ref %d\tuid %d\n",cred->cr_ref,cred->cr_uid));
1898
1899 for (i=0; i < cred->cr_ngroups; i++)
1900 myprintf(("\tgroup %d: (%d)\n",i,cred->cr_groups[i]));
1901 myprintf(("\n"));
1902
1903}
1904
1905/*
1906 * Return a vnode for the given fid.
1907 * If no cnode exists for this fid create one and put it
1908 * in a table hashed by coda_f2i(). If the cnode for
1909 * this fid is already in the table return it (ref count is
1910 * incremented by coda_find. The cnode will be flushed from the
1911 * table when coda_inactive calls coda_unsave.
1912 */
1913struct cnode *
1914make_coda_node(fid, vfsp, type)
1915 CodaFid *fid; struct mount *vfsp; short type;
1916{
1917 struct cnode *cp;
1918 int err;
1919
1920 if ((cp = coda_find(fid)) == NULL) {
1921 struct vnode *vp;
1922
1923 cp = coda_alloc();
1924 lockinit(&cp->c_lock, PINOD, "cnode", 0, 0);
1925 cp->c_fid = *fid;
1926
1927 err = getnewvnode("coda", vfsp, coda_vnodeop_p, &vp);
1928 if (err) {
1929 panic("coda: getnewvnode returned error %d\n", err);
1930 }
1931 vp->v_data = cp;
1932 vp->v_type = type;
1933 cp->c_vnode = vp;
1934 coda_save(cp);
1935
1936 } else {
1937 vref(CTOV(cp));
1938 }
1939
1940 return cp;
1941}
1942
1943int
1944coda_pathconf(v)
1945 void *v;
1946{
1947 struct vop_pathconf_args *ap;
1948 int error;
1949 register_t *retval;
1950
1951 ap = v;
1952 retval = ap->a_retval;
1953 error = 0;
1954
1955 switch (ap->a_name) {
1956 case _PC_NAME_MAX:
1957 *retval = CODA_MAXNAMLEN;
1958 break;
1959 case _PC_PATH_MAX:
1960 *retval = CODA_MAXPATHLEN;
1961 break;
1962 default:
1963 error = vop_stdpathconf(ap);
1964 break;
1965 }
1966
1967 return (error);
1968}