2 * OpenBSD specific vnodeops + other misc interface glue
3 * Original NetBSD version for Transarc afs by John Kohl <jtk@MIT.EDU>
4 * OpenBSD version by Jim Rees <rees@umich.edu>
11 the regents of the university of michigan
14 permission is granted to use, copy, create derivative works
15 and redistribute this software and such derivative works
16 for any purpose, so long as the name of the university of
17 michigan is not used in any advertising or publicity
18 pertaining to the use or distribution of this software
19 without specific, written prior authorization. if the
20 above copyright notice or any other identification of the
21 university of michigan is included in any copy of any
22 portion of this software, then the disclaimer below must
25 this software is provided as is, without representation
26 from the university of michigan as to its fitness for any
27 purpose, and without warranty by the university of
28 michigan of any kind, either express or implied, including
29 without limitation the implied warranties of
30 merchantability and fitness for a particular purpose. the
31 regents of the university of michigan shall not be liable
32 for any damages, including special, indirect, incidental, or
33 consequential damages, with respect to any claim arising
34 out of or in connection with the use of the software, even
35 if it has been or is hereafter advised of the possibility of
40 Copyright 1995 Massachusetts Institute of Technology. All Rights
43 You are hereby granted a worldwide, irrevocable, paid-up, right and
44 license to use, execute, display, modify, copy and distribute MIT's
45 Modifications, provided that (i) you abide by the terms and conditions
46 of your OpenAFS License Agreement, and (ii) you do not use the name
47 of MIT in any advertising or publicity without the prior written consent
48 of MIT. MIT disclaims all liability for your use of MIT's
49 Modifications. MIT's Modifications are provided "AS IS" WITHOUT
50 WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO,
51 ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
56 * A bunch of code cribbed from NetBSD ufs_vnops.c, ffs_vnops.c, and
57 * nfs_vnops.c which carry this copyright:
60 * Copyright (c) 1982, 1986, 1989, 1993
61 * The Regents of the University of California. All rights reserved.
62 * (c) UNIX System Laboratories, Inc.
63 * All or some portions of this file are derived from material licensed
64 * to the University of California by American Telephone and Telegraph
65 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
66 * the permission of UNIX System Laboratories, Inc.
68 * Redistribution and use in source and binary forms, with or without
69 * modification, are permitted provided that the following conditions
71 * 1. Redistributions of source code must retain the above copyright
72 * notice, this list of conditions and the following disclaimer.
73 * 2. Redistributions in binary form must reproduce the above copyright
74 * notice, this list of conditions and the following disclaimer in the
75 * documentation and/or other materials provided with the distribution.
76 * 3. All advertising materials mentioning features or use of this software
77 * must display the following acknowledgement:
78 * This product includes software developed by the University of
79 * California, Berkeley and its contributors.
80 * 4. Neither the name of the University nor the names of its contributors
81 * may be used to endorse or promote products derived from this software
82 * without specific prior written permission.
84 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
85 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
86 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
87 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
88 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
89 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
90 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
91 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
92 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
93 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
98 #include <afsconfig.h>
99 #include "afs/param.h"
104 #include "afs/sysincludes.h" /* Standard vendor system headers */
105 #include "afs/afsincludes.h" /* Afs-based standard headers */
106 #include "afs/afs_stats.h" /* statistics */
108 #include <sys/malloc.h>
109 #include <sys/namei.h>
111 #include "afs/afs_cbqueue.h"
112 #include "afs/nfsclient.h"
113 #include "afs/afs_osidnlc.h"
115 #ifdef AFS_DISCON_ENV
116 extern int afs_FlushVS(struct vcache *tvc);
119 #define M_AFSNODE (M_TEMP-1) /* XXX */
121 int afs_nbsd_lookup(struct vop_lookup_args *);
122 int afs_nbsd_create(struct vop_create_args *);
123 int afs_nbsd_mknod(struct vop_mknod_args *);
124 int afs_nbsd_open(struct vop_open_args *);
125 int afs_nbsd_close(struct vop_close_args *);
126 int afs_nbsd_access(struct vop_access_args *);
127 int afs_nbsd_getattr(struct vop_getattr_args *);
128 int afs_nbsd_setattr(struct vop_setattr_args *);
129 int afs_nbsd_read(struct vop_read_args *);
130 int afs_nbsd_write(struct vop_write_args *);
131 int afs_nbsd_ioctl(struct vop_ioctl_args *);
132 int afs_nbsd_select(struct vop_select_args *);
133 int afs_nbsd_fsync(struct vop_fsync_args *);
134 int afs_nbsd_remove(struct vop_remove_args *);
135 int afs_nbsd_link(struct vop_link_args *);
136 int afs_nbsd_rename(struct vop_rename_args *);
137 int afs_nbsd_mkdir(struct vop_mkdir_args *);
138 int afs_nbsd_rmdir(struct vop_rmdir_args *);
139 int afs_nbsd_symlink(struct vop_symlink_args *);
140 int afs_nbsd_readdir(struct vop_readdir_args *);
141 int afs_nbsd_readlink(struct vop_readlink_args *);
142 extern int ufs_abortop(struct vop_abortop_args *);
143 int afs_nbsd_inactive(struct vop_inactive_args *);
144 int afs_nbsd_reclaim(struct vop_reclaim_args *);
145 int afs_nbsd_lock(struct vop_lock_args *);
146 int afs_nbsd_unlock(struct vop_unlock_args *);
147 int afs_nbsd_bmap(struct vop_bmap_args *);
148 int afs_nbsd_strategy(struct vop_strategy_args *);
149 int afs_nbsd_print(struct vop_print_args *);
150 int afs_nbsd_islocked(struct vop_islocked_args *);
151 int afs_nbsd_pathconf(struct vop_pathconf_args *);
152 int afs_nbsd_advlock(struct vop_advlock_args *);
154 #define afs_nbsd_opnotsupp \
155 ((int (*) __P((struct vop_reallocblks_args *)))eopnotsupp)
156 #define afs_nbsd_reallocblks afs_nbsd_opnotsupp
158 /* Global vfs data structures for AFS. */
159 int (**afs_vnodeop_p) __P((void *));
160 struct vnodeopv_entry_desc afs_vnodeop_entries[] = {
161 {&vop_default_desc, vn_default_error},
162 {&vop_lookup_desc, afs_nbsd_lookup}, /* lookup */
163 {&vop_create_desc, afs_nbsd_create}, /* create */
164 {&vop_mknod_desc, afs_nbsd_mknod}, /* mknod */
165 {&vop_open_desc, afs_nbsd_open}, /* open */
166 {&vop_close_desc, afs_nbsd_close}, /* close */
167 {&vop_access_desc, afs_nbsd_access}, /* access */
168 {&vop_getattr_desc, afs_nbsd_getattr}, /* getattr */
169 {&vop_setattr_desc, afs_nbsd_setattr}, /* setattr */
170 {&vop_read_desc, afs_nbsd_read}, /* read */
171 {&vop_write_desc, afs_nbsd_write}, /* write */
172 {&vop_ioctl_desc, afs_nbsd_ioctl}, /* XXX ioctl */
173 {&vop_select_desc, afs_nbsd_select}, /* select */
174 {&vop_fsync_desc, afs_nbsd_fsync}, /* fsync */
175 {&vop_remove_desc, afs_nbsd_remove}, /* remove */
176 {&vop_link_desc, afs_nbsd_link}, /* link */
177 {&vop_rename_desc, afs_nbsd_rename}, /* rename */
178 {&vop_mkdir_desc, afs_nbsd_mkdir}, /* mkdir */
179 {&vop_rmdir_desc, afs_nbsd_rmdir}, /* rmdir */
180 {&vop_symlink_desc, afs_nbsd_symlink}, /* symlink */
181 {&vop_readdir_desc, afs_nbsd_readdir}, /* readdir */
182 {&vop_readlink_desc, afs_nbsd_readlink}, /* readlink */
183 {&vop_abortop_desc, vop_generic_abortop}, /* abortop */
184 {&vop_inactive_desc, afs_nbsd_inactive}, /* inactive */
185 {&vop_reclaim_desc, afs_nbsd_reclaim}, /* reclaim */
186 {&vop_lock_desc, afs_nbsd_lock}, /* lock */
187 {&vop_unlock_desc, afs_nbsd_unlock}, /* unlock */
188 {&vop_bmap_desc, afs_nbsd_bmap}, /* bmap */
189 {&vop_strategy_desc, afs_nbsd_strategy}, /* strategy */
190 {&vop_print_desc, afs_nbsd_print}, /* print */
191 {&vop_islocked_desc, afs_nbsd_islocked}, /* islocked */
192 {&vop_pathconf_desc, afs_nbsd_pathconf}, /* pathconf */
193 {&vop_advlock_desc, afs_nbsd_advlock}, /* advlock */
194 {&vop_reallocblks_desc, afs_nbsd_reallocblks}, /* reallocblks */
195 {&vop_bwrite_desc, vop_generic_bwrite},
196 {(struct vnodeop_desc *)NULL, (int (*)__P((void *)))NULL}
198 struct vnodeopv_desc afs_vnodeop_opv_desc =
199 { &afs_vnodeop_p, afs_vnodeop_entries };
202 struct componentname *cnp = ap->a_cnp; \
204 MALLOC(name, char *, cnp->cn_namelen+1, M_TEMP, M_WAITOK); \
205 bcopy(cnp->cn_nameptr, name, cnp->cn_namelen); \
206 name[cnp->cn_namelen] = '\0'
208 #define DROPNAME() FREE(name, M_TEMP)
213 #define vrele afs_nbsd_rele
215 #define VREF afs_nbsd_ref
219 struct vop_lookup_args /* {
220 * struct vnodeop_desc * a_desc;
221 * struct vnode *a_dvp;
222 * struct vnode **a_vpp;
223 * struct componentname *a_cnp;
228 struct vnode *vp, *dvp;
229 int flags = ap->a_cnp->cn_flags;
230 int lockparent; /* 1 => lockparent flag is set */
231 int wantparent; /* 1 => wantparent or lockparent flag */
234 lockparent = flags & LOCKPARENT;
235 wantparent = flags & (LOCKPARENT | WANTPARENT);
237 cnp->cn_flags &= ~PDIRUNLOCK;
240 if (ap->a_dvp->v_type != VDIR) {
246 if (afs_debug & AFSDEB_VNLAYER && !(dvp->v_flag & VROOT))
247 printf("nbsd_lookup dvp %p flags %x name %s cnt %d\n", dvp, flags,
248 name, dvp->v_usecount);
250 code = afs_lookup(VTOAFS(dvp), name, &vcp, cnp->cn_cred);
253 if ((cnp->cn_nameiop == CREATE || cnp->cn_nameiop == RENAME)
254 && (flags & ISLASTCN) && code == ENOENT)
256 if (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))
257 cnp->cn_flags |= SAVENAME;
262 vp = AFSTOV(vcp); /* always get a node if no error */
265 * The parent directory comes in locked. We unlock it on return
266 * unless the caller wants it left locked.
267 * we also always return the vnode locked.
271 /* they're the same; afs_lookup() already ref'ed the leaf.
272 * It came in locked, so we don't need to ref OR lock it */
273 if (afs_debug & AFSDEB_VNLAYER)
274 printf("ref'ed %p as .\n", dvp);
276 if (!lockparent || !(flags & ISLASTCN)) {
277 VOP_UNLOCK(dvp, 0, curproc); /* done with parent. */
279 cnp->cn_flags |= PDIRUNLOCK;
282 vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc); /* always return the child locked */
283 if (afs_debug & AFSDEB_VNLAYER)
284 printf("locked ret %p from lookup\n", vp);
288 if (((cnp->cn_nameiop == RENAME && wantparent && (flags & ISLASTCN))
289 || (cnp->cn_nameiop != LOOKUP && (flags & ISLASTCN))))
290 cnp->cn_flags |= SAVENAME;
293 if (afs_debug & AFSDEB_VNLAYER && !(dvp->v_flag & VROOT))
294 printf("nbsd_lookup done dvp %p cnt %d\n", dvp, dvp->v_usecount);
300 struct vop_create_args /* {
301 * struct vnode *a_dvp;
302 * struct vnode **a_vpp;
303 * struct componentname *a_cnp;
304 * struct vattr *a_vap;
309 struct vnode *dvp = ap->a_dvp;
312 if (afs_debug & AFSDEB_VNLAYER)
313 printf("nbsd_create dvp %p cnt %d\n", dvp, dvp->v_usecount);
315 /* vnode layer handles excl/nonexcl */
319 afs_create(VTOAFS(dvp), name, ap->a_vap, NONEXCL, ap->a_vap->va_mode,
323 VOP_ABORTOP(dvp, cnp);
330 *ap->a_vpp = AFSTOV(vcp);
331 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, curproc);
335 if ((cnp->cn_flags & SAVESTART) == 0)
336 FREE(cnp->cn_pnbuf, M_NAMEI);
339 if (afs_debug & AFSDEB_VNLAYER)
340 printf("nbsd_create done dvp %p cnt %d\n", dvp, dvp->v_usecount);
346 struct vop_mknod_args /* {
347 * struct vnode *a_dvp;
348 * struct vnode **a_vpp;
349 * struct componentname *a_cnp;
350 * struct vattr *a_vap;
353 free(ap->a_cnp->cn_pnbuf, M_NAMEI);
360 struct vop_open_args /* {
361 * struct vnode *a_vp;
363 * struct ucred *a_cred;
368 struct vcache *vc = VTOAFS(ap->a_vp);
371 code = afs_open(&vc, ap->a_mode, ap->a_cred);
373 if (AFSTOV(vc) != ap->a_vp)
374 panic("AFS open changed vnode!");
382 struct vop_close_args /* {
383 * struct vnode *a_vp;
385 * struct ucred *a_cred;
392 code = afs_close(VTOAFS(ap->a_vp), ap->a_fflag, ap->a_cred, ap->a_p);
399 struct vop_access_args /* {
400 * struct vnode *a_vp;
402 * struct ucred *a_cred;
409 code = afs_access(VTOAFS(ap->a_vp), ap->a_mode, ap->a_cred);
416 struct vop_getattr_args /* {
417 * struct vnode *a_vp;
418 * struct vattr *a_vap;
419 * struct ucred *a_cred;
426 code = afs_getattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
433 struct vop_setattr_args /* {
434 * struct vnode *a_vp;
435 * struct vattr *a_vap;
436 * struct ucred *a_cred;
443 code = afs_setattr(VTOAFS(ap->a_vp), ap->a_vap, ap->a_cred);
450 struct vop_read_args /* {
451 * struct vnode *a_vp;
454 * struct ucred *a_cred;
461 afs_read(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, (daddr_t) 0, NULL,
469 struct vop_write_args /* {
470 * struct vnode *a_vp;
473 * struct ucred *a_cred;
479 (void)uvm_vnp_uncache(ap->a_vp); /* toss stale pages */
481 vnode_pager_uncache(ap->a_vp);
485 afs_write(VTOAFS(ap->a_vp), ap->a_uio, ap->a_ioflag, ap->a_cred, 0);
492 struct vop_ioctl_args /* {
493 * struct vnode *a_vp;
497 * struct ucred *a_cred;
503 /* in case we ever get in here... */
505 AFS_STATCNT(afs_ioctl);
507 if (((ap->a_command >> 8) & 0xff) == 'V')
508 /* This is a VICEIOCTL call */
510 HandleIoctl(VTOAFS(ap->a_vp), ap->a_command,
511 (struct afs_ioctl *)ap->a_data);
513 /* No-op call; just return. */
522 struct vop_select_args /* {
523 * struct vnode *a_vp;
526 * struct ucred *a_cred;
531 * We should really check to see if I/O is possible.
538 struct vop_fsync_args /* {
539 * struct vnode *a_vp;
540 * struct ucred *a_cred;
545 int wait = ap->a_waitfor == MNT_WAIT;
546 struct vnode *vp = ap->a_vp;
551 code = afs_fsync(VTOAFS(vp), ap->a_cred);
558 struct vop_remove_args /* {
559 * struct vnode *a_dvp;
560 * struct vnode *a_vp;
561 * struct componentname *a_cnp;
565 struct vnode *vp = ap->a_vp;
566 struct vnode *dvp = ap->a_dvp;
570 code = afs_remove(VTOAFS(dvp), name, cnp->cn_cred);
577 FREE(cnp->cn_pnbuf, M_NAMEI);
584 struct vop_link_args /* {
585 * struct vnode *a_vp;
586 * struct vnode *a_tdvp;
587 * struct componentname *a_cnp;
591 struct vnode *dvp = ap->a_dvp;
592 struct vnode *vp = ap->a_vp;
595 if (dvp->v_mount != vp->v_mount) {
596 VOP_ABORTOP(vp, cnp);
600 if (vp->v_type == VDIR) {
601 VOP_ABORTOP(vp, cnp);
605 if ((code = vn_lock(vp, LK_EXCLUSIVE | LK_RETRY, curproc))) {
606 VOP_ABORTOP(dvp, cnp);
611 code = afs_link(VTOAFS(vp), VTOAFS(dvp), name, cnp->cn_cred);
613 FREE(cnp->cn_pnbuf, M_NAMEI);
615 VOP_UNLOCK(vp, 0, curproc);
625 struct vop_rename_args /* {
626 * struct vnode *a_fdvp;
627 * struct vnode *a_fvp;
628 * struct componentname *a_fcnp;
629 * struct vnode *a_tdvp;
630 * struct vnode *a_tvp;
631 * struct componentname *a_tcnp;
635 struct componentname *fcnp = ap->a_fcnp;
637 struct componentname *tcnp = ap->a_tcnp;
639 struct vnode *tvp = ap->a_tvp;
640 struct vnode *tdvp = ap->a_tdvp;
641 struct vnode *fvp = ap->a_fvp;
642 struct vnode *fdvp = ap->a_fdvp;
645 * Check for cross-device rename.
647 if ((fvp->v_mount != tdvp->v_mount)
648 || (tvp && (fvp->v_mount != tvp->v_mount))) {
651 VOP_ABORTOP(tdvp, tcnp); /* XXX, why not in NFS? */
658 VOP_ABORTOP(fdvp, fcnp); /* XXX, why not in NFS? */
664 * if fvp == tvp, we're just removing one name of a pair of
665 * directory entries for the same element. convert call into rename.
666 ( (pinched from NetBSD 1.0's ufs_rename())
669 if (fvp->v_type == VDIR) {
674 /* Release destination completely. */
675 VOP_ABORTOP(tdvp, tcnp);
682 fcnp->cn_flags &= ~MODMASK;
683 fcnp->cn_flags |= LOCKPARENT | LOCKLEAF;
684 if ((fcnp->cn_flags & SAVESTART) == 0)
685 panic("afs_rename: lost from startdir");
686 fcnp->cn_nameiop = DELETE;
687 (void)relookup(fdvp, &fvp, fcnp);
688 return (VOP_REMOVE(fdvp, fvp, fcnp));
691 if ((code = vn_lock(fvp, LK_EXCLUSIVE | LK_RETRY, curproc)))
694 MALLOC(fname, char *, fcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
695 bcopy(fcnp->cn_nameptr, fname, fcnp->cn_namelen);
696 fname[fcnp->cn_namelen] = '\0';
697 MALLOC(tname, char *, tcnp->cn_namelen + 1, M_TEMP, M_WAITOK);
698 bcopy(tcnp->cn_nameptr, tname, tcnp->cn_namelen);
699 tname[tcnp->cn_namelen] = '\0';
703 /* XXX use "from" or "to" creds? NFS uses "to" creds */
705 afs_rename(VTOAFS(fdvp), fname, VTOAFS(tdvp), tname, tcnp->cn_cred);
708 VOP_UNLOCK(fvp, 0, curproc);
712 goto abortit; /* XXX */
726 struct vop_mkdir_args /* {
727 * struct vnode *a_dvp;
728 * struct vnode **a_vpp;
729 * struct componentname *a_cnp;
730 * struct vattr *a_vap;
733 struct vnode *dvp = ap->a_dvp;
734 struct vattr *vap = ap->a_vap;
740 if ((cnp->cn_flags & HASBUF) == 0)
741 panic("afs_nbsd_mkdir: no name");
744 code = afs_mkdir(VTOAFS(dvp), name, vap, &vcp, cnp->cn_cred);
747 VOP_ABORTOP(dvp, cnp);
753 *ap->a_vpp = AFSTOV(vcp);
754 vn_lock(AFSTOV(vcp), LK_EXCLUSIVE | LK_RETRY, curproc);
758 FREE(cnp->cn_pnbuf, M_NAMEI);
765 struct vop_rmdir_args /* {
766 * struct vnode *a_dvp;
767 * struct vnode *a_vp;
768 * struct componentname *a_cnp;
772 struct vnode *vp = ap->a_vp;
773 struct vnode *dvp = ap->a_dvp;
779 FREE(cnp->cn_pnbuf, M_NAMEI);
785 code = afs_rmdir(VTOAFS(dvp), name, cnp->cn_cred);
795 struct vop_symlink_args /* {
796 * struct vnode *a_dvp;
797 * struct vnode **a_vpp;
798 * struct componentname *a_cnp;
799 * struct vattr *a_vap;
803 struct vnode *dvp = ap->a_dvp;
805 /* NFS ignores a_vpp; so do we. */
810 afs_symlink(VTOAFS(dvp), name, ap->a_vap, ap->a_target, cnp->cn_cred);
813 FREE(cnp->cn_pnbuf, M_NAMEI);
820 struct vop_readdir_args /* {
821 * struct vnode *a_vp;
823 * struct ucred *a_cred;
826 * u_long **a_cookies;
832 #ifdef AFS_HAVE_COOKIES
833 printf("readdir %p cookies %p ncookies %d\n", ap->a_vp, ap->a_cookies,
836 afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag,
837 ap->a_ncookies, ap->a_cookies);
840 afs_readdir(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred, ap->a_eofflag);
847 afs_nbsd_readlink(ap)
848 struct vop_readlink_args /* {
849 * struct vnode *a_vp;
851 * struct ucred *a_cred;
857 code = afs_readlink(VTOAFS(ap->a_vp), ap->a_uio, ap->a_cred);
862 extern int prtactive;
865 afs_nbsd_inactive(ap)
866 struct vop_inactive_args /* {
867 * struct vnode *a_vp;
870 struct vnode *vp = ap->a_vp;
871 struct vcache *vc = VTOAFS(vp);
872 int haveGlock = ISAFS_GLOCK();
874 AFS_STATCNT(afs_inactive);
876 if (prtactive && vp->v_usecount != 0)
877 vprint("afs_nbsd_inactive(): pushing active", vp);
881 afs_InactiveVCache(vc, 0); /* decrs ref counts */
885 lockinit(&vc->rwlock, PINOD, "vcache", 0, 0);
891 struct vop_reclaim_args /* {
892 * struct vnode *a_vp;
896 struct vnode *vp = ap->a_vp;
897 struct vcache *avc = VTOAFS(vp);
898 int haveGlock = ISAFS_GLOCK();
899 int haveVlock = CheckLock(&afs_xvcache);
904 ObtainWriteLock(&afs_xvcache, 901);
905 #ifndef AFS_DISCON_ENV
906 code = afs_FlushVCache(avc, &slept); /* tosses our stuff from vnode */
908 /* reclaim the vnode and the in-memory vcache, but keep the on-disk vcache */
909 code = afs_FlushVS(avc);
912 ReleaseWriteLock(&afs_xvcache);
920 struct vop_lock_args /* {
921 * struct vnode *a_vp;
926 struct vnode *vp = ap->a_vp;
927 struct vcache *vc = VTOAFS(vp);
930 panic("afs_nbsd_lock: null vcache");
931 return lockmgr(&vc->rwlock, ap->a_flags | LK_CANRECURSE, &vp->v_interlock,
937 struct vop_unlock_args /* {
938 * struct vnode *a_vp;
943 struct vnode *vp = ap->a_vp;
944 struct vcache *vc = VTOAFS(vp);
947 panic("afs_nbsd_unlock: null vcache");
948 return lockmgr(&vc->rwlock, ap->a_flags | LK_RELEASE, &vp->v_interlock,
954 struct vop_bmap_args /* {
955 * struct vnode *a_vp;
957 * struct vnode **a_vpp;
962 struct vcache *vcp = VTOAFS(ap->a_vp);
964 AFS_STATCNT(afs_bmap);
966 ap->a_bnp = (daddr_t *) (ap->a_bn * (8192 / DEV_BSIZE));
968 *ap->a_vpp = (vcp) ? AFSTOV(vcp) : NULL;
973 afs_nbsd_strategy(ap)
974 struct vop_strategy_args /* {
978 struct buf *abp = ap->a_bp;
980 struct iovec tiovec[1];
981 struct vcache *tvc = VTOAFS(abp->b_vp);
982 struct ucred *credp = osi_curcred();
983 long len = abp->b_bcount;
986 AFS_STATCNT(afs_strategy);
988 tuio.afsio_iov = tiovec;
989 tuio.afsio_iovcnt = 1;
990 tuio.afsio_seg = AFS_UIOSYS;
991 tuio.afsio_resid = len;
992 tiovec[0].iov_base = abp->b_un.b_addr;
993 tiovec[0].iov_len = len;
996 if ((abp->b_flags & B_READ) == B_READ) {
997 code = afs_rdwr(tvc, &tuio, UIO_READ, 0, credp);
998 if (code == 0 && tuio.afsio_resid > 0)
999 bzero(abp->b_un.b_addr + len - tuio.afsio_resid,
1002 code = afs_rdwr(tvc, &tuio, UIO_WRITE, 0, credp);
1005 ReleaseWriteLock(&tvc->lock);
1006 AFS_RELE(AFSTOV(tvc));
1012 struct vop_print_args /* {
1013 * struct vnode *a_vp;
1016 struct vnode *vp = ap->a_vp;
1017 struct vcache *vc = VTOAFS(ap->a_vp);
1019 printf("tag %d, fid: %d.%x.%x.%x, ", vp->v_tag, vc->fid.Cell,
1020 (int)vc->fid.Fid.Volume, (int)vc->fid.Fid.Vnode,
1021 (int)vc->fid.Fid.Unique);
1022 lockmgr_printinfo(&vc->rwlock);
1028 afs_nbsd_islocked(ap)
1029 struct vop_islocked_args /* {
1030 * struct vnode *a_vp;
1033 return lockstatus(&VTOAFS(ap->a_vp)->rwlock);
1037 * Return POSIX pathconf information applicable to ufs filesystems.
1040 afs_nbsd_pathconf(ap)
1041 struct vop_pathconf_args /* {
1042 * struct vnode *a_vp;
1047 AFS_STATCNT(afs_cntl);
1048 switch (ap->a_name) {
1050 *ap->a_retval = LINK_MAX;
1053 *ap->a_retval = NAME_MAX;
1056 *ap->a_retval = PATH_MAX;
1058 case _PC_CHOWN_RESTRICTED:
1074 afs_lockctl(struct vcache *avc, struct AFS_FLOCK *af, int acmd,
1075 struct AFS_UCRED *acred, pid_t clid);
1078 * Advisory record locking support (fcntl() POSIX style)
1081 afs_nbsd_advlock(ap)
1082 struct vop_advlock_args /* {
1083 * struct vnode *a_vp;
1086 * struct flock *a_fl;
1094 afs_lockctl(VTOAFS(ap->a_vp), ap->a_fl, ap->a_op, osi_curcred(),