3 * Copyright (c) 2004 The DragonFly Project. All rights reserved.
5 * This code is derived from software contributed to The DragonFly Project
6 * by Matthew Dillon <dillon@backplane.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in
16 * the documentation and/or other materials provided with the
18 * 3. Neither the name of The DragonFly Project nor the names of its
19 * contributors may be used to endorse or promote products derived
20 * from this software without specific, prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
28 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
30 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
31 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * $DragonFly: src/sys/kern/vfs_vopops.c,v 1.13 2004/12/29 02:40:02 dillon Exp $
38 #include <sys/param.h>
39 #include <sys/systm.h>
42 #include <sys/dirent.h>
43 #include <sys/domain.h>
44 #include <sys/eventhandler.h>
45 #include <sys/fcntl.h>
46 #include <sys/kernel.h>
47 #include <sys/kthread.h>
48 #include <sys/malloc.h>
50 #include <sys/mount.h>
52 #include <sys/namei.h>
53 #include <sys/reboot.h>
54 #include <sys/socket.h>
56 #include <sys/sysctl.h>
57 #include <sys/syslog.h>
58 #include <sys/vmmeter.h>
59 #include <sys/vnode.h>
60 #include <sys/vfsops.h>
62 #include <machine/limits.h>
65 #include <vm/vm_object.h>
66 #include <vm/vm_extern.h>
67 #include <vm/vm_kern.h>
69 #include <vm/vm_map.h>
70 #include <vm/vm_page.h>
71 #include <vm/vm_pager.h>
72 #include <vm/vnode_pager.h>
73 #include <vm/vm_zone.h>
76 #include <sys/thread2.h>
78 #define VOFFNAME(name) __CONCAT(__CONCAT(vop_,name),_vp_offsets)
79 #define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
80 #define VARGSSTRUCT(name) struct __CONCAT(__CONCAT(vop_,name),_args)
82 #define VNODEOP_DESC_INIT(name, flags, vpoffs, vpp, cred, proc, comp) \
83 struct vnodeop_desc VDESCNAME(name) = { \
84 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
85 #name, flags, vpoffs, vpp, cred, proc, comp }
87 #define VNODEOP_DESC_INIT_SIMPLE(name) \
88 VNODEOP_DESC_INIT(name, 0, NULL, \
94 #define VNODEOP_DESC_INIT_VP(name) \
95 static int VOFFNAME(name)[] = { \
96 __offsetof(VARGSSTRUCT(name), a_vp), \
98 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
104 #define VNODEOP_DESC_INIT_VP_VPP(name) \
105 static int VOFFNAME(name)[] = { \
106 __offsetof(VARGSSTRUCT(name), a_vp), \
108 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
109 __offsetof(VARGSSTRUCT(name), a_vpp), \
114 #define VNODEOP_DESC_INIT_VP_CRED(name) \
115 static int VOFFNAME(name)[] = { \
116 __offsetof(VARGSSTRUCT(name), a_vp), \
118 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
120 __offsetof(VARGSSTRUCT(name), a_cred), \
124 #define VNODEOP_DESC_INIT_NCP(name) \
125 VNODEOP_DESC_INIT(name, 0, NULL, \
131 #define VNODEOP_DESC_INIT_NCP2_CRED(name) \
132 VNODEOP_DESC_INIT(name, 0, NULL, \
134 __offsetof(VARGSSTRUCT(name), a_cred), \
138 #define VNODEOP_DESC_INIT_NCP_CRED(name) \
139 VNODEOP_DESC_INIT(name, 0, NULL, \
141 __offsetof(VARGSSTRUCT(name), a_cred), \
145 #define VNODEOP_DESC_INIT_NCP_VP_CRED(name) \
146 static int VOFFNAME(name)[] = { \
147 __offsetof(VARGSSTRUCT(name), a_vp), \
149 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
151 __offsetof(VARGSSTRUCT(name), a_cred), \
155 #define VNODEOP_DESC_INIT_NCP_CRED_VPP(name) \
156 VNODEOP_DESC_INIT(name, 0, NULL, \
157 __offsetof(VARGSSTRUCT(name), a_vpp), \
158 __offsetof(VARGSSTRUCT(name), a_cred), \
162 #define VNODEOP_DESC_INIT_DVP_VPP_CNP(name) \
163 static int VOFFNAME(name)[] = { \
164 __offsetof(VARGSSTRUCT(name), a_dvp), \
166 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
167 __offsetof(VARGSSTRUCT(name), a_vpp), \
170 __offsetof(VARGSSTRUCT(name), a_cnp))
172 #define VNODEOP_DESC_INIT_DVP_VPP_CRED(name) \
173 static int VOFFNAME(name)[] = { \
174 __offsetof(VARGSSTRUCT(name), a_dvp), \
176 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
177 __offsetof(VARGSSTRUCT(name), a_vpp), \
178 __offsetof(VARGSSTRUCT(name), a_cred), \
182 #define VNODEOP_DESC_INIT_DVP_CNP(name) \
183 static int VOFFNAME(name)[] = { \
184 __offsetof(VARGSSTRUCT(name), a_dvp), \
186 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
190 __offsetof(VARGSSTRUCT(name), a_cnp))
192 #define VNODEOP_DESC_INIT_DVP_VP_CNP(name) \
193 static int VOFFNAME(name)[] = { \
194 __offsetof(VARGSSTRUCT(name), a_dvp), \
195 __offsetof(VARGSSTRUCT(name), a_vp), \
197 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
201 __offsetof(VARGSSTRUCT(name), a_cnp))
203 #define VNODEOP_DESC_INIT_TDVP_VP_CNP(name) \
204 static int VOFFNAME(name)[] = { \
205 __offsetof(VARGSSTRUCT(name), a_tdvp), \
206 __offsetof(VARGSSTRUCT(name), a_vp), \
208 VNODEOP_DESC_INIT(name, 0, VOFFNAME(name), \
212 __offsetof(VARGSSTRUCT(name), a_cnp))
214 VNODEOP_DESC_INIT_SIMPLE(default);
215 VNODEOP_DESC_INIT_VP(islocked);
216 VNODEOP_DESC_INIT_DVP_VPP_CNP(lookup);
217 VNODEOP_DESC_INIT_DVP_VPP_CNP(create);
218 VNODEOP_DESC_INIT_DVP_CNP(whiteout);
219 VNODEOP_DESC_INIT_DVP_VPP_CNP(mknod);
220 VNODEOP_DESC_INIT_VP_CRED(open);
221 VNODEOP_DESC_INIT_VP(close);
222 VNODEOP_DESC_INIT_VP_CRED(access);
223 VNODEOP_DESC_INIT_VP(getattr);
224 VNODEOP_DESC_INIT_VP_CRED(setattr);
225 VNODEOP_DESC_INIT_VP_CRED(read);
226 VNODEOP_DESC_INIT_VP_CRED(write);
227 VNODEOP_DESC_INIT_VP_CRED(lease);
228 VNODEOP_DESC_INIT_VP_CRED(ioctl);
229 VNODEOP_DESC_INIT_VP_CRED(poll);
230 VNODEOP_DESC_INIT_VP(kqfilter);
231 VNODEOP_DESC_INIT_VP(revoke);
232 VNODEOP_DESC_INIT_VP_CRED(mmap);
233 VNODEOP_DESC_INIT_VP(fsync);
234 VNODEOP_DESC_INIT_DVP_VP_CNP(remove);
235 VNODEOP_DESC_INIT_TDVP_VP_CNP(link);
237 static int VOFFNAME(rename)[] = {
238 __offsetof(VARGSSTRUCT(rename), a_fdvp),
239 __offsetof(VARGSSTRUCT(rename), a_fvp),
240 __offsetof(VARGSSTRUCT(rename), a_tdvp),
241 __offsetof(VARGSSTRUCT(rename), a_tvp),
244 VNODEOP_DESC_INIT(rename,
245 VDESC_VP0_WILLRELE|VDESC_VP1_WILLRELE|
246 VDESC_VP2_WILLRELE|VDESC_VP3_WILLRELE|
247 VDESC_VP2_WILLUNLOCK|VDESC_VP3_WILLUNLOCK, /* tdvp and tvp */
252 __offsetof(VARGSSTRUCT(rename), a_fcnp));
254 VNODEOP_DESC_INIT_DVP_VPP_CNP(mkdir);
255 VNODEOP_DESC_INIT_DVP_VP_CNP(rmdir);
256 VNODEOP_DESC_INIT_DVP_VPP_CNP(symlink);
257 VNODEOP_DESC_INIT_VP_CRED(readdir);
258 VNODEOP_DESC_INIT_VP_CRED(readlink);
259 VNODEOP_DESC_INIT_VP(inactive);
260 VNODEOP_DESC_INIT_VP(reclaim);
261 VNODEOP_DESC_INIT_VP(lock);
262 VNODEOP_DESC_INIT_VP(unlock);
263 VNODEOP_DESC_INIT_VP_VPP(bmap);
264 VNODEOP_DESC_INIT_VP(strategy);
265 VNODEOP_DESC_INIT_VP(print);
266 VNODEOP_DESC_INIT_VP(pathconf);
267 VNODEOP_DESC_INIT_VP(advlock);
268 VNODEOP_DESC_INIT_VP_CRED(balloc);
269 VNODEOP_DESC_INIT_VP(reallocblks);
270 VNODEOP_DESC_INIT_VP(getpages);
271 VNODEOP_DESC_INIT_VP(putpages);
272 VNODEOP_DESC_INIT_VP(freeblks);
273 VNODEOP_DESC_INIT_VP(bwrite);
274 VNODEOP_DESC_INIT_VP_CRED(getacl);
275 VNODEOP_DESC_INIT_VP_CRED(setacl);
276 VNODEOP_DESC_INIT_VP_CRED(aclcheck);
277 VNODEOP_DESC_INIT_VP_CRED(getextattr);
278 VNODEOP_DESC_INIT_VP_CRED(setextattr);
279 VNODEOP_DESC_INIT_VP(createvobject);
280 VNODEOP_DESC_INIT_VP(destroyvobject);
281 VNODEOP_DESC_INIT_VP(getvobject);
282 VNODEOP_DESC_INIT_SIMPLE(mountctl);
284 VNODEOP_DESC_INIT_NCP_CRED(nresolve);
285 VNODEOP_DESC_INIT_DVP_VPP_CRED(nlookupdotdot);
286 VNODEOP_DESC_INIT_NCP_CRED_VPP(ncreate);
287 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmkdir);
288 VNODEOP_DESC_INIT_NCP_CRED_VPP(nmknod);
289 VNODEOP_DESC_INIT_NCP_VP_CRED(nlink);
290 VNODEOP_DESC_INIT_NCP_CRED_VPP(nsymlink);
291 VNODEOP_DESC_INIT_NCP_CRED(nwhiteout);
292 VNODEOP_DESC_INIT_NCP_CRED(nremove);
293 VNODEOP_DESC_INIT_NCP_CRED(nrmdir);
294 VNODEOP_DESC_INIT_NCP2_CRED(nrename);
296 #define DO_OPS(ops, error, ap, vop_field) \
297 error = ops->vop_field(ap);
299 /************************************************************************
300 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
301 ************************************************************************
303 * These procedures are called directly from the kernel and/or fileops
304 * code to perform file/device operations on the system.
308 vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
310 struct vop_islocked_args ap;
313 ap.a_head.a_desc = &vop_islocked_desc;
314 ap.a_head.a_ops = ops;
318 DO_OPS(ops, error, &ap, vop_islocked);
323 vop_lookup(struct vop_ops *ops, struct vnode *dvp,
324 struct vnode **vpp, struct componentname *cnp)
326 struct vop_lookup_args ap;
329 ap.a_head.a_desc = &vop_lookup_desc;
330 ap.a_head.a_ops = ops;
335 DO_OPS(ops, error, &ap, vop_lookup);
340 vop_create(struct vop_ops *ops, struct vnode *dvp,
341 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
343 struct vop_create_args ap;
346 ap.a_head.a_desc = &vop_create_desc;
347 ap.a_head.a_ops = ops;
353 DO_OPS(ops, error, &ap, vop_create);
358 vop_whiteout(struct vop_ops *ops, struct vnode *dvp,
359 struct componentname *cnp, int flags)
361 struct vop_whiteout_args ap;
364 ap.a_head.a_desc = &vop_whiteout_desc;
365 ap.a_head.a_ops = ops;
370 DO_OPS(ops, error, &ap, vop_whiteout);
375 vop_mknod(struct vop_ops *ops, struct vnode *dvp,
376 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
378 struct vop_mknod_args ap;
381 ap.a_head.a_desc = &vop_mknod_desc;
382 ap.a_head.a_ops = ops;
388 DO_OPS(ops, error, &ap, vop_mknod);
393 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
394 struct file *fp, struct thread *td)
396 struct vop_open_args ap;
399 ap.a_head.a_desc = &vop_open_desc;
400 ap.a_head.a_ops = ops;
407 DO_OPS(ops, error, &ap, vop_open);
412 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag, struct thread *td)
414 struct vop_close_args ap;
417 ap.a_head.a_desc = &vop_close_desc;
418 ap.a_head.a_ops = ops;
423 DO_OPS(ops, error, &ap, vop_close);
428 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
431 struct vop_access_args ap;
434 ap.a_head.a_desc = &vop_access_desc;
435 ap.a_head.a_ops = ops;
441 DO_OPS(ops, error, &ap, vop_access);
446 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
449 struct vop_getattr_args ap;
452 ap.a_head.a_desc = &vop_getattr_desc;
453 ap.a_head.a_ops = ops;
458 DO_OPS(ops, error, &ap, vop_getattr);
463 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
464 struct ucred *cred, struct thread *td)
466 struct vop_setattr_args ap;
469 ap.a_head.a_desc = &vop_setattr_desc;
470 ap.a_head.a_ops = ops;
476 DO_OPS(ops, error, &ap, vop_setattr);
481 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
484 struct vop_read_args ap;
487 ap.a_head.a_desc = &vop_read_desc;
488 ap.a_head.a_ops = ops;
491 ap.a_ioflag = ioflag;
494 DO_OPS(ops, error, &ap, vop_read);
499 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
502 struct vop_write_args ap;
505 ap.a_head.a_desc = &vop_write_desc;
506 ap.a_head.a_ops = ops;
509 ap.a_ioflag = ioflag;
512 DO_OPS(ops, error, &ap, vop_write);
517 vop_lease(struct vop_ops *ops, struct vnode *vp, struct thread *td,
518 struct ucred *cred, int flag)
520 struct vop_lease_args ap;
523 ap.a_head.a_desc = &vop_lease_desc;
524 ap.a_head.a_ops = ops;
530 DO_OPS(ops, error, &ap, vop_lease);
535 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
536 int fflag, struct ucred *cred,
539 struct vop_ioctl_args ap;
542 ap.a_head.a_desc = &vop_ioctl_desc;
543 ap.a_head.a_ops = ops;
545 ap.a_command = command;
551 DO_OPS(ops, error, &ap, vop_ioctl);
556 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred,
559 struct vop_poll_args ap;
562 ap.a_head.a_desc = &vop_poll_desc;
563 ap.a_head.a_ops = ops;
565 ap.a_events = events;
569 DO_OPS(ops, error, &ap, vop_poll);
574 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
576 struct vop_kqfilter_args ap;
579 ap.a_head.a_desc = &vop_kqfilter_desc;
580 ap.a_head.a_ops = ops;
584 DO_OPS(ops, error, &ap, vop_kqfilter);
589 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
591 struct vop_revoke_args ap;
594 ap.a_head.a_desc = &vop_revoke_desc;
595 ap.a_head.a_ops = ops;
599 DO_OPS(ops, error, &ap, vop_revoke);
604 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred,
607 struct vop_mmap_args ap;
610 ap.a_head.a_desc = &vop_mmap_desc;
611 ap.a_head.a_ops = ops;
613 ap.a_fflags = fflags;
617 DO_OPS(ops, error, &ap, vop_mmap);
622 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, struct thread *td)
624 struct vop_fsync_args ap;
627 ap.a_head.a_desc = &vop_fsync_desc;
628 ap.a_head.a_ops = ops;
630 ap.a_waitfor = waitfor;
633 DO_OPS(ops, error, &ap, vop_fsync);
638 vop_remove(struct vop_ops *ops, struct vnode *dvp,
639 struct vnode *vp, struct componentname *cnp)
641 struct vop_remove_args ap;
644 ap.a_head.a_desc = &vop_remove_desc;
645 ap.a_head.a_ops = ops;
650 DO_OPS(ops, error, &ap, vop_remove);
655 vop_link(struct vop_ops *ops, struct vnode *tdvp,
656 struct vnode *vp, struct componentname *cnp)
658 struct vop_link_args ap;
661 ap.a_head.a_desc = &vop_link_desc;
662 ap.a_head.a_ops = ops;
667 DO_OPS(ops, error, &ap, vop_link);
672 vop_rename(struct vop_ops *ops,
673 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
674 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
676 struct vop_rename_args ap;
679 ap.a_head.a_desc = &vop_rename_desc;
680 ap.a_head.a_ops = ops;
688 DO_OPS(ops, error, &ap, vop_rename);
693 vop_mkdir(struct vop_ops *ops, struct vnode *dvp,
694 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
696 struct vop_mkdir_args ap;
699 ap.a_head.a_desc = &vop_mkdir_desc;
700 ap.a_head.a_ops = ops;
706 DO_OPS(ops, error, &ap, vop_mkdir);
711 vop_rmdir(struct vop_ops *ops, struct vnode *dvp,
712 struct vnode *vp, struct componentname *cnp)
714 struct vop_rmdir_args ap;
717 ap.a_head.a_desc = &vop_rmdir_desc;
718 ap.a_head.a_ops = ops;
723 DO_OPS(ops, error, &ap, vop_rmdir);
728 vop_symlink(struct vop_ops *ops, struct vnode *dvp,
729 struct vnode **vpp, struct componentname *cnp,
730 struct vattr *vap, char *target)
732 struct vop_symlink_args ap;
735 ap.a_head.a_desc = &vop_symlink_desc;
736 ap.a_head.a_ops = ops;
741 ap.a_target = target;
743 DO_OPS(ops, error, &ap, vop_symlink);
748 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
749 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
751 struct vop_readdir_args ap;
754 ap.a_head.a_desc = &vop_readdir_desc;
755 ap.a_head.a_ops = ops;
759 ap.a_eofflag = eofflag;
760 ap.a_ncookies = ncookies;
761 ap.a_cookies = cookies;
763 DO_OPS(ops, error, &ap, vop_readdir);
768 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
771 struct vop_readlink_args ap;
774 ap.a_head.a_desc = &vop_readlink_desc;
775 ap.a_head.a_ops = ops;
780 DO_OPS(ops, error, &ap, vop_readlink);
785 vop_inactive(struct vop_ops *ops, struct vnode *vp, struct thread *td)
787 struct vop_inactive_args ap;
790 ap.a_head.a_desc = &vop_inactive_desc;
791 ap.a_head.a_ops = ops;
795 DO_OPS(ops, error, &ap, vop_inactive);
800 vop_reclaim(struct vop_ops *ops, struct vnode *vp, struct thread *td)
802 struct vop_reclaim_args ap;
805 ap.a_head.a_desc = &vop_reclaim_desc;
806 ap.a_head.a_ops = ops;
810 DO_OPS(ops, error, &ap, vop_reclaim);
815 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
817 struct vop_lock_args ap;
820 ap.a_head.a_desc = &vop_lock_desc;
821 ap.a_head.a_ops = ops;
826 DO_OPS(ops, error, &ap, vop_lock);
831 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags, struct thread *td)
833 struct vop_unlock_args ap;
836 ap.a_head.a_desc = &vop_unlock_desc;
837 ap.a_head.a_ops = ops;
842 DO_OPS(ops, error, &ap, vop_unlock);
847 vop_bmap(struct vop_ops *ops, struct vnode *vp, daddr_t bn, struct vnode **vpp,
848 daddr_t *bnp, int *runp, int *runb)
850 struct vop_bmap_args ap;
853 ap.a_head.a_desc = &vop_bmap_desc;
854 ap.a_head.a_ops = ops;
862 DO_OPS(ops, error, &ap, vop_bmap);
867 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct buf *bp)
869 struct vop_strategy_args ap;
872 ap.a_head.a_desc = &vop_strategy_desc;
873 ap.a_head.a_ops = ops;
877 DO_OPS(ops, error, &ap, vop_strategy);
882 vop_print(struct vop_ops *ops, struct vnode *vp)
884 struct vop_print_args ap;
887 ap.a_head.a_desc = &vop_print_desc;
888 ap.a_head.a_ops = ops;
891 DO_OPS(ops, error, &ap, vop_print);
896 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
899 struct vop_pathconf_args ap;
902 ap.a_head.a_desc = &vop_pathconf_desc;
903 ap.a_head.a_ops = ops;
906 ap.a_retval = retval;
908 DO_OPS(ops, error, &ap, vop_pathconf);
913 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
914 struct flock *fl, int flags)
916 struct vop_advlock_args ap;
919 ap.a_head.a_desc = &vop_advlock_desc;
920 ap.a_head.a_ops = ops;
927 DO_OPS(ops, error, &ap, vop_advlock);
932 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
933 int size, struct ucred *cred, int flags,
936 struct vop_balloc_args ap;
939 ap.a_head.a_desc = &vop_balloc_desc;
940 ap.a_head.a_ops = ops;
942 ap.a_startoffset = startoffset;
948 DO_OPS(ops, error, &ap, vop_balloc);
953 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
954 struct cluster_save *buflist)
956 struct vop_reallocblks_args ap;
959 ap.a_head.a_desc = &vop_reallocblks_desc;
960 ap.a_head.a_ops = ops;
962 ap.a_buflist = buflist;
964 DO_OPS(ops, error, &ap, vop_reallocblks);
969 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
970 int reqpage, vm_ooffset_t offset)
972 struct vop_getpages_args ap;
975 ap.a_head.a_desc = &vop_getpages_desc;
976 ap.a_head.a_ops = ops;
980 ap.a_reqpage = reqpage;
981 ap.a_offset = offset;
983 DO_OPS(ops, error, &ap, vop_getpages);
988 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
989 int sync, int *rtvals, vm_ooffset_t offset)
991 struct vop_putpages_args ap;
994 ap.a_head.a_desc = &vop_putpages_desc;
995 ap.a_head.a_ops = ops;
1000 ap.a_rtvals = rtvals;
1001 ap.a_offset = offset;
1003 DO_OPS(ops, error, &ap, vop_putpages);
1008 vop_freeblks(struct vop_ops *ops, struct vnode *vp,
1009 daddr_t addr, daddr_t length)
1011 struct vop_freeblks_args ap;
1014 ap.a_head.a_desc = &vop_freeblks_desc;
1015 ap.a_head.a_ops = ops;
1018 ap.a_length = length;
1020 DO_OPS(ops, error, &ap, vop_freeblks);
1025 vop_bwrite(struct vop_ops *ops, struct vnode *vp, struct buf *bp)
1027 struct vop_bwrite_args ap;
1030 ap.a_head.a_desc = &vop_bwrite_desc;
1031 ap.a_head.a_ops = ops;
1035 DO_OPS(ops, error, &ap, vop_bwrite);
1040 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1041 struct acl *aclp, struct ucred *cred, struct thread *td)
1043 struct vop_getacl_args ap;
1046 ap.a_head.a_desc = &vop_getacl_desc;
1047 ap.a_head.a_ops = ops;
1054 DO_OPS(ops, error, &ap, vop_getacl);
1059 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1060 struct acl *aclp, struct ucred *cred, struct thread *td)
1062 struct vop_setacl_args ap;
1065 ap.a_head.a_desc = &vop_setacl_desc;
1066 ap.a_head.a_ops = ops;
1073 DO_OPS(ops, error, &ap, vop_setacl);
1078 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
1079 struct acl *aclp, struct ucred *cred, struct thread *td)
1081 struct vop_aclcheck_args ap;
1084 ap.a_head.a_desc = &vop_aclcheck_desc;
1085 ap.a_head.a_ops = ops;
1092 DO_OPS(ops, error, &ap, vop_aclcheck);
1097 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1098 struct uio *uio, struct ucred *cred, struct thread *td)
1100 struct vop_getextattr_args ap;
1103 ap.a_head.a_desc = &vop_getextattr_desc;
1104 ap.a_head.a_ops = ops;
1111 DO_OPS(ops, error, &ap, vop_getextattr);
1116 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
1117 struct uio *uio, struct ucred *cred, struct thread *td)
1119 struct vop_setextattr_args ap;
1122 ap.a_head.a_desc = &vop_setextattr_desc;
1123 ap.a_head.a_ops = ops;
1130 DO_OPS(ops, error, &ap, vop_setextattr);
1135 vop_createvobject(struct vop_ops *ops, struct vnode *vp, struct thread *td)
1137 struct vop_createvobject_args ap;
1140 ap.a_head.a_desc = &vop_createvobject_desc;
1141 ap.a_head.a_ops = ops;
1145 DO_OPS(ops, error, &ap, vop_createvobject);
1150 vop_destroyvobject(struct vop_ops *ops, struct vnode *vp)
1152 struct vop_destroyvobject_args ap;
1155 ap.a_head.a_desc = &vop_destroyvobject_desc;
1156 ap.a_head.a_ops = ops;
1159 DO_OPS(ops, error, &ap, vop_destroyvobject);
1164 vop_getvobject(struct vop_ops *ops, struct vnode *vp, struct vm_object **objpp)
1166 struct vop_getvobject_args ap;
1169 ap.a_head.a_desc = &vop_getvobject_desc;
1170 ap.a_head.a_ops = ops;
1174 DO_OPS(ops, error, &ap, vop_getvobject);
1179 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
1180 const void *ctl, int ctllen, void *buf, int buflen, int *res)
1182 struct vop_mountctl_args ap;
1185 ap.a_head.a_desc = &vop_mountctl_desc;
1186 ap.a_head.a_ops = ops;
1190 ap.a_ctllen = ctllen;
1192 ap.a_buflen = buflen;
1195 DO_OPS(ops, error, &ap, vop_mountctl);
1202 * nresolve takes a locked ncp and a cred and resolves the ncp into a
1203 * positive or negative hit.
1205 * The namecache is automatically adjusted by this function. The ncp
1206 * is left locked on return.
1209 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1211 struct vop_nresolve_args ap;
1214 ap.a_head.a_desc = &vop_nresolve_desc;
1215 ap.a_head.a_ops = ops;
1219 DO_OPS(ops, error, &ap, vop_nresolve);
1224 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
1225 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
1228 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1229 struct vnode **vpp, struct ucred *cred)
1231 struct vop_nlookupdotdot_args ap;
1234 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1235 ap.a_head.a_ops = ops;
1240 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1245 * ncreate takes a locked, resolved ncp that typically represents a negative
1246 * cache hit and creates the file or node specified by the ncp, cred, and
1247 * vattr. If no error occurs a locked vnode is returned in *vpp.
1249 * The namecache is automatically adjusted by this function. The ncp
1250 * is left locked on return.
1253 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1254 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1256 struct vop_ncreate_args ap;
1259 ap.a_head.a_desc = &vop_ncreate_desc;
1260 ap.a_head.a_ops = ops;
1266 DO_OPS(ops, error, &ap, vop_ncreate);
1271 * nmkdir takes a locked, resolved ncp that typically represents a negative
1272 * cache hit and creates the directory specified by the ncp, cred, and
1273 * vattr. If no error occurs a locked vnode is returned in *vpp.
1275 * The namecache is automatically adjusted by this function. The ncp
1276 * is left locked on return.
1279 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1280 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1282 struct vop_nmkdir_args ap;
1285 ap.a_head.a_desc = &vop_nmkdir_desc;
1286 ap.a_head.a_ops = ops;
1292 DO_OPS(ops, error, &ap, vop_nmkdir);
1297 * nmknod takes a locked, resolved ncp that typically represents a negative
1298 * cache hit and creates the node specified by the ncp, cred, and
1299 * vattr. If no error occurs a locked vnode is returned in *vpp.
1301 * The namecache is automatically adjusted by this function. The ncp
1302 * is left locked on return.
1305 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1306 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1308 struct vop_nmknod_args ap;
1311 ap.a_head.a_desc = &vop_nmknod_desc;
1312 ap.a_head.a_ops = ops;
1318 DO_OPS(ops, error, &ap, vop_nmknod);
1323 * nlink takes a locked, resolved ncp that typically represents a negative
1324 * cache hit and creates the node specified by the ncp, cred, and
1325 * existing vnode. The passed vp must be locked and will remain locked
1326 * on return, as does the ncp, whether an error occurs or not.
1328 * The namecache is automatically adjusted by this function. The ncp
1329 * is left locked on return.
1332 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1333 struct vnode *vp, struct ucred *cred)
1335 struct vop_nlink_args ap;
1338 ap.a_head.a_desc = &vop_nlink_desc;
1339 ap.a_head.a_ops = ops;
1344 DO_OPS(ops, error, &ap, vop_nlink);
1349 * nsymlink takes a locked, resolved ncp that typically represents a negative
1350 * cache hit and creates a symbolic link based on cred, vap, and target (the
1351 * contents of the link). If no error occurs a locked vnode is returned in
1354 * The namecache is automatically adjusted by this function. The ncp
1355 * is left locked on return.
1358 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1359 struct vnode **vpp, struct ucred *cred,
1360 struct vattr *vap, char *target)
1362 struct vop_nsymlink_args ap;
1365 ap.a_head.a_desc = &vop_nsymlink_desc;
1366 ap.a_head.a_ops = ops;
1371 ap.a_target = target;
1373 DO_OPS(ops, error, &ap, vop_nsymlink);
1378 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1379 * negative hit and executes the whiteout function specified in flags.
1381 * The namecache is automatically adjusted by this function. The ncp
1382 * is left locked on return.
1385 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1386 struct ucred *cred, int flags)
1388 struct vop_nwhiteout_args ap;
1391 ap.a_head.a_desc = &vop_nwhiteout_desc;
1392 ap.a_head.a_ops = ops;
1397 DO_OPS(ops, error, &ap, vop_nwhiteout);
1402 * nremove takes a locked, resolved ncp that generally represents a
1403 * positive hit and removes the file.
1405 * The namecache is automatically adjusted by this function. The ncp
1406 * is left locked on return.
1409 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1411 struct vop_nremove_args ap;
1414 ap.a_head.a_desc = &vop_nremove_desc;
1415 ap.a_head.a_ops = ops;
1419 DO_OPS(ops, error, &ap, vop_nremove);
1424 * nrmdir takes a locked, resolved ncp that generally represents a
1425 * directory and removes the directory.
1427 * The namecache is automatically adjusted by this function. The ncp
1428 * is left locked on return.
1431 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1433 struct vop_nrmdir_args ap;
1436 ap.a_head.a_desc = &vop_nrmdir_desc;
1437 ap.a_head.a_ops = ops;
1441 DO_OPS(ops, error, &ap, vop_nrmdir);
1446 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1447 * and renames the source ncp to the target ncp. The target ncp may
1448 * represent a positive or negative hit.
1450 * The namecache is automatically adjusted by this function. The ncp
1451 * is left locked on return. The source ncp is typically changed to
1452 * a negative cache hit and the target ncp typically takes on the
1453 * source ncp's underlying file.
1456 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1457 struct namecache *tncp, struct ucred *cred)
1459 struct vop_nrename_args ap;
1462 ap.a_head.a_desc = &vop_nrename_desc;
1463 ap.a_head.a_ops = ops;
1468 DO_OPS(ops, error, &ap, vop_nrename);
1472 /************************************************************************
1473 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1474 ************************************************************************
1476 * These procedures are called from VFSs such as unionfs and nullfs
1477 * when they wish to forward an operation on one VFS to another. The
1478 * argument structure/message is modified and then directly passed to the
1479 * appropriate routine. This routines may also be called by initiators
1480 * who have an argument structure in hand rather then discreet arguments.
1483 vop_vnoperate_ap(struct vop_generic_args *ap)
1485 struct vop_ops *ops;
1489 error = VOCALL(ops, ap);
1495 * This routine is called by the cache coherency layer to execute the actual
1496 * VFS operation. If a journaling layer is present we call though it, else
1497 * we call the native VOP functions.
1500 vop_cache_operate_ap(struct vop_generic_args *ap)
1502 struct vop_ops *ops;
1506 if (ops->vv_mount->mnt_vn_journal_ops)
1507 error = VOCALL(ops->vv_mount->mnt_vn_journal_ops, ap);
1509 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1515 * This routine is called by the journaling layer to execute the actual
1519 vop_journal_operate_ap(struct vop_generic_args *ap)
1521 struct vop_ops *ops;
1525 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1531 vop_islocked_ap(struct vop_islocked_args *ap)
1535 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1540 vop_lookup_ap(struct vop_lookup_args *ap)
1544 DO_OPS(ap->a_head.a_ops, error, ap, vop_lookup);
1549 vop_create_ap(struct vop_create_args *ap)
1553 DO_OPS(ap->a_head.a_ops, error, ap, vop_create);
1558 vop_whiteout_ap(struct vop_whiteout_args *ap)
1562 DO_OPS(ap->a_head.a_ops, error, ap, vop_whiteout);
1567 vop_mknod_ap(struct vop_mknod_args *ap)
1571 DO_OPS(ap->a_head.a_ops, error, ap, vop_mknod);
1576 vop_open_ap(struct vop_open_args *ap)
1580 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1585 vop_close_ap(struct vop_close_args *ap)
1589 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1594 vop_access_ap(struct vop_access_args *ap)
1598 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1603 vop_getattr_ap(struct vop_getattr_args *ap)
1607 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1612 vop_setattr_ap(struct vop_setattr_args *ap)
1616 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1621 vop_read_ap(struct vop_read_args *ap)
1625 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1630 vop_write_ap(struct vop_write_args *ap)
1634 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1639 vop_lease_ap(struct vop_lease_args *ap)
1643 DO_OPS(ap->a_head.a_ops, error, ap, vop_lease);
1648 vop_ioctl_ap(struct vop_ioctl_args *ap)
1652 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1657 vop_poll_ap(struct vop_poll_args *ap)
1661 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1666 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1670 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1675 vop_revoke_ap(struct vop_revoke_args *ap)
1679 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1684 vop_mmap_ap(struct vop_mmap_args *ap)
1688 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1693 vop_fsync_ap(struct vop_fsync_args *ap)
1697 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1702 vop_remove_ap(struct vop_remove_args *ap)
1706 DO_OPS(ap->a_head.a_ops, error, ap, vop_remove);
1711 vop_link_ap(struct vop_link_args *ap)
1715 DO_OPS(ap->a_head.a_ops, error, ap, vop_link);
1720 vop_rename_ap(struct vop_rename_args *ap)
1724 DO_OPS(ap->a_head.a_ops, error, ap, vop_rename);
1729 vop_mkdir_ap(struct vop_mkdir_args *ap)
1733 DO_OPS(ap->a_head.a_ops, error, ap, vop_mkdir);
1738 vop_rmdir_ap(struct vop_rmdir_args *ap)
1742 DO_OPS(ap->a_head.a_ops, error, ap, vop_rmdir);
1747 vop_symlink_ap(struct vop_symlink_args *ap)
1751 DO_OPS(ap->a_head.a_ops, error, ap, vop_symlink);
1756 vop_readdir_ap(struct vop_readdir_args *ap)
1760 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1765 vop_readlink_ap(struct vop_readlink_args *ap)
1769 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1774 vop_inactive_ap(struct vop_inactive_args *ap)
1778 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1783 vop_reclaim_ap(struct vop_reclaim_args *ap)
1787 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1792 vop_lock_ap(struct vop_lock_args *ap)
1796 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1801 vop_unlock_ap(struct vop_unlock_args *ap)
1805 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1810 vop_bmap_ap(struct vop_bmap_args *ap)
1814 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1819 vop_strategy_ap(struct vop_strategy_args *ap)
1823 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1828 vop_print_ap(struct vop_print_args *ap)
1832 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1837 vop_pathconf_ap(struct vop_pathconf_args *ap)
1841 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1846 vop_advlock_ap(struct vop_advlock_args *ap)
1850 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1855 vop_balloc_ap(struct vop_balloc_args *ap)
1859 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1864 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1868 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1873 vop_getpages_ap(struct vop_getpages_args *ap)
1877 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1882 vop_putpages_ap(struct vop_putpages_args *ap)
1886 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1891 vop_freeblks_ap(struct vop_freeblks_args *ap)
1895 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1900 vop_bwrite_ap(struct vop_bwrite_args *ap)
1904 DO_OPS(ap->a_head.a_ops, error, ap, vop_bwrite);
1909 vop_getacl_ap(struct vop_getacl_args *ap)
1913 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1918 vop_setacl_ap(struct vop_setacl_args *ap)
1922 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1927 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1931 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1936 vop_getextattr_ap(struct vop_getextattr_args *ap)
1940 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1945 vop_setextattr_ap(struct vop_setextattr_args *ap)
1949 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1954 vop_createvobject_ap(struct vop_createvobject_args *ap)
1958 DO_OPS(ap->a_head.a_ops, error, ap, vop_createvobject);
1963 vop_destroyvobject_ap(struct vop_destroyvobject_args *ap)
1967 DO_OPS(ap->a_head.a_ops, error, ap, vop_destroyvobject);
1972 vop_getvobject_ap(struct vop_getvobject_args *ap)
1976 DO_OPS(ap->a_head.a_ops, error, ap, vop_getvobject);
1981 vop_mountctl_ap(struct vop_mountctl_args *ap)
1985 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1990 vop_nresolve_ap(struct vop_nresolve_args *ap)
1994 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1999 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
2003 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
2008 vop_ncreate_ap(struct vop_ncreate_args *ap)
2012 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
2017 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
2021 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
2026 vop_nmknod_ap(struct vop_nmknod_args *ap)
2030 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
2035 vop_nlink_ap(struct vop_nlink_args *ap)
2039 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
2044 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
2048 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
2053 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
2057 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
2062 vop_nremove_ap(struct vop_nremove_args *ap)
2066 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
2071 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
2075 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
2080 vop_nrename_ap(struct vop_nrename_args *ap)
2084 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);