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.29 2006/07/19 06:08:06 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 VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
79 #define VARGSSTRUCT(name) struct __CONCAT(__CONCAT(vop_,name),_args)
81 #define VNODEOP_DESC_INIT(name) \
82 struct syslink_desc VDESCNAME(name) = { \
83 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
86 VNODEOP_DESC_INIT(default);
87 VNODEOP_DESC_INIT(islocked);
88 VNODEOP_DESC_INIT(old_lookup);
89 VNODEOP_DESC_INIT(old_create);
90 VNODEOP_DESC_INIT(old_whiteout);
91 VNODEOP_DESC_INIT(old_mknod);
92 VNODEOP_DESC_INIT(open);
93 VNODEOP_DESC_INIT(close);
94 VNODEOP_DESC_INIT(access);
95 VNODEOP_DESC_INIT(getattr);
96 VNODEOP_DESC_INIT(setattr);
97 VNODEOP_DESC_INIT(read);
98 VNODEOP_DESC_INIT(write);
99 VNODEOP_DESC_INIT(ioctl);
100 VNODEOP_DESC_INIT(poll);
101 VNODEOP_DESC_INIT(kqfilter);
102 VNODEOP_DESC_INIT(revoke);
103 VNODEOP_DESC_INIT(mmap);
104 VNODEOP_DESC_INIT(fsync);
105 VNODEOP_DESC_INIT(old_remove);
106 VNODEOP_DESC_INIT(old_link);
107 VNODEOP_DESC_INIT(old_rename);
109 VNODEOP_DESC_INIT(old_mkdir);
110 VNODEOP_DESC_INIT(old_rmdir);
111 VNODEOP_DESC_INIT(old_symlink);
112 VNODEOP_DESC_INIT(readdir);
113 VNODEOP_DESC_INIT(readlink);
114 VNODEOP_DESC_INIT(inactive);
115 VNODEOP_DESC_INIT(reclaim);
116 VNODEOP_DESC_INIT(lock);
117 VNODEOP_DESC_INIT(unlock);
118 VNODEOP_DESC_INIT(bmap);
119 VNODEOP_DESC_INIT(strategy);
120 VNODEOP_DESC_INIT(print);
121 VNODEOP_DESC_INIT(pathconf);
122 VNODEOP_DESC_INIT(advlock);
123 VNODEOP_DESC_INIT(balloc);
124 VNODEOP_DESC_INIT(reallocblks);
125 VNODEOP_DESC_INIT(getpages);
126 VNODEOP_DESC_INIT(putpages);
127 VNODEOP_DESC_INIT(freeblks);
128 VNODEOP_DESC_INIT(getacl);
129 VNODEOP_DESC_INIT(setacl);
130 VNODEOP_DESC_INIT(aclcheck);
131 VNODEOP_DESC_INIT(getextattr);
132 VNODEOP_DESC_INIT(setextattr);
133 VNODEOP_DESC_INIT(mountctl);
135 VNODEOP_DESC_INIT(nresolve);
136 VNODEOP_DESC_INIT(nlookupdotdot);
137 VNODEOP_DESC_INIT(ncreate);
138 VNODEOP_DESC_INIT(nmkdir);
139 VNODEOP_DESC_INIT(nmknod);
140 VNODEOP_DESC_INIT(nlink);
141 VNODEOP_DESC_INIT(nsymlink);
142 VNODEOP_DESC_INIT(nwhiteout);
143 VNODEOP_DESC_INIT(nremove);
144 VNODEOP_DESC_INIT(nrmdir);
145 VNODEOP_DESC_INIT(nrename);
147 #define DO_OPS(ops, error, ap, vop_field) \
148 error = ops->vop_field(ap);
150 /************************************************************************
151 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
152 ************************************************************************
154 * These procedures are called directly from the kernel and/or fileops
155 * code to perform file/device operations on the system.
157 * NOTE: The old namespace api functions such as vop_rename() are no longer
158 * available for general use and have been renamed to vop_old_*(). Only
159 * the code in vfs_default.c is allowed to call those ops.
163 vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
165 struct vop_islocked_args ap;
168 ap.a_head.a_desc = &vop_islocked_desc;
169 ap.a_head.a_ops = ops;
173 DO_OPS(ops, error, &ap, vop_islocked);
178 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
179 struct vnode **vpp, struct componentname *cnp)
181 struct vop_old_lookup_args ap;
184 ap.a_head.a_desc = &vop_old_lookup_desc;
185 ap.a_head.a_ops = ops;
190 DO_OPS(ops, error, &ap, vop_old_lookup);
195 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
196 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
198 struct vop_old_create_args ap;
201 ap.a_head.a_desc = &vop_old_create_desc;
202 ap.a_head.a_ops = ops;
208 DO_OPS(ops, error, &ap, vop_old_create);
213 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
214 struct componentname *cnp, int flags)
216 struct vop_old_whiteout_args ap;
219 ap.a_head.a_desc = &vop_old_whiteout_desc;
220 ap.a_head.a_ops = ops;
225 DO_OPS(ops, error, &ap, vop_old_whiteout);
230 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
231 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
233 struct vop_old_mknod_args ap;
236 ap.a_head.a_desc = &vop_old_mknod_desc;
237 ap.a_head.a_ops = ops;
243 DO_OPS(ops, error, &ap, vop_old_mknod);
248 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
251 struct vop_open_args ap;
254 ap.a_head.a_desc = &vop_open_desc;
255 ap.a_head.a_ops = ops;
261 DO_OPS(ops, error, &ap, vop_open);
266 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
268 struct vop_close_args ap;
271 ap.a_head.a_desc = &vop_close_desc;
272 ap.a_head.a_ops = ops;
276 DO_OPS(ops, error, &ap, vop_close);
281 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred)
283 struct vop_access_args ap;
286 ap.a_head.a_desc = &vop_access_desc;
287 ap.a_head.a_ops = ops;
292 DO_OPS(ops, error, &ap, vop_access);
297 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
299 struct vop_getattr_args ap;
302 ap.a_head.a_desc = &vop_getattr_desc;
303 ap.a_head.a_ops = ops;
307 DO_OPS(ops, error, &ap, vop_getattr);
308 if ((ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0)
309 vap->va_fsmid = cache_sync_fsmid_vp(vp);
314 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
317 struct vop_setattr_args ap;
320 ap.a_head.a_desc = &vop_setattr_desc;
321 ap.a_head.a_ops = ops;
326 DO_OPS(ops, error, &ap, vop_setattr);
328 cache_update_fsmid_vp(vp);
333 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
336 struct vop_read_args ap;
339 ap.a_head.a_desc = &vop_read_desc;
340 ap.a_head.a_ops = ops;
343 ap.a_ioflag = ioflag;
346 DO_OPS(ops, error, &ap, vop_read);
351 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
354 struct vop_write_args ap;
357 ap.a_head.a_desc = &vop_write_desc;
358 ap.a_head.a_ops = ops;
361 ap.a_ioflag = ioflag;
364 DO_OPS(ops, error, &ap, vop_write);
366 cache_update_fsmid_vp(vp);
371 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
372 int fflag, struct ucred *cred)
374 struct vop_ioctl_args ap;
377 ap.a_head.a_desc = &vop_ioctl_desc;
378 ap.a_head.a_ops = ops;
380 ap.a_command = command;
385 DO_OPS(ops, error, &ap, vop_ioctl);
390 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
392 struct vop_poll_args ap;
395 ap.a_head.a_desc = &vop_poll_desc;
396 ap.a_head.a_ops = ops;
398 ap.a_events = events;
401 DO_OPS(ops, error, &ap, vop_poll);
406 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
408 struct vop_kqfilter_args ap;
411 ap.a_head.a_desc = &vop_kqfilter_desc;
412 ap.a_head.a_ops = ops;
416 DO_OPS(ops, error, &ap, vop_kqfilter);
421 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
423 struct vop_revoke_args ap;
426 ap.a_head.a_desc = &vop_revoke_desc;
427 ap.a_head.a_ops = ops;
431 DO_OPS(ops, error, &ap, vop_revoke);
436 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
438 struct vop_mmap_args ap;
441 ap.a_head.a_desc = &vop_mmap_desc;
442 ap.a_head.a_ops = ops;
444 ap.a_fflags = fflags;
447 DO_OPS(ops, error, &ap, vop_mmap);
452 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor)
454 struct vop_fsync_args ap;
457 ap.a_head.a_desc = &vop_fsync_desc;
458 ap.a_head.a_ops = ops;
460 ap.a_waitfor = waitfor;
462 DO_OPS(ops, error, &ap, vop_fsync);
467 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
468 struct vnode *vp, struct componentname *cnp)
470 struct vop_old_remove_args ap;
473 ap.a_head.a_desc = &vop_old_remove_desc;
474 ap.a_head.a_ops = ops;
479 DO_OPS(ops, error, &ap, vop_old_remove);
484 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
485 struct vnode *vp, struct componentname *cnp)
487 struct vop_old_link_args ap;
490 ap.a_head.a_desc = &vop_old_link_desc;
491 ap.a_head.a_ops = ops;
496 DO_OPS(ops, error, &ap, vop_old_link);
501 vop_old_rename(struct vop_ops *ops,
502 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
503 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
505 struct vop_old_rename_args ap;
508 ap.a_head.a_desc = &vop_old_rename_desc;
509 ap.a_head.a_ops = ops;
517 DO_OPS(ops, error, &ap, vop_old_rename);
522 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
523 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
525 struct vop_old_mkdir_args ap;
528 ap.a_head.a_desc = &vop_old_mkdir_desc;
529 ap.a_head.a_ops = ops;
535 DO_OPS(ops, error, &ap, vop_old_mkdir);
540 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
541 struct vnode *vp, struct componentname *cnp)
543 struct vop_old_rmdir_args ap;
546 ap.a_head.a_desc = &vop_old_rmdir_desc;
547 ap.a_head.a_ops = ops;
552 DO_OPS(ops, error, &ap, vop_old_rmdir);
557 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
558 struct vnode **vpp, struct componentname *cnp,
559 struct vattr *vap, char *target)
561 struct vop_old_symlink_args ap;
564 ap.a_head.a_desc = &vop_old_symlink_desc;
565 ap.a_head.a_ops = ops;
570 ap.a_target = target;
572 DO_OPS(ops, error, &ap, vop_old_symlink);
577 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
578 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
580 struct vop_readdir_args ap;
583 ap.a_head.a_desc = &vop_readdir_desc;
584 ap.a_head.a_ops = ops;
588 ap.a_eofflag = eofflag;
589 ap.a_ncookies = ncookies;
590 ap.a_cookies = cookies;
592 DO_OPS(ops, error, &ap, vop_readdir);
597 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
600 struct vop_readlink_args ap;
603 ap.a_head.a_desc = &vop_readlink_desc;
604 ap.a_head.a_ops = ops;
609 DO_OPS(ops, error, &ap, vop_readlink);
614 vop_inactive(struct vop_ops *ops, struct vnode *vp)
616 struct vop_inactive_args ap;
619 ap.a_head.a_desc = &vop_inactive_desc;
620 ap.a_head.a_ops = ops;
623 DO_OPS(ops, error, &ap, vop_inactive);
628 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
630 struct vop_reclaim_args ap;
633 ap.a_head.a_desc = &vop_reclaim_desc;
634 ap.a_head.a_ops = ops;
637 DO_OPS(ops, error, &ap, vop_reclaim);
642 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags)
644 struct vop_lock_args ap;
647 ap.a_head.a_desc = &vop_lock_desc;
648 ap.a_head.a_ops = ops;
652 DO_OPS(ops, error, &ap, vop_lock);
657 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags)
659 struct vop_unlock_args ap;
662 ap.a_head.a_desc = &vop_unlock_desc;
663 ap.a_head.a_ops = ops;
667 DO_OPS(ops, error, &ap, vop_unlock);
672 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
673 struct vnode **vpp, off_t *doffsetp, int *runp, int *runb)
675 struct vop_bmap_args ap;
678 ap.a_head.a_desc = &vop_bmap_desc;
679 ap.a_head.a_ops = ops;
681 ap.a_loffset = loffset;
683 ap.a_doffsetp = doffsetp;
687 DO_OPS(ops, error, &ap, vop_bmap);
692 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
694 struct vop_strategy_args ap;
697 ap.a_head.a_desc = &vop_strategy_desc;
698 ap.a_head.a_ops = ops;
702 DO_OPS(ops, error, &ap, vop_strategy);
703 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
704 cache_update_fsmid_vp(vp);
709 vop_print(struct vop_ops *ops, struct vnode *vp)
711 struct vop_print_args ap;
714 ap.a_head.a_desc = &vop_print_desc;
715 ap.a_head.a_ops = ops;
718 DO_OPS(ops, error, &ap, vop_print);
723 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
726 struct vop_pathconf_args ap;
729 ap.a_head.a_desc = &vop_pathconf_desc;
730 ap.a_head.a_ops = ops;
733 ap.a_retval = retval;
735 DO_OPS(ops, error, &ap, vop_pathconf);
740 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
741 struct flock *fl, int flags)
743 struct vop_advlock_args ap;
746 ap.a_head.a_desc = &vop_advlock_desc;
747 ap.a_head.a_ops = ops;
754 DO_OPS(ops, error, &ap, vop_advlock);
759 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
760 int size, struct ucred *cred, int flags,
763 struct vop_balloc_args ap;
766 ap.a_head.a_desc = &vop_balloc_desc;
767 ap.a_head.a_ops = ops;
769 ap.a_startoffset = startoffset;
775 DO_OPS(ops, error, &ap, vop_balloc);
780 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
781 struct cluster_save *buflist)
783 struct vop_reallocblks_args ap;
786 ap.a_head.a_desc = &vop_reallocblks_desc;
787 ap.a_head.a_ops = ops;
789 ap.a_buflist = buflist;
791 DO_OPS(ops, error, &ap, vop_reallocblks);
796 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
797 int reqpage, vm_ooffset_t offset)
799 struct vop_getpages_args ap;
802 ap.a_head.a_desc = &vop_getpages_desc;
803 ap.a_head.a_ops = ops;
807 ap.a_reqpage = reqpage;
808 ap.a_offset = offset;
810 DO_OPS(ops, error, &ap, vop_getpages);
815 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
816 int sync, int *rtvals, vm_ooffset_t offset)
818 struct vop_putpages_args ap;
821 ap.a_head.a_desc = &vop_putpages_desc;
822 ap.a_head.a_ops = ops;
827 ap.a_rtvals = rtvals;
828 ap.a_offset = offset;
830 DO_OPS(ops, error, &ap, vop_putpages);
832 cache_update_fsmid_vp(vp);
837 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
839 struct vop_freeblks_args ap;
842 ap.a_head.a_desc = &vop_freeblks_desc;
843 ap.a_head.a_ops = ops;
845 ap.a_offset = offset;
846 ap.a_length = length;
848 DO_OPS(ops, error, &ap, vop_freeblks);
853 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
854 struct acl *aclp, struct ucred *cred)
856 struct vop_getacl_args ap;
859 ap.a_head.a_desc = &vop_getacl_desc;
860 ap.a_head.a_ops = ops;
866 DO_OPS(ops, error, &ap, vop_getacl);
871 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
872 struct acl *aclp, struct ucred *cred)
874 struct vop_setacl_args ap;
877 ap.a_head.a_desc = &vop_setacl_desc;
878 ap.a_head.a_ops = ops;
884 DO_OPS(ops, error, &ap, vop_setacl);
886 cache_update_fsmid_vp(vp);
891 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
892 struct acl *aclp, struct ucred *cred)
894 struct vop_aclcheck_args ap;
897 ap.a_head.a_desc = &vop_aclcheck_desc;
898 ap.a_head.a_ops = ops;
904 DO_OPS(ops, error, &ap, vop_aclcheck);
909 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
910 struct uio *uio, struct ucred *cred)
912 struct vop_getextattr_args ap;
915 ap.a_head.a_desc = &vop_getextattr_desc;
916 ap.a_head.a_ops = ops;
922 DO_OPS(ops, error, &ap, vop_getextattr);
927 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
928 struct uio *uio, struct ucred *cred)
930 struct vop_setextattr_args ap;
933 ap.a_head.a_desc = &vop_setextattr_desc;
934 ap.a_head.a_ops = ops;
940 DO_OPS(ops, error, &ap, vop_setextattr);
942 cache_update_fsmid_vp(vp);
947 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
948 const void *ctl, int ctllen, void *buf, int buflen, int *res)
950 struct vop_mountctl_args ap;
953 ap.a_head.a_desc = &vop_mountctl_desc;
954 ap.a_head.a_ops = ops;
958 ap.a_ctllen = ctllen;
960 ap.a_buflen = buflen;
963 DO_OPS(ops, error, &ap, vop_mountctl);
970 * nresolve takes a locked ncp and a cred and resolves the ncp into a
971 * positive or negative hit.
973 * The namecache is automatically adjusted by this function. The ncp
974 * is left locked on return.
977 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
979 struct vop_nresolve_args ap;
982 ap.a_head.a_desc = &vop_nresolve_desc;
983 ap.a_head.a_ops = ops;
987 DO_OPS(ops, error, &ap, vop_nresolve);
992 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
993 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
996 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
997 struct vnode **vpp, struct ucred *cred)
999 struct vop_nlookupdotdot_args ap;
1002 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1003 ap.a_head.a_ops = ops;
1008 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1013 * ncreate takes a locked, resolved ncp that typically represents a negative
1014 * cache hit and creates the file or node specified by the ncp, cred, and
1015 * vattr. If no error occurs a locked vnode is returned in *vpp.
1017 * The namecache is automatically adjusted by this function. The ncp
1018 * is left locked on return.
1021 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1022 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1024 struct vop_ncreate_args ap;
1027 ap.a_head.a_desc = &vop_ncreate_desc;
1028 ap.a_head.a_ops = ops;
1034 DO_OPS(ops, error, &ap, vop_ncreate);
1035 if (error == 0 && *vpp)
1036 cache_update_fsmid_vp(*vpp);
1041 * nmkdir takes a locked, resolved ncp that typically represents a negative
1042 * cache hit and creates the directory specified by the ncp, cred, and
1043 * vattr. If no error occurs a locked vnode is returned in *vpp.
1045 * The namecache is automatically adjusted by this function. The ncp
1046 * is left locked on return.
1049 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1050 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1052 struct vop_nmkdir_args ap;
1055 ap.a_head.a_desc = &vop_nmkdir_desc;
1056 ap.a_head.a_ops = ops;
1062 DO_OPS(ops, error, &ap, vop_nmkdir);
1063 if (error == 0 && *vpp)
1064 cache_update_fsmid_vp(*vpp);
1069 * nmknod takes a locked, resolved ncp that typically represents a negative
1070 * cache hit and creates the node specified by the ncp, cred, and
1071 * vattr. If no error occurs a locked vnode is returned in *vpp.
1073 * The namecache is automatically adjusted by this function. The ncp
1074 * is left locked on return.
1077 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1078 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1080 struct vop_nmknod_args ap;
1083 ap.a_head.a_desc = &vop_nmknod_desc;
1084 ap.a_head.a_ops = ops;
1090 DO_OPS(ops, error, &ap, vop_nmknod);
1091 if (error == 0 && *vpp)
1092 cache_update_fsmid_vp(*vpp);
1097 * nlink takes a locked, resolved ncp that typically represents a negative
1098 * cache hit and creates the node specified by the ncp, cred, and
1099 * existing vnode. The passed vp must be locked and will remain locked
1100 * on return, as does the ncp, whether an error occurs or not.
1102 * The namecache is automatically adjusted by this function. The ncp
1103 * is left locked on return.
1106 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1107 struct vnode *vp, struct ucred *cred)
1109 struct vop_nlink_args ap;
1112 ap.a_head.a_desc = &vop_nlink_desc;
1113 ap.a_head.a_ops = ops;
1118 DO_OPS(ops, error, &ap, vop_nlink);
1120 cache_update_fsmid(ncp);
1125 * nsymlink takes a locked, resolved ncp that typically represents a negative
1126 * cache hit and creates a symbolic link based on cred, vap, and target (the
1127 * contents of the link). If no error occurs a locked vnode is returned in
1130 * The namecache is automatically adjusted by this function. The ncp
1131 * is left locked on return.
1134 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1135 struct vnode **vpp, struct ucred *cred,
1136 struct vattr *vap, char *target)
1138 struct vop_nsymlink_args ap;
1141 ap.a_head.a_desc = &vop_nsymlink_desc;
1142 ap.a_head.a_ops = ops;
1147 ap.a_target = target;
1149 DO_OPS(ops, error, &ap, vop_nsymlink);
1151 cache_update_fsmid(ncp);
1156 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1157 * negative hit and executes the whiteout function specified in flags.
1159 * The namecache is automatically adjusted by this function. The ncp
1160 * is left locked on return.
1163 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1164 struct ucred *cred, int flags)
1166 struct vop_nwhiteout_args ap;
1169 ap.a_head.a_desc = &vop_nwhiteout_desc;
1170 ap.a_head.a_ops = ops;
1175 DO_OPS(ops, error, &ap, vop_nwhiteout);
1177 cache_update_fsmid(ncp);
1182 * nremove takes a locked, resolved ncp that generally represents a
1183 * positive hit and removes the file.
1185 * The namecache is automatically adjusted by this function. The ncp
1186 * is left locked on return.
1189 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1191 struct vop_nremove_args ap;
1194 ap.a_head.a_desc = &vop_nremove_desc;
1195 ap.a_head.a_ops = ops;
1199 DO_OPS(ops, error, &ap, vop_nremove);
1201 cache_update_fsmid(ncp);
1206 * nrmdir takes a locked, resolved ncp that generally represents a
1207 * directory and removes the directory.
1209 * The namecache is automatically adjusted by this function. The ncp
1210 * is left locked on return.
1213 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1215 struct vop_nrmdir_args ap;
1218 ap.a_head.a_desc = &vop_nrmdir_desc;
1219 ap.a_head.a_ops = ops;
1223 DO_OPS(ops, error, &ap, vop_nrmdir);
1225 cache_update_fsmid(ncp);
1230 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1231 * and renames the source ncp to the target ncp. The target ncp may
1232 * represent a positive or negative hit.
1234 * The namecache is automatically adjusted by this function. The ncp
1235 * is left locked on return. The source ncp is typically changed to
1236 * a negative cache hit and the target ncp typically takes on the
1237 * source ncp's underlying file.
1240 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1241 struct namecache *tncp, struct ucred *cred)
1243 struct vop_nrename_args ap;
1246 ap.a_head.a_desc = &vop_nrename_desc;
1247 ap.a_head.a_ops = ops;
1252 DO_OPS(ops, error, &ap, vop_nrename);
1254 cache_update_fsmid(fncp);
1255 cache_update_fsmid(tncp);
1260 /************************************************************************
1261 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1262 ************************************************************************
1264 * These procedures are called from VFSs such as unionfs and nullfs
1265 * when they wish to forward an operation on one VFS to another. The
1266 * argument structure/message is modified and then directly passed to the
1267 * appropriate routine. This routines may also be called by initiators
1268 * who have an argument structure in hand rather then discreet arguments.
1271 vop_vnoperate_ap(struct vop_generic_args *ap)
1273 struct vop_ops *ops;
1277 error = VOCALL(ops, ap);
1283 * This routine is called by the cache coherency layer to execute the actual
1284 * VFS operation. If a journaling layer is present we call though it, else
1285 * we call the native VOP functions.
1288 vop_cache_operate_ap(struct vop_generic_args *ap)
1290 struct vop_ops *ops;
1294 if (ops->head.vv_mount->mnt_vn_journal_ops)
1295 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1297 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1303 * This routine is called by the journaling layer to execute the actual
1307 vop_journal_operate_ap(struct vop_generic_args *ap)
1309 struct vop_ops *ops;
1313 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1319 vop_islocked_ap(struct vop_islocked_args *ap)
1323 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1328 vop_open_ap(struct vop_open_args *ap)
1332 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1337 vop_close_ap(struct vop_close_args *ap)
1341 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1346 vop_access_ap(struct vop_access_args *ap)
1350 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1355 vop_getattr_ap(struct vop_getattr_args *ap)
1359 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1364 vop_setattr_ap(struct vop_setattr_args *ap)
1368 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1373 vop_read_ap(struct vop_read_args *ap)
1377 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1382 vop_write_ap(struct vop_write_args *ap)
1386 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1391 vop_ioctl_ap(struct vop_ioctl_args *ap)
1395 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1400 vop_poll_ap(struct vop_poll_args *ap)
1404 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1409 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1413 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1418 vop_revoke_ap(struct vop_revoke_args *ap)
1422 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1427 vop_mmap_ap(struct vop_mmap_args *ap)
1431 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1436 vop_fsync_ap(struct vop_fsync_args *ap)
1440 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1445 vop_readdir_ap(struct vop_readdir_args *ap)
1449 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1454 vop_readlink_ap(struct vop_readlink_args *ap)
1458 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1463 vop_inactive_ap(struct vop_inactive_args *ap)
1467 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1472 vop_reclaim_ap(struct vop_reclaim_args *ap)
1476 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1481 vop_lock_ap(struct vop_lock_args *ap)
1485 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1490 vop_unlock_ap(struct vop_unlock_args *ap)
1494 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1499 vop_bmap_ap(struct vop_bmap_args *ap)
1503 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1508 vop_strategy_ap(struct vop_strategy_args *ap)
1512 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1517 vop_print_ap(struct vop_print_args *ap)
1521 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1526 vop_pathconf_ap(struct vop_pathconf_args *ap)
1530 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1535 vop_advlock_ap(struct vop_advlock_args *ap)
1539 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1544 vop_balloc_ap(struct vop_balloc_args *ap)
1548 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1553 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1557 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1562 vop_getpages_ap(struct vop_getpages_args *ap)
1566 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1571 vop_putpages_ap(struct vop_putpages_args *ap)
1575 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1580 vop_freeblks_ap(struct vop_freeblks_args *ap)
1584 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1589 vop_getacl_ap(struct vop_getacl_args *ap)
1593 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1598 vop_setacl_ap(struct vop_setacl_args *ap)
1602 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1607 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1611 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1616 vop_getextattr_ap(struct vop_getextattr_args *ap)
1620 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1625 vop_setextattr_ap(struct vop_setextattr_args *ap)
1629 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1634 vop_mountctl_ap(struct vop_mountctl_args *ap)
1638 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1643 vop_nresolve_ap(struct vop_nresolve_args *ap)
1647 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1652 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1656 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1661 vop_ncreate_ap(struct vop_ncreate_args *ap)
1665 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1670 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1674 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1679 vop_nmknod_ap(struct vop_nmknod_args *ap)
1683 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1688 vop_nlink_ap(struct vop_nlink_args *ap)
1692 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1697 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1701 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1706 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1710 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1715 vop_nremove_ap(struct vop_nremove_args *ap)
1719 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1724 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1728 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1733 vop_nrename_ap(struct vop_nrename_args *ap)
1737 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);