xref: /openbsd/sys/kern/vfs_vops.c (revision aa47c49a)
1*aa47c49aSsemarie /*	$OpenBSD: vfs_vops.c,v 1.36 2024/05/13 11:17:40 semarie Exp $	*/
257593ff0Sthib /*
357593ff0Sthib  * Copyright (c) 2010 Thordur I. Bjornsson <thib@openbsd.org>
457593ff0Sthib  *
557593ff0Sthib  * Permission to use, copy, modify, and distribute this software for any
657593ff0Sthib  * purpose with or without fee is hereby granted, provided that the above
757593ff0Sthib  * copyright notice and this permission notice appear in all copies.
857593ff0Sthib  *
957593ff0Sthib  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
1057593ff0Sthib  * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
1157593ff0Sthib  * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
1257593ff0Sthib  * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
1357593ff0Sthib  * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
1457593ff0Sthib  * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
1557593ff0Sthib  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1657593ff0Sthib  *
1757593ff0Sthib  * Copyright (c) 1992, 1993
1857593ff0Sthib  *	The Regents of the University of California.  All rights reserved.
1957593ff0Sthib  *
2057593ff0Sthib  * Redistribution and use in source and binary forms, with or without
2157593ff0Sthib  * modification, are permitted provided that the following conditions
2257593ff0Sthib  * are met:
2357593ff0Sthib  * 1. Redistributions of source code must retain the above copyright
2457593ff0Sthib  *    notice, this list of conditions and the following disclaimer.
2557593ff0Sthib  * 2. Redistributions in binary form must reproduce the above copyright
2657593ff0Sthib  *    notice, this list of conditions and the following disclaimer in the
2757593ff0Sthib  *    documentation and/or other materials provided with the distribution.
2857593ff0Sthib  * 3. Neither the name of the University nor the names of its contributors
2957593ff0Sthib  *    may be used to endorse or promote products derived from this software
3057593ff0Sthib  *    without specific prior written permission.
3157593ff0Sthib  *
3257593ff0Sthib  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS AS IS'' AND
3357593ff0Sthib  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
3457593ff0Sthib  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
3557593ff0Sthib  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
3657593ff0Sthib  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
3757593ff0Sthib  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
3857593ff0Sthib  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
3957593ff0Sthib  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
4057593ff0Sthib  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
4157593ff0Sthib  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
4257593ff0Sthib  * SUCH DAMAGE.
4357593ff0Sthib  */
4457593ff0Sthib 
4557593ff0Sthib #include <sys/param.h>
4657593ff0Sthib #include <sys/vnode.h>
475540ae66Sguenther #include <sys/unistd.h>
481d9ad96eSbeck #include <sys/systm.h>
4957593ff0Sthib 
5061169d10Sthib #ifdef VFSLCKDEBUG
5157593ff0Sthib #define ASSERT_VP_ISLOCKED(vp) do {				\
5205ee8c21Ssemarie 	if (((vp)->v_flag & VLOCKSWORK) && !VOP_ISLOCKED(vp)) {	\
5305ee8c21Ssemarie 		VOP_PRINT(vp);					\
5405ee8c21Ssemarie 		panic("vp not locked");				\
55d8d0cf1aSguenther 	}							\
5657593ff0Sthib } while (0)
5757593ff0Sthib #else
5857593ff0Sthib #define ASSERT_VP_ISLOCKED(vp)  /* nothing */
5957593ff0Sthib #endif
6057593ff0Sthib 
6157593ff0Sthib int
VOP_ISLOCKED(struct vnode * vp)6257593ff0Sthib VOP_ISLOCKED(struct vnode *vp)
6357593ff0Sthib {
6457593ff0Sthib 	struct vop_islocked_args a;
6557593ff0Sthib 	a.a_vp = vp;
6657593ff0Sthib 
6757593ff0Sthib 	if (vp->v_op->vop_islocked == NULL)
68c89ed189Sthib 		return (EOPNOTSUPP);
6957593ff0Sthib 
7057593ff0Sthib 	return ((vp->v_op->vop_islocked)(&a));
7157593ff0Sthib }
7257593ff0Sthib 
7357593ff0Sthib int
VOP_LOOKUP(struct vnode * dvp,struct vnode ** vpp,struct componentname * cnp)7457593ff0Sthib VOP_LOOKUP(struct vnode *dvp, struct vnode **vpp,
7557593ff0Sthib     struct componentname *cnp)
7657593ff0Sthib {
7757593ff0Sthib 	struct vop_lookup_args a;
7857593ff0Sthib 	a.a_dvp = dvp;
7957593ff0Sthib 	a.a_vpp = vpp;
8057593ff0Sthib 	a.a_cnp = cnp;
8157593ff0Sthib 
8257593ff0Sthib 	if (dvp->v_op->vop_lookup == NULL)
83c89ed189Sthib 		return (EOPNOTSUPP);
8457593ff0Sthib 
85f4904628Sclaudio 	return ((dvp->v_op->vop_lookup)(&a));
8657593ff0Sthib }
8757593ff0Sthib 
8857593ff0Sthib int
VOP_CREATE(struct vnode * dvp,struct vnode ** vpp,struct componentname * cnp,struct vattr * vap)8957593ff0Sthib VOP_CREATE(struct vnode *dvp, struct vnode **vpp,
9057593ff0Sthib     struct componentname *cnp, struct vattr *vap)
9157593ff0Sthib {
9257593ff0Sthib 	struct vop_create_args a;
9357593ff0Sthib 	a.a_dvp = dvp;
9457593ff0Sthib 	a.a_vpp = vpp;
9557593ff0Sthib 	a.a_cnp = cnp;
9657593ff0Sthib 	a.a_vap = vap;
9757593ff0Sthib 
9857593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
9957593ff0Sthib 
10057593ff0Sthib 	if (dvp->v_op->vop_create == NULL)
101c89ed189Sthib 		return (EOPNOTSUPP);
102c89ed189Sthib 
103f4904628Sclaudio 	return ((dvp->v_op->vop_create)(&a));
10457593ff0Sthib }
10557593ff0Sthib 
10657593ff0Sthib int
VOP_MKNOD(struct vnode * dvp,struct vnode ** vpp,struct componentname * cnp,struct vattr * vap)10757593ff0Sthib VOP_MKNOD(struct vnode *dvp, struct vnode **vpp,
10857593ff0Sthib     struct componentname *cnp, struct vattr *vap)
10957593ff0Sthib {
11057593ff0Sthib 	struct vop_mknod_args a;
11157593ff0Sthib 	a.a_dvp = dvp;
11257593ff0Sthib 	a.a_vpp = vpp;
11357593ff0Sthib 	a.a_cnp = cnp;
11457593ff0Sthib 	a.a_vap = vap;
11557593ff0Sthib 
11657593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
11757593ff0Sthib 
11857593ff0Sthib 	if (dvp->v_op->vop_mknod == NULL)
119c89ed189Sthib 		return (EOPNOTSUPP);
120c89ed189Sthib 
121f4904628Sclaudio 	return ((dvp->v_op->vop_mknod)(&a));
12257593ff0Sthib }
12357593ff0Sthib 
12457593ff0Sthib int
VOP_OPEN(struct vnode * vp,int mode,struct ucred * cred,struct proc * p)12557593ff0Sthib VOP_OPEN(struct vnode *vp, int mode, struct ucred *cred, struct proc *p)
12657593ff0Sthib {
12757593ff0Sthib 	struct vop_open_args a;
12857593ff0Sthib 	a.a_vp = vp;
12957593ff0Sthib 	a.a_mode = mode;
13057593ff0Sthib 	a.a_cred = cred;
13157593ff0Sthib 	a.a_p = p;
13257593ff0Sthib 
1337406c037Smpi 	KASSERT(p == curproc);
1347406c037Smpi 
13557593ff0Sthib 	if (vp->v_op->vop_open == NULL)
136c89ed189Sthib 		return (EOPNOTSUPP);
137c89ed189Sthib 
138f4904628Sclaudio 	return ((vp->v_op->vop_open)(&a));
13957593ff0Sthib }
14057593ff0Sthib 
14157593ff0Sthib int
VOP_CLOSE(struct vnode * vp,int fflag,struct ucred * cred,struct proc * p)14257593ff0Sthib VOP_CLOSE(struct vnode *vp, int fflag, struct ucred *cred, struct proc *p)
14357593ff0Sthib {
14457593ff0Sthib 	struct vop_close_args a;
14557593ff0Sthib 	a.a_vp = vp;
14657593ff0Sthib 	a.a_fflag = fflag;
14757593ff0Sthib 	a.a_cred = cred;
14857593ff0Sthib 	a.a_p = p;
14957593ff0Sthib 
1507406c037Smpi 	KASSERT(p == NULL || p == curproc);
15157593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
15257593ff0Sthib 
15357593ff0Sthib 	if (vp->v_op->vop_close == NULL)
154c89ed189Sthib 		return (EOPNOTSUPP);
155c89ed189Sthib 
156f4904628Sclaudio 	return ((vp->v_op->vop_close)(&a));
15757593ff0Sthib }
15857593ff0Sthib 
15957593ff0Sthib int
VOP_ACCESS(struct vnode * vp,int mode,struct ucred * cred,struct proc * p)16057593ff0Sthib VOP_ACCESS(struct vnode *vp, int mode, struct ucred *cred, struct proc *p)
16157593ff0Sthib {
16257593ff0Sthib 	struct vop_access_args a;
16357593ff0Sthib 	a.a_vp = vp;
16457593ff0Sthib 	a.a_mode = mode;
16557593ff0Sthib 	a.a_cred = cred;
16657593ff0Sthib 	a.a_p = p;
16757593ff0Sthib 
1687406c037Smpi 	KASSERT(p == curproc);
16957593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
17057593ff0Sthib 
17157593ff0Sthib 	if (vp->v_op->vop_access == NULL)
172c89ed189Sthib 		return (EOPNOTSUPP);
173c89ed189Sthib 
17457593ff0Sthib 	return ((vp->v_op->vop_access)(&a));
17557593ff0Sthib }
17657593ff0Sthib 
17757593ff0Sthib int
VOP_GETATTR(struct vnode * vp,struct vattr * vap,struct ucred * cred,struct proc * p)17857593ff0Sthib VOP_GETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred,
17957593ff0Sthib     struct proc *p)
18057593ff0Sthib {
18157593ff0Sthib 	struct vop_getattr_args a;
18257593ff0Sthib 	a.a_vp = vp;
18357593ff0Sthib 	a.a_vap = vap;
18457593ff0Sthib 	a.a_cred = cred;
18557593ff0Sthib 	a.a_p = p;
18657593ff0Sthib 
1877406c037Smpi 	KASSERT(p == curproc);
18857593ff0Sthib 	if (vp->v_op->vop_getattr == NULL)
189c89ed189Sthib 		return (EOPNOTSUPP);
190c89ed189Sthib 
19157593ff0Sthib 	return ((vp->v_op->vop_getattr)(&a));
19257593ff0Sthib }
19357593ff0Sthib 
19457593ff0Sthib int
VOP_SETATTR(struct vnode * vp,struct vattr * vap,struct ucred * cred,struct proc * p)19557593ff0Sthib VOP_SETATTR(struct vnode *vp, struct vattr *vap, struct ucred *cred,
19657593ff0Sthib     struct proc *p)
19757593ff0Sthib {
19857593ff0Sthib 	struct vop_setattr_args a;
19957593ff0Sthib 	a.a_vp = vp;
20057593ff0Sthib 	a.a_vap = vap;
20157593ff0Sthib 	a.a_cred = cred;
20257593ff0Sthib 	a.a_p = p;
20357593ff0Sthib 
2047406c037Smpi 	KASSERT(p == curproc);
20557593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
20657593ff0Sthib 
20757593ff0Sthib 	if (vp->v_op->vop_setattr == NULL)
208c89ed189Sthib 		return (EOPNOTSUPP);
209c89ed189Sthib 
210f4904628Sclaudio 	return ((vp->v_op->vop_setattr)(&a));
21157593ff0Sthib }
21257593ff0Sthib 
21357593ff0Sthib int
VOP_READ(struct vnode * vp,struct uio * uio,int ioflag,struct ucred * cred)21457593ff0Sthib VOP_READ(struct vnode *vp, struct uio *uio, int ioflag, struct ucred *cred)
21557593ff0Sthib {
21657593ff0Sthib 	struct vop_read_args a;
21757593ff0Sthib 	a.a_vp = vp;
21857593ff0Sthib 	a.a_uio = uio;
21957593ff0Sthib 	a.a_ioflag = ioflag;
22057593ff0Sthib 	a.a_cred = cred;
22157593ff0Sthib 
22257593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
22357593ff0Sthib 
22457593ff0Sthib 	if (vp->v_op->vop_read == NULL)
225c89ed189Sthib 		return (EOPNOTSUPP);
226c89ed189Sthib 
22757593ff0Sthib 	return ((vp->v_op->vop_read)(&a));
22857593ff0Sthib }
22957593ff0Sthib 
23057593ff0Sthib int
VOP_WRITE(struct vnode * vp,struct uio * uio,int ioflag,struct ucred * cred)23157593ff0Sthib VOP_WRITE(struct vnode *vp, struct uio *uio, int ioflag,
23257593ff0Sthib     struct ucred *cred)
23357593ff0Sthib {
23457593ff0Sthib 	struct vop_write_args a;
23557593ff0Sthib 	a.a_vp = vp;
23657593ff0Sthib 	a.a_uio = uio;
23757593ff0Sthib 	a.a_ioflag = ioflag;
23857593ff0Sthib 	a.a_cred = cred;
23957593ff0Sthib 
24057593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
24157593ff0Sthib 
24257593ff0Sthib 	if (vp->v_op->vop_write == NULL)
243c89ed189Sthib 		return (EOPNOTSUPP);
244c89ed189Sthib 
245f4904628Sclaudio 	return ((vp->v_op->vop_write)(&a));
24657593ff0Sthib }
24757593ff0Sthib 
24857593ff0Sthib int
VOP_IOCTL(struct vnode * vp,u_long command,void * data,int fflag,struct ucred * cred,struct proc * p)24957593ff0Sthib VOP_IOCTL(struct vnode *vp, u_long command, void *data, int fflag,
25057593ff0Sthib     struct ucred *cred, struct proc *p)
25157593ff0Sthib {
25257593ff0Sthib 	struct vop_ioctl_args a;
25357593ff0Sthib 	a.a_vp = vp;
25457593ff0Sthib 	a.a_command = command;
25557593ff0Sthib 	a.a_data = data;
25657593ff0Sthib 	a.a_fflag = fflag;
25757593ff0Sthib 	a.a_cred = cred;
25857593ff0Sthib 	a.a_p = p;
25957593ff0Sthib 
2607406c037Smpi 	KASSERT(p == curproc);
26157593ff0Sthib 	if (vp->v_op->vop_ioctl == NULL)
262c89ed189Sthib 		return (EOPNOTSUPP);
263c89ed189Sthib 
264f4904628Sclaudio 	return ((vp->v_op->vop_ioctl)(&a));
26557593ff0Sthib }
26657593ff0Sthib 
26757593ff0Sthib int
VOP_KQFILTER(struct vnode * vp,int fflag,struct knote * kn)268f7744361Smpi VOP_KQFILTER(struct vnode *vp, int fflag, struct knote *kn)
26957593ff0Sthib {
27057593ff0Sthib 	struct vop_kqfilter_args a;
27157593ff0Sthib 	a.a_vp = vp;
272f7744361Smpi 	a.a_fflag = fflag;
27357593ff0Sthib 	a.a_kn = kn;
27457593ff0Sthib 
27557593ff0Sthib 	if (vp->v_op->vop_kqfilter == NULL)
276c89ed189Sthib 		return (EOPNOTSUPP);
277c89ed189Sthib 
27857593ff0Sthib 	return ((vp->v_op->vop_kqfilter)(&a));
27957593ff0Sthib }
28057593ff0Sthib 
28157593ff0Sthib int
VOP_REVOKE(struct vnode * vp,int flags)28257593ff0Sthib VOP_REVOKE(struct vnode *vp, int flags)
28357593ff0Sthib {
28457593ff0Sthib 	struct vop_revoke_args a;
28557593ff0Sthib 	a.a_vp = vp;
28657593ff0Sthib 	a.a_flags = flags;
28757593ff0Sthib 
28857593ff0Sthib 	if (vp->v_op->vop_revoke == NULL)
289c89ed189Sthib 		return (EOPNOTSUPP);
290c89ed189Sthib 
29157593ff0Sthib 	return ((vp->v_op->vop_revoke)(&a));
29257593ff0Sthib }
29357593ff0Sthib 
29457593ff0Sthib int
VOP_FSYNC(struct vnode * vp,struct ucred * cred,int waitfor,struct proc * p)29557593ff0Sthib VOP_FSYNC(struct vnode *vp, struct ucred *cred, int waitfor,
29657593ff0Sthib     struct proc *p)
29757593ff0Sthib {
2987e472e55Stedu 	int r, s;
29957593ff0Sthib 	struct vop_fsync_args a;
30057593ff0Sthib 	a.a_vp = vp;
30157593ff0Sthib 	a.a_cred = cred;
30257593ff0Sthib 	a.a_waitfor = waitfor;
30357593ff0Sthib 	a.a_p = p;
30457593ff0Sthib 
3057406c037Smpi 	KASSERT(p == curproc);
30657593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
30757593ff0Sthib 
30857593ff0Sthib 	if (vp->v_op->vop_fsync == NULL)
309c89ed189Sthib 		return (EOPNOTSUPP);
310c89ed189Sthib 
311976e9839Sderaadt 	r = (vp->v_op->vop_fsync)(&a);
3127e472e55Stedu 	s = splbio();
3137e472e55Stedu 	if (r == 0 && vp->v_bioflag & VBIOERROR)
3147e472e55Stedu 		r = EIO;
3157e472e55Stedu 	splx(s);
316976e9839Sderaadt 	return r;
31757593ff0Sthib }
31857593ff0Sthib 
31957593ff0Sthib int
VOP_REMOVE(struct vnode * dvp,struct vnode * vp,struct componentname * cnp)32057593ff0Sthib VOP_REMOVE(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
32157593ff0Sthib {
322*aa47c49aSsemarie 	int error;
32357593ff0Sthib 	struct vop_remove_args a;
32457593ff0Sthib 	a.a_dvp = dvp;
32557593ff0Sthib         a.a_vp = vp;
32657593ff0Sthib 	a.a_cnp = cnp;
32757593ff0Sthib 
32857593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
32957593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
33057593ff0Sthib 
331*aa47c49aSsemarie 	error = dvp->v_op->vop_remove(&a);
332c89ed189Sthib 
333*aa47c49aSsemarie 	if (dvp == vp)
334*aa47c49aSsemarie 		vrele(vp);
335*aa47c49aSsemarie 	else
336*aa47c49aSsemarie 		vput(vp);
337*aa47c49aSsemarie 	vput(dvp);
338*aa47c49aSsemarie 
339*aa47c49aSsemarie 	return error;
34057593ff0Sthib }
34157593ff0Sthib 
34257593ff0Sthib int
VOP_LINK(struct vnode * dvp,struct vnode * vp,struct componentname * cnp)34357593ff0Sthib VOP_LINK(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
34457593ff0Sthib {
34557593ff0Sthib 	struct vop_link_args a;
34657593ff0Sthib 	a.a_dvp = dvp;
34757593ff0Sthib 	a.a_vp = vp;
34857593ff0Sthib 	a.a_cnp = cnp;
34957593ff0Sthib 
35057593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
35157593ff0Sthib 
35257593ff0Sthib 	if (dvp->v_op->vop_link == NULL)
353c89ed189Sthib 		return (EOPNOTSUPP);
354c89ed189Sthib 
355f4904628Sclaudio 	return ((dvp->v_op->vop_link)(&a));
35657593ff0Sthib }
35757593ff0Sthib 
35857593ff0Sthib int
VOP_RENAME(struct vnode * fdvp,struct vnode * fvp,struct componentname * fcnp,struct vnode * tdvp,struct vnode * tvp,struct componentname * tcnp)35957593ff0Sthib VOP_RENAME(struct vnode *fdvp, struct vnode *fvp,
36057593ff0Sthib     struct componentname *fcnp, struct vnode *tdvp, struct vnode *tvp,
36157593ff0Sthib     struct componentname *tcnp)
36257593ff0Sthib {
36357593ff0Sthib 	struct vop_rename_args a;
36457593ff0Sthib 	a.a_fdvp = fdvp;
36557593ff0Sthib 	a.a_fvp = fvp;
36657593ff0Sthib 	a.a_fcnp = fcnp;
36757593ff0Sthib 	a.a_tdvp = tdvp;
36857593ff0Sthib 	a.a_tvp = tvp;
36957593ff0Sthib 	a.a_tcnp = tcnp;
37057593ff0Sthib 
37157593ff0Sthib 	ASSERT_VP_ISLOCKED(tdvp);
37257593ff0Sthib 
37357593ff0Sthib 	if (fdvp->v_op->vop_rename == NULL)
374c89ed189Sthib 		return (EOPNOTSUPP);
375c89ed189Sthib 
376f4904628Sclaudio 	return ((fdvp->v_op->vop_rename)(&a));
37757593ff0Sthib }
37857593ff0Sthib 
37957593ff0Sthib int
VOP_MKDIR(struct vnode * dvp,struct vnode ** vpp,struct componentname * cnp,struct vattr * vap)38057593ff0Sthib VOP_MKDIR(struct vnode *dvp, struct vnode **vpp,
38157593ff0Sthib     struct componentname *cnp, struct vattr *vap)
38257593ff0Sthib {
38357593ff0Sthib 	struct vop_mkdir_args a;
38457593ff0Sthib 	a.a_dvp = dvp;
38557593ff0Sthib 	a.a_vpp = vpp;
38657593ff0Sthib 	a.a_cnp = cnp;
38757593ff0Sthib 	a.a_vap = vap;
38857593ff0Sthib 
38957593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
39057593ff0Sthib 
39157593ff0Sthib 	if (dvp->v_op->vop_mkdir == NULL)
392c89ed189Sthib 		return (EOPNOTSUPP);
393c89ed189Sthib 
394f4904628Sclaudio 	return ((dvp->v_op->vop_mkdir)(&a));
39557593ff0Sthib }
39657593ff0Sthib 
39757593ff0Sthib int
VOP_RMDIR(struct vnode * dvp,struct vnode * vp,struct componentname * cnp)39857593ff0Sthib VOP_RMDIR(struct vnode *dvp, struct vnode *vp, struct componentname *cnp)
39957593ff0Sthib {
40057593ff0Sthib 	struct vop_rmdir_args a;
40157593ff0Sthib 	a.a_dvp = dvp;
40257593ff0Sthib 	a.a_vp = vp;
40357593ff0Sthib 	a.a_cnp = cnp;
40457593ff0Sthib 
40557593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
40657593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
40757593ff0Sthib 
4085ff674a5Svisa 	KASSERT(dvp != vp);
4095ff674a5Svisa 
41057593ff0Sthib 	if (dvp->v_op->vop_rmdir == NULL)
411c89ed189Sthib 		return (EOPNOTSUPP);
412c89ed189Sthib 
413f4904628Sclaudio 	return ((dvp->v_op->vop_rmdir)(&a));
41457593ff0Sthib }
41557593ff0Sthib 
41657593ff0Sthib int
VOP_SYMLINK(struct vnode * dvp,struct vnode ** vpp,struct componentname * cnp,struct vattr * vap,char * target)41757593ff0Sthib VOP_SYMLINK(struct vnode *dvp, struct vnode **vpp,
41857593ff0Sthib     struct componentname *cnp, struct vattr *vap, char *target)
41957593ff0Sthib {
42057593ff0Sthib 	struct vop_symlink_args a;
42157593ff0Sthib 	a.a_dvp = dvp;
42257593ff0Sthib 	a.a_vpp = vpp;
42357593ff0Sthib 	a.a_cnp = cnp;
42457593ff0Sthib 	a.a_vap = vap;
42557593ff0Sthib 	a.a_target = target;
42657593ff0Sthib 
42757593ff0Sthib 	ASSERT_VP_ISLOCKED(dvp);
42857593ff0Sthib 
42957593ff0Sthib 	if (dvp->v_op->vop_symlink == NULL)
430c89ed189Sthib 		return (EOPNOTSUPP);
431c89ed189Sthib 
432f4904628Sclaudio 	return ((dvp->v_op->vop_symlink)(&a));
43357593ff0Sthib }
43457593ff0Sthib 
43557593ff0Sthib int
VOP_READDIR(struct vnode * vp,struct uio * uio,struct ucred * cred,int * eofflag)43657593ff0Sthib VOP_READDIR(struct vnode *vp, struct uio *uio, struct ucred *cred,
43791a535ffSguenther     int *eofflag)
43857593ff0Sthib {
43957593ff0Sthib 	struct vop_readdir_args a;
44057593ff0Sthib 	a.a_vp = vp;
44157593ff0Sthib 	a.a_uio = uio;
44257593ff0Sthib 	a.a_cred = cred;
44357593ff0Sthib 	a.a_eofflag = eofflag;
44457593ff0Sthib 
44557593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
44657593ff0Sthib 
44757593ff0Sthib 	if (vp->v_op->vop_readdir == NULL)
448c89ed189Sthib 		return (EOPNOTSUPP);
449c89ed189Sthib 
450f4904628Sclaudio 	return ((vp->v_op->vop_readdir)(&a));
45157593ff0Sthib }
45257593ff0Sthib 
45357593ff0Sthib int
VOP_READLINK(struct vnode * vp,struct uio * uio,struct ucred * cred)45457593ff0Sthib VOP_READLINK(struct vnode *vp, struct uio *uio, struct ucred *cred)
45557593ff0Sthib {
45657593ff0Sthib 	struct vop_readlink_args a;
45757593ff0Sthib 	a.a_vp = vp;
45857593ff0Sthib 	a.a_uio = uio;
45957593ff0Sthib 	a.a_cred = cred;
46057593ff0Sthib 
46157593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
46257593ff0Sthib 
46357593ff0Sthib 	if (vp->v_op->vop_readlink == NULL)
464c89ed189Sthib 		return (EOPNOTSUPP);
465c89ed189Sthib 
466f4904628Sclaudio 	return ((vp->v_op->vop_readlink)(&a));
46757593ff0Sthib }
46857593ff0Sthib 
46957593ff0Sthib int
VOP_ABORTOP(struct vnode * dvp,struct componentname * cnp)47057593ff0Sthib VOP_ABORTOP(struct vnode *dvp, struct componentname *cnp)
47157593ff0Sthib {
47257593ff0Sthib 	struct vop_abortop_args a;
47357593ff0Sthib 	a.a_dvp = dvp;
47457593ff0Sthib 	a.a_cnp = cnp;
47557593ff0Sthib 
47657593ff0Sthib 	if (dvp->v_op->vop_abortop == NULL)
477c89ed189Sthib 		return (EOPNOTSUPP);
478c89ed189Sthib 
479f4904628Sclaudio 	return ((dvp->v_op->vop_abortop)(&a));
48057593ff0Sthib }
48157593ff0Sthib 
48257593ff0Sthib int
VOP_INACTIVE(struct vnode * vp,struct proc * p)48357593ff0Sthib VOP_INACTIVE(struct vnode *vp, struct proc *p)
48457593ff0Sthib {
48557593ff0Sthib 	struct vop_inactive_args a;
48657593ff0Sthib 	a.a_vp = vp;
48757593ff0Sthib 	a.a_p = p;
48857593ff0Sthib 
4897406c037Smpi 	KASSERT(p == curproc);
49057593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
49157593ff0Sthib 
49257593ff0Sthib 	if (vp->v_op->vop_inactive == NULL)
493c89ed189Sthib 		return (EOPNOTSUPP);
494c89ed189Sthib 
49557593ff0Sthib 	return ((vp->v_op->vop_inactive)(&a));
49657593ff0Sthib }
49757593ff0Sthib 
49857593ff0Sthib int
VOP_RECLAIM(struct vnode * vp,struct proc * p)49957593ff0Sthib VOP_RECLAIM(struct vnode *vp, struct proc *p)
50057593ff0Sthib {
50157593ff0Sthib 	struct vop_reclaim_args a;
50257593ff0Sthib 	a.a_vp = vp;
50357593ff0Sthib 	a.a_p = p;
50457593ff0Sthib 
5057406c037Smpi 	KASSERT(p == curproc);
50657593ff0Sthib 	if (vp->v_op->vop_reclaim == NULL)
507c89ed189Sthib 		return (EOPNOTSUPP);
508c89ed189Sthib 
509f4904628Sclaudio 	return ((vp->v_op->vop_reclaim)(&a));
51057593ff0Sthib }
51157593ff0Sthib 
51257593ff0Sthib int
VOP_LOCK(struct vnode * vp,int flags)51336bb23f1Svisa VOP_LOCK(struct vnode *vp, int flags)
51457593ff0Sthib {
51557593ff0Sthib 	struct vop_lock_args a;
51657593ff0Sthib 	a.a_vp = vp;
51757593ff0Sthib 	a.a_flags = flags;
51857593ff0Sthib 
5199d6122f6Sclaudio 	MUTEX_ASSERT_UNLOCKED(&vnode_mtx);
5209d6122f6Sclaudio 
52157593ff0Sthib 	if (vp->v_op->vop_lock == NULL)
522c89ed189Sthib 		return (EOPNOTSUPP);
523c89ed189Sthib 
52457593ff0Sthib 	return ((vp->v_op->vop_lock)(&a));
52557593ff0Sthib }
52657593ff0Sthib 
52757593ff0Sthib int
VOP_UNLOCK(struct vnode * vp)52836bb23f1Svisa VOP_UNLOCK(struct vnode *vp)
52957593ff0Sthib {
53057593ff0Sthib 	struct vop_unlock_args a;
53157593ff0Sthib 	a.a_vp = vp;
53257593ff0Sthib 
53357593ff0Sthib 	if (vp->v_op->vop_unlock == NULL)
534c89ed189Sthib 		return (EOPNOTSUPP);
535c89ed189Sthib 
536bd673e62Sclaudio 	return ((vp->v_op->vop_unlock)(&a));
53757593ff0Sthib }
53857593ff0Sthib 
53957593ff0Sthib int
VOP_BMAP(struct vnode * vp,daddr_t bn,struct vnode ** vpp,daddr_t * bnp,int * runp)5401abdbfdeSderaadt VOP_BMAP(struct vnode *vp, daddr_t bn, struct vnode **vpp,
5411abdbfdeSderaadt     daddr_t *bnp, int *runp)
54257593ff0Sthib {
54357593ff0Sthib 	struct vop_bmap_args a;
54457593ff0Sthib 	a.a_vp = vp;
54557593ff0Sthib 	a.a_bn = bn;
54657593ff0Sthib 	a.a_vpp = vpp;
54757593ff0Sthib 	a.a_bnp = bnp;
54857593ff0Sthib 	a.a_runp = runp;
54957593ff0Sthib 
55057593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
55157593ff0Sthib 
55257593ff0Sthib 	if (vp->v_op->vop_bmap == NULL)
553c89ed189Sthib 		return (EOPNOTSUPP);
554c89ed189Sthib 
55557593ff0Sthib 	return ((vp->v_op->vop_bmap)(&a));
55657593ff0Sthib }
55757593ff0Sthib 
55857593ff0Sthib int
VOP_PRINT(struct vnode * vp)55957593ff0Sthib VOP_PRINT(struct vnode *vp)
56057593ff0Sthib {
56157593ff0Sthib 	struct vop_print_args a;
56257593ff0Sthib 	a.a_vp = vp;
56357593ff0Sthib 
56457593ff0Sthib 	if (vp->v_op->vop_print == NULL)
565c89ed189Sthib 		return (EOPNOTSUPP);
566c89ed189Sthib 
56757593ff0Sthib 	return ((vp->v_op->vop_print)(&a));
56857593ff0Sthib }
56957593ff0Sthib 
57057593ff0Sthib int
VOP_PATHCONF(struct vnode * vp,int name,register_t * retval)57157593ff0Sthib VOP_PATHCONF(struct vnode *vp, int name, register_t *retval)
57257593ff0Sthib {
57357593ff0Sthib 	struct vop_pathconf_args a;
5745540ae66Sguenther 
5755540ae66Sguenther 	/*
5765540ae66Sguenther 	 * Handle names that are constant across filesystem
5775540ae66Sguenther 	 */
5785540ae66Sguenther 	switch (name) {
5795540ae66Sguenther 	case _PC_PATH_MAX:
5805540ae66Sguenther 		*retval = PATH_MAX;
5815540ae66Sguenther 		return (0);
5825540ae66Sguenther 	case _PC_PIPE_BUF:
5835540ae66Sguenther 		*retval = PIPE_BUF;
5845540ae66Sguenther 		return (0);
5855540ae66Sguenther 	case _PC_ASYNC_IO:
5865540ae66Sguenther 	case _PC_PRIO_IO:
5875540ae66Sguenther 	case _PC_SYNC_IO:
5885540ae66Sguenther 		*retval = 0;
5895540ae66Sguenther 		return (0);
5905540ae66Sguenther 
5915540ae66Sguenther 	}
5925540ae66Sguenther 
59357593ff0Sthib 	a.a_vp = vp;
59457593ff0Sthib 	a.a_name = name;
59557593ff0Sthib 	a.a_retval = retval;
59657593ff0Sthib 
59757593ff0Sthib 	ASSERT_VP_ISLOCKED(vp);
59857593ff0Sthib 
59957593ff0Sthib 	if (vp->v_op->vop_pathconf == NULL)
600c89ed189Sthib 		return (EOPNOTSUPP);
601c89ed189Sthib 
60257593ff0Sthib 	return ((vp->v_op->vop_pathconf)(&a));
60357593ff0Sthib }
60457593ff0Sthib 
60557593ff0Sthib int
VOP_ADVLOCK(struct vnode * vp,void * id,int op,struct flock * fl,int flags)60657593ff0Sthib VOP_ADVLOCK(struct vnode *vp, void *id, int op, struct flock *fl, int flags)
60757593ff0Sthib {
60857593ff0Sthib 	struct vop_advlock_args a;
60957593ff0Sthib 	a.a_vp = vp;
61057593ff0Sthib 	a.a_id = id;
61157593ff0Sthib 	a.a_op = op;
61257593ff0Sthib 	a.a_fl = fl;
61357593ff0Sthib 	a.a_flags = flags;
61457593ff0Sthib 
61557593ff0Sthib 	if (vp->v_op->vop_advlock == NULL)
616c89ed189Sthib 		return (EOPNOTSUPP);
617c89ed189Sthib 
618d0403264Svisa 	return (vp->v_op->vop_advlock)(&a);
61957593ff0Sthib }
62057593ff0Sthib 
62157593ff0Sthib int
VOP_STRATEGY(struct vnode * vp,struct buf * bp)622f1993be3Svisa VOP_STRATEGY(struct vnode *vp, struct buf *bp)
62357593ff0Sthib {
62457593ff0Sthib 	struct vop_strategy_args a;
625f1993be3Svisa 	a.a_vp = vp;
62657593ff0Sthib 	a.a_bp = bp;
62757593ff0Sthib 
6281d9ad96eSbeck 	if ((ISSET(bp->b_flags, B_BC)) && (!ISSET(bp->b_flags, B_DMA)))
6291d9ad96eSbeck 		panic("Non dma reachable buffer passed to VOP_STRATEGY");
6301d9ad96eSbeck 
631f1993be3Svisa 	if (vp->v_op->vop_strategy == NULL)
632c89ed189Sthib 		return (EOPNOTSUPP);
633c89ed189Sthib 
634f1993be3Svisa 	return ((vp->v_op->vop_strategy)(&a));
63557593ff0Sthib }
63657593ff0Sthib 
63757593ff0Sthib int
VOP_BWRITE(struct buf * bp)63857593ff0Sthib VOP_BWRITE(struct buf *bp)
63957593ff0Sthib {
64057593ff0Sthib 	struct vop_bwrite_args a;
64157593ff0Sthib 	a.a_bp = bp;
64257593ff0Sthib 
64357593ff0Sthib 	if (bp->b_vp->v_op->vop_bwrite == NULL)
644c89ed189Sthib 		return (EOPNOTSUPP);
645c89ed189Sthib 
64657593ff0Sthib 	return ((bp->b_vp->v_op->vop_bwrite)(&a));
64757593ff0Sthib }
648