6 #include <afs/sysincludes.h> /* Standard vendor system headers */
7 #include <afsincludes.h> /* Afs-based standard headers */
8 #include <afs/afs_stats.h> /* statistics */
9 #include <sys/malloc.h>
10 #include <sys/namei.h>
11 #ifndef AFS_FBSD50_ENV
12 #include <vm/vm_zone.h>
14 #include <vm/vm_page.h>
15 #include <vm/vm_object.h>
16 #include <vm/vm_pager.h>
17 #include <vm/vnode_pager.h>
18 extern int afs_pbuf_freecnt;
20 int afs_vop_lookup(struct vop_lookup_args *);
21 int afs_vop_create(struct vop_create_args *);
22 int afs_vop_mknod(struct vop_mknod_args *);
23 int afs_vop_open(struct vop_open_args *);
24 int afs_vop_close(struct vop_close_args *);
25 int afs_vop_access(struct vop_access_args *);
26 int afs_vop_getattr(struct vop_getattr_args *);
27 int afs_vop_setattr(struct vop_setattr_args *);
28 int afs_vop_read(struct vop_read_args *);
29 int afs_vop_write(struct vop_write_args *);
30 int afs_vop_getpages(struct vop_getpages_args *);
31 int afs_vop_putpages(struct vop_putpages_args *);
32 int afs_vop_ioctl(struct vop_ioctl_args *);
33 int afs_vop_poll(struct vop_poll_args *);
34 int afs_vop_mmap(struct vop_mmap_args *);
35 int afs_vop_fsync(struct vop_fsync_args *);
36 int afs_vop_remove(struct vop_remove_args *);
37 int afs_vop_link(struct vop_link_args *);
38 int afs_vop_rename(struct vop_rename_args *);
39 int afs_vop_mkdir(struct vop_mkdir_args *);
40 int afs_vop_rmdir(struct vop_rmdir_args *);
41 int afs_vop_symlink(struct vop_symlink_args *);
42 int afs_vop_readdir(struct vop_readdir_args *);
43 int afs_vop_readlink(struct vop_readlink_args *);
44 int afs_vop_inactive(struct vop_inactive_args *);
45 int afs_vop_reclaim(struct vop_reclaim_args *);
46 int afs_vop_lock(struct vop_lock_args *);
47 int afs_vop_unlock(struct vop_unlock_args *);
48 int afs_vop_bmap(struct vop_bmap_args *);
49 int afs_vop_strategy(struct vop_strategy_args *);
50 int afs_vop_print(struct vop_print_args *);
51 int afs_vop_islocked(struct vop_islocked_args *);
52 int afs_vop_advlock(struct vop_advlock_args *);
56 /* Global vfs data structures for AFS. */
57 vop_t **afs_vnodeop_p;
58 struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
59 { &vop_default_desc, (vop_t *) vop_eopnotsupp },
60 { &vop_access_desc, (vop_t *) afs_vop_access }, /* access */
61 { &vop_advlock_desc, (vop_t *) afs_vop_advlock }, /* advlock */
62 { &vop_bmap_desc, (vop_t *) afs_vop_bmap }, /* bmap */
63 #ifndef AFS_FBSD50_ENV
64 { &vop_bwrite_desc, (vop_t *) vop_stdbwrite },
66 { &vop_close_desc, (vop_t *) afs_vop_close }, /* close */
67 { &vop_createvobject_desc, (vop_t *) vop_stdcreatevobject },
68 { &vop_destroyvobject_desc, (vop_t *) vop_stddestroyvobject },
69 { &vop_create_desc, (vop_t *) afs_vop_create }, /* create */
70 { &vop_fsync_desc, (vop_t *) afs_vop_fsync }, /* fsync */
71 { &vop_getattr_desc, (vop_t *) afs_vop_getattr }, /* getattr */
72 { &vop_getpages_desc, (vop_t *) afs_vop_getpages }, /* read */
73 { &vop_getvobject_desc, (vop_t *) vop_stdgetvobject },
74 { &vop_putpages_desc, (vop_t *) afs_vop_putpages }, /* write */
75 { &vop_inactive_desc, (vop_t *) afs_vop_inactive }, /* inactive */
76 { &vop_islocked_desc, (vop_t *) afs_vop_islocked }, /* islocked */
77 { &vop_lease_desc, (vop_t *) vop_null },
78 { &vop_link_desc, (vop_t *) afs_vop_link }, /* link */
79 { &vop_lock_desc, (vop_t *) afs_vop_lock }, /* lock */
80 { &vop_lookup_desc, (vop_t *) afs_vop_lookup }, /* lookup */
81 { &vop_mkdir_desc, (vop_t *) afs_vop_mkdir }, /* mkdir */
82 { &vop_mknod_desc, (vop_t *) afs_vop_mknod }, /* mknod */
83 { &vop_mmap_desc, (vop_t *) afs_vop_mmap }, /* mmap */
84 { &vop_open_desc, (vop_t *) afs_vop_open }, /* open */
85 { &vop_poll_desc, (vop_t *) afs_vop_poll }, /* select */
86 { &vop_print_desc, (vop_t *) afs_vop_print }, /* print */
87 { &vop_read_desc, (vop_t *) afs_vop_read }, /* read */
88 { &vop_readdir_desc, (vop_t *) afs_vop_readdir }, /* readdir */
89 { &vop_readlink_desc, (vop_t *) afs_vop_readlink }, /* readlink */
90 { &vop_reclaim_desc, (vop_t *) afs_vop_reclaim }, /* reclaim */
91 { &vop_remove_desc, (vop_t *) afs_vop_remove }, /* remove */
92 { &vop_rename_desc, (vop_t *) afs_vop_rename }, /* rename */
93 { &vop_rmdir_desc, (vop_t *) afs_vop_rmdir }, /* rmdir */
94 { &vop_setattr_desc, (vop_t *) afs_vop_setattr }, /* setattr */
95 { &vop_strategy_desc, (vop_t *) afs_vop_strategy }, /* strategy */
96 { &vop_symlink_desc, (vop_t *) afs_vop_symlink }, /* symlink */
97 { &vop_unlock_desc, (vop_t *) afs_vop_unlock }, /* unlock */
98 { &vop_write_desc, (vop_t *) afs_vop_write }, /* write */
99 { &vop_ioctl_desc, (vop_t *) afs_vop_ioctl }, /* XXX ioctl */
100 /*{ &vop_seek_desc, afs_vop_seek },*/ /* seek */
103 struct vnodeopv_desc afs_vnodeop_opv_desc =
104 { &afs_vnodeop_p, afs_vnodeop_entries };
107 struct componentname *cnp = ap->a_cnp; \
109 MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
110 memcpy(name, cnp->cn_nameptr, cnp->cn_namelen); \
111 name[cnp->cn_namelen] = '\0'
113 #define DROPNAME() FREE(name, M_TEMP)
119 struct vop_lookup_args /* {
120 struct vnodeop_desc * a_desc;
122 struct vnode **a_vpp;
123 struct componentname *a_cnp;
128 struct vnode *vp, *dvp;
129 register int flags = ap->a_cnp->cn_flags;
130 int lockparent; /* 1 => lockparent flag is set */
131 int wantparent; /* 1 => wantparent or lockparent flag */
132 #ifdef AFS_FBSD50_ENV
133 struct thread *p = ap->a_cnp->cn_thread;
135 struct proc *p = ap->a_cnp->cn_proc;
139 lockparent = flags & LOCKPARENT;
140 wantparent = flags & (LOCKPARENT|WANTPARENT);
142 if (ap->a_dvp->v_type != VDIR) {
148 if (flags & ISDOTDOT)
149 VOP_UNLOCK(dvp, 0, p);
151 error = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
154 if (flags & ISDOTDOT)
155 VOP_LOCK(dvp, LK_EXCLUSIVE | LK_RETRY, p);
156 if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME) &&
157 (flags & ISLASTCN) && error == ENOENT)
159 if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
160 cnp->cn_flags |= SAVENAME;
165 vp = AFSTOV(vcp); /* always get a node if no error */
167 /* The parent directory comes in locked. We unlock it on return
168 unless the caller wants it left locked.
169 we also always return the vnode locked. */
171 if (flags & ISDOTDOT) {
172 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
173 /* always return the child locked */
174 if (lockparent && (flags & ISLASTCN) &&
175 (error = vn_lock(dvp, LK_EXCLUSIVE, p))) {
180 } else if (vp == dvp) {
181 /* they're the same; afs_lookup() already ref'ed the leaf.
182 It came in locked, so we don't need to ref OR lock it */
184 if (!lockparent || !(flags & ISLASTCN))
185 VOP_UNLOCK(dvp, 0, p); /* done with parent. */
186 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, p);
187 /* always return the child locked */
191 if ((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN)) ||
192 (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN)))
193 cnp->cn_flags |= SAVENAME;
201 struct vop_create_args /* {
203 struct vnode **a_vpp;
204 struct componentname *a_cnp;
210 register struct vnode *dvp = ap->a_dvp;
211 #ifdef AFS_FBSD50_ENV
212 struct thread *p = ap->a_cnp->cn_thread;
214 struct proc *p = ap->a_cnp->cn_proc;
219 error = afs_create(VTOAFS(dvp), name, ap->a_vap, ap->a_vap->va_vaflags & VA_EXCLUSIVE? EXCL : NONEXCL,
220 ap->a_vap->va_mode, &vcp,
229 *ap->a_vpp = AFSTOV(vcp);
230 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE| LK_RETRY, p);
240 struct vop_mknod_args /* {
242 struct vnode **a_vpp;
243 struct componentname *a_cnp;
251 static int validate_vops(struct vnode *vp, int after)
254 struct vnodeopv_entry_desc *this;
255 for (this=afs_vnodeop_entries; this->opve_op; this++) {
256 if (vp->v_op[this->opve_op->vdesc_offset] != this->opve_impl) {
258 printf("v_op %d ", after);
262 printf("For oper %d (%s), func is %p, not %p",
263 this->opve_op->vdesc_offset, this->opve_op->vdesc_name,
264 vp->v_op[this->opve_op->vdesc_offset], this->opve_impl);
272 struct vop_open_args /* {
275 struct ucred *a_cred;
281 struct vcache *vc = VTOAFS(ap->a_vp);
284 error = afs_open(&vc, ap->a_mode, ap->a_cred);
286 if (AFSTOV(vc) != ap->a_vp)
287 panic("AFS open changed vnode!");
289 afs_BozonLock(&vc->pvnLock, vc);
290 osi_FlushPages(vc, ap->a_cred);
291 afs_BozonUnlock(&vc->pvnLock, vc);
298 struct vop_close_args /* {
301 struct ucred *a_cred;
306 struct vcache *avc=ap->a_vp;
309 code=afs_close(avc, ap->a_fflag, ap->a_cred, ap->a_p);
311 code=afs_close(avc, ap->a_fflag, &afs_osi_cred, ap->a_p);
312 afs_BozonLock(&avc->pvnLock, avc);
313 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
314 afs_BozonUnlock(&avc->pvnLock, avc);
321 struct vop_access_args /* {
324 struct ucred *a_cred;
330 code=afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
336 struct vop_getattr_args /* {
339 struct ucred *a_cred;
345 code=afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
351 struct vop_setattr_args /* {
354 struct ucred *a_cred;
360 code=afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
365 struct vop_read_args /* {
369 struct ucred *a_cred;
374 struct vcache *avc=VTOAFS(ap->a_vp);
376 afs_BozonLock(&avc->pvnLock, avc);
377 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
378 code=afs_read(avc, ap->a_uio, ap->a_cred, 0, 0, 0);
379 afs_BozonUnlock(&avc->pvnLock, avc);
385 struct vop_getpages_args /* {
390 vm_oofset_t a_offset;
394 int i, nextoff, size, toff, npages;
399 struct vcache *avc=VTOAFS(ap->a_vp);
401 if (avc->v.v_object == NULL) {
402 printf("afs_getpages: called with non-merged cache vnode??\n");
403 return VM_PAGER_ERROR;
405 npages=btoc(ap->a_count);
407 * If the requested page is partially valid, just return it and
408 * allow the pager to zero-out the blanks. Partially valid pages
409 * can only occur at the file EOF.
413 vm_page_t m = ap->a_m[ap->a_reqpage];
416 /* handled by vm_fault now */
417 /* vm_page_zero_invalid(m, TRUE); */
418 for (i = 0; i < npages; ++i) {
419 if (i != ap->a_reqpage)
420 vnode_pager_freepage(ap->a_m[i]);
425 bp = getpbuf(&afs_pbuf_freecnt);
426 kva = (vm_offset_t) bp->b_data;
427 pmap_qenter(kva, ap->a_m, npages);
428 iov.iov_base = (caddr_t)kva;
429 iov.iov_len = ap->a_count;
432 uio.uio_offset = IDX_TO_OFF(ap->a_m[0]->pindex);
433 uio.uio_resid = ap->a_count;
434 uio.uio_segflg = UIO_SYSSPACE;
435 uio.uio_rw = UIO_READ;
436 #ifdef AFS_FBSD50_ENV
437 uio.uio_td = curthread;
439 uio.uio_procp = curproc;
442 afs_BozonLock(&avc->pvnLock, avc);
443 osi_FlushPages(avc, osi_curcred()); /* hold bozon lock, but not basic vnode lock */
444 code=afs_read(avc, &uio, osi_curcred(), 0, 0, 0);
445 afs_BozonUnlock(&avc->pvnLock, avc);
447 pmap_qremove(kva, npages);
449 relpbuf(bp, &afs_pbuf_freecnt);
450 if (code && (uio.uio_resid == ap->a_count)) {
451 for (i = 0; i < npages; ++i) {
452 if (i != ap->a_reqpage)
453 vnode_pager_freepage(ap->a_m[i]);
455 return VM_PAGER_ERROR;
457 size = ap->a_count - uio.uio_resid;
458 for (i = 0, toff = 0; i < npages; i++, toff = nextoff) {
460 nextoff = toff + PAGE_SIZE;
463 m->flags &= ~PG_ZERO;
465 if (nextoff <= size) {
467 * Read operation filled an entire page
469 m->valid = VM_PAGE_BITS_ALL;
471 } else if (size > toff) {
473 * Read operation filled a partial page.
476 vm_page_set_validclean(m, 0, size - toff);
477 /* handled by vm_fault now */
478 /* vm_page_zero_invalid(m, TRUE); */
481 if (i != ap->a_reqpage) {
483 * Whether or not to leave the page activated is up in
484 * the air, but we should put the page on a page queue
485 * somewhere (it already is in the object). Result:
486 * It appears that emperical results show that
487 * deactivating pages is best.
491 * Just in case someone was asking for this page we
492 * now tell them that it is ok to use.
495 if (m->flags & PG_WANTED)
498 vm_page_deactivate(m);
501 vnode_pager_freepage(m);
510 struct vop_write_args /* {
514 struct ucred *a_cred;
518 struct vcache *avc=VTOAFS(ap->a_vp);
520 afs_BozonLock(&avc->pvnLock, avc);
521 osi_FlushPages(avc, ap->a_cred); /* hold bozon lock, but not basic vnode lock */
522 code=afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
523 afs_BozonUnlock(&avc->pvnLock, avc);
530 struct vop_putpages_args /* {
536 vm_oofset_t a_offset;
540 int i, size, npages, sync;
545 struct vcache *avc=VTOAFS(ap->a_vp);
547 if (avc->v.v_object == NULL) {
548 printf("afs_putpages: called with non-merged cache vnode??\n");
549 return VM_PAGER_ERROR;
551 if (vType(avc) != VREG) {
552 printf("afs_putpages: not VREG");
553 return VM_PAGER_ERROR;
555 npages=btoc(ap->a_count);
556 for (i=0; i < npages; i++ ) ap->a_rtvals[i]=VM_PAGER_AGAIN;
557 bp = getpbuf(&afs_pbuf_freecnt);
558 kva = (vm_offset_t) bp->b_data;
559 pmap_qenter(kva, ap->a_m, npages);
560 iov.iov_base = (caddr_t)kva;
561 iov.iov_len = ap->a_count;
564 uio.uio_offset = IDX_TO_OFF(ap->a_m[0]->pindex);
565 uio.uio_resid = ap->a_count;
566 uio.uio_segflg = UIO_SYSSPACE;
567 uio.uio_rw = UIO_WRITE;
568 #ifdef AFS_FBSD50_ENV
569 uio.uio_td = curthread;
571 uio.uio_procp = curproc;
574 if (ap->a_sync & VM_PAGER_PUT_SYNC)
576 /*if (ap->a_sync & VM_PAGER_PUT_INVAL)
580 afs_BozonLock(&avc->pvnLock, avc);
581 code = afs_write(avc, &uio, sync, osi_curcred(), 0);
582 afs_BozonUnlock(&avc->pvnLock, avc);
584 pmap_qremove(kva, npages);
586 relpbuf(bp, &afs_pbuf_freecnt);
588 size = ap->a_count - uio.uio_resid;
589 for (i = 0; i < round_page(size) / PAGE_SIZE; i++) {
590 ap->a_rtvals[i]=VM_PAGER_OK;
593 return VM_PAGER_ERROR;
595 return ap->a_rtvals[0];
600 struct vop_ioctl_args /* {
605 struct ucred *a_cred;
609 struct vcache *tvc = VTOAFS(ap->a_vp);
612 /* in case we ever get in here... */
614 AFS_STATCNT(afs_ioctl);
615 if (((ap->a_command >> 8) & 0xff) == 'V') {
616 /* This is a VICEIOCTL call */
618 error = HandleIoctl(tvc, NULL /*Not used*/,
619 ap->a_command, ap->a_data);
623 /* No-op call; just return. */
631 struct vop_poll_args /* {
634 struct ucred *a_cred;
639 * We should really check to see if I/O is possible.
646 * NB Currently unsupported.
651 struct vop_mmap_args /* {
654 struct ucred *a_cred;
663 struct vop_fsync_args /* {
665 struct ucred *a_cred;
671 register struct vnode *vp = ap->a_vp;
674 /*vflushbuf(vp, wait);*/
676 error = afs_fsync(VTOAFS(vp), ap->a_cred);
678 error = afs_fsync(VTOAFS(vp), &afs_osi_cred);
685 struct vop_remove_args /* {
688 struct componentname *a_cnp;
692 register struct vnode *vp = ap->a_vp;
693 register struct vnode *dvp = ap->a_dvp;
697 error = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
706 struct vop_link_args /* {
708 struct vnode *a_tdvp;
709 struct componentname *a_cnp;
713 register struct vnode *dvp = ap->a_tdvp;
714 register struct vnode *vp = ap->a_vp;
715 #ifdef AFS_FBSD50_ENV
716 struct thread *p = ap->a_cnp->cn_thread;
718 struct proc *p = ap->a_cnp->cn_proc;
722 if (dvp->v_mount != vp->v_mount) {
726 if (vp->v_type == VDIR) {
730 if ((error = vn_lock(vp, LK_EXCLUSIVE, p)) != 0) {
734 error = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
745 struct vop_rename_args /* {
746 struct vnode *a_fdvp;
748 struct componentname *a_fcnp;
749 struct vnode *a_tdvp;
751 struct componentname *a_tcnp;
755 struct componentname *fcnp = ap->a_fcnp;
757 struct componentname *tcnp = ap->a_tcnp;
759 struct vnode *tvp = ap->a_tvp;
760 register struct vnode *tdvp = ap->a_tdvp;
761 struct vnode *fvp = ap->a_fvp;
762 register struct vnode *fdvp = ap->a_fdvp;
763 #ifdef AFS_FBSD50_ENV
764 struct thread *p = fcnp->cn_thread;
766 struct proc *p = fcnp->cn_proc;
770 * Check for cross-device rename.
772 if ((fvp->v_mount != tdvp->v_mount) ||
773 (tvp && (fvp->v_mount != tvp->v_mount))) {
787 * if fvp == tvp, we're just removing one name of a pair of
788 * directory entries for the same element. convert call into rename.
789 ( (pinched from FreeBSD 4.4's ufs_rename())
793 if (fvp->v_type == VDIR) {
798 /* Release destination completely. */
805 fcnp->cn_flags &= ~MODMASK;
806 fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
807 if ((fcnp->cn_flags & SAVESTART) == 0)
808 panic("afs_rename: lost from startdir");
809 fcnp->cn_nameiop = DELETE;
811 error=relookup(fdvp, &fvp, fcnp);
818 error=VOP_REMOVE(fdvp, fvp, fcnp);
826 if ((error = vn_lock(fvp, LK_EXCLUSIVE, p)) != 0)
829 MALLOC(fname, char *, fcnp->cn_namelen+1, M_TEMP, M_WAITOK);
830 memcpy(fname, fcnp->cn_nameptr, fcnp->cn_namelen);
831 fname[fcnp->cn_namelen] = '\0';
832 MALLOC(tname, char *, tcnp->cn_namelen+1, M_TEMP, M_WAITOK);
833 memcpy(tname, tcnp->cn_nameptr, tcnp->cn_namelen);
834 tname[tcnp->cn_namelen] = '\0';
838 /* XXX use "from" or "to" creds? NFS uses "to" creds */
839 error = afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
857 struct vop_mkdir_args /* {
859 struct vnode **a_vpp;
860 struct componentname *a_cnp;
864 register struct vnode *dvp = ap->a_dvp;
865 register struct vattr *vap = ap->a_vap;
868 #ifdef AFS_FBSD50_ENV
869 struct thread *p = ap->a_cnp->cn_thread;
871 struct proc *p = ap->a_cnp->cn_proc;
876 if ((cnp->cn_flags & HASBUF) == 0)
877 panic("afs_vop_mkdir: no name");
880 error = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
888 *ap->a_vpp = AFSTOV(vcp);
889 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE|LK_RETRY, p);
898 struct vop_rmdir_args /* {
901 struct componentname *a_cnp;
905 register struct vnode *dvp = ap->a_dvp;
909 error = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
917 struct vop_symlink_args /* {
919 struct vnode **a_vpp;
920 struct componentname *a_cnp;
925 register struct vnode *dvp = ap->a_dvp;
927 /* NFS ignores a_vpp; so do we. */
931 error = afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target,
940 struct vop_readdir_args /* {
943 struct ucred *a_cred;
951 /* printf("readdir %x cookies %x ncookies %d\n", ap->a_vp, ap->a_cookies,
953 off=ap->a_uio->uio_offset;
955 error= afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred,
958 if (!error && ap->a_ncookies != NULL) {
959 struct uio *uio = ap->a_uio;
960 const struct dirent *dp, *dp_start, *dp_end;
962 u_long *cookies, *cookiep;
964 if (uio->uio_segflg != UIO_SYSSPACE || uio->uio_iovcnt != 1)
965 panic("afs_readdir: burned cookies");
966 dp = (const struct dirent *)
967 ((const char *)uio->uio_iov->iov_base - (uio->uio_offset - off));
969 dp_end = (const struct dirent *) uio->uio_iov->iov_base;
970 for (dp_start = dp, ncookies = 0;
972 dp = (const struct dirent *)((const char *) dp + dp->d_reclen))
975 MALLOC(cookies, u_long *, ncookies * sizeof(u_long),
977 for (dp = dp_start, cookiep = cookies;
979 dp = (const struct dirent *)((const char *) dp + dp->d_reclen)) {
983 *ap->a_cookies = cookies;
984 *ap->a_ncookies = ncookies;
992 struct vop_readlink_args /* {
995 struct ucred *a_cred;
999 /* printf("readlink %x\n", ap->a_vp);*/
1001 error= afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
1006 extern int prtactive;
1009 afs_vop_inactive(ap)
1010 struct vop_inactive_args /* {
1015 register struct vnode *vp = ap->a_vp;
1017 if (prtactive && vp->v_usecount != 0)
1018 vprint("afs_vop_inactive(): pushing active", vp);
1021 afs_InactiveVCache(VTOAFS(vp), 0); /* decrs ref counts */
1023 VOP_UNLOCK(vp, 0, ap->a_p);
1029 struct vop_reclaim_args /* {
1035 register struct vnode *vp = ap->a_vp;
1037 cache_purge(vp); /* just in case... */
1041 error = afs_FlushVCache(VTOAFS(vp), &sl); /* tosses our stuff from vnode */
1044 if (!error && vp->v_data)
1045 panic("afs_reclaim: vnode not cleaned");
1048 if (vp->v_usecount == 2) {
1049 vprint("reclaim count==2", vp);
1050 } else if (vp->v_usecount == 1) {
1051 vprint("reclaim count==1", vp);
1053 vprint("reclaim bad count", vp);
1061 struct vop_lock_args /* {
1065 register struct vnode *vp = ap->a_vp;
1066 register struct vcache *avc = VTOAFS(vp);
1068 #ifdef AFS_FBSD50_ENV
1069 if (!strcmp(vp->v_tag, "none"))
1071 if (vp->v_tag == VT_NON)
1074 return (lockmgr(&avc->rwlock, ap->a_flags, &vp->v_interlock,
1080 struct vop_unlock_args /* {
1084 struct vnode *vp = ap->a_vp;
1085 struct vcache *avc = VTOAFS(vp);
1086 return (lockmgr(&avc->rwlock, ap->a_flags | LK_RELEASE,
1087 &vp->v_interlock, ap->a_p));
1093 struct vop_bmap_args /* {
1096 struct vnode **a_vpp;
1103 *ap->a_bnp = ap->a_bn * (PAGE_SIZE / DEV_BSIZE);
1106 *ap->a_vpp = ap->a_vp;
1108 if (ap->a_runp != NULL)
1110 if (ap->a_runb != NULL)
1116 afs_vop_strategy(ap)
1117 struct vop_strategy_args /* {
1123 error= afs_ustrategy(ap->a_bp);
1129 struct vop_print_args /* {
1133 register struct vnode *vp = ap->a_vp;
1134 register struct vcache *vc = VTOAFS(ap->a_vp);
1136 printf("tag %d, fid: %ld.%x.%x.%x, opens %d, writers %d", vp->v_tag, vc->fid.Cell,
1137 vc->fid.Fid.Volume, vc->fid.Fid.Vnode, vc->fid.Fid.Unique, vc->opens,
1138 vc->execsOrWriters);
1139 printf("\n states%s%s%s%s%s", (s&CStatd) ? " statd" : "", (s&CRO) ? " readonly" : "",(s&CDirty) ? " dirty" : "",(s&CMAPPED) ? " mapped" : "", (s&CVFlushed) ? " flush in progress" : "");
1145 afs_vop_islocked(ap)
1146 struct vop_islocked_args /* {
1150 struct vcache *vc = VTOAFS(ap->a_vp);
1151 return lockstatus(&vc->rwlock, ap->a_p);
1155 * Advisory record locking support (fcntl() POSIX style)
1159 struct vop_advlock_args /* {
1168 struct ucred cr = *osi_curcred();
1171 error= afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, &cr,