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.30 2006/07/20 20:16:24 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);
310 * mount pointer may be NULL if vnode is dead.
312 if (ops->head.vv_mount &&
313 (ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0) {
314 vap->va_fsmid = cache_sync_fsmid_vp(vp);
320 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
323 struct vop_setattr_args ap;
326 ap.a_head.a_desc = &vop_setattr_desc;
327 ap.a_head.a_ops = ops;
332 DO_OPS(ops, error, &ap, vop_setattr);
334 cache_update_fsmid_vp(vp);
339 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
342 struct vop_read_args ap;
345 ap.a_head.a_desc = &vop_read_desc;
346 ap.a_head.a_ops = ops;
349 ap.a_ioflag = ioflag;
352 DO_OPS(ops, error, &ap, vop_read);
357 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
360 struct vop_write_args ap;
363 ap.a_head.a_desc = &vop_write_desc;
364 ap.a_head.a_ops = ops;
367 ap.a_ioflag = ioflag;
370 DO_OPS(ops, error, &ap, vop_write);
372 cache_update_fsmid_vp(vp);
377 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
378 int fflag, struct ucred *cred)
380 struct vop_ioctl_args ap;
383 ap.a_head.a_desc = &vop_ioctl_desc;
384 ap.a_head.a_ops = ops;
386 ap.a_command = command;
391 DO_OPS(ops, error, &ap, vop_ioctl);
396 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
398 struct vop_poll_args ap;
401 ap.a_head.a_desc = &vop_poll_desc;
402 ap.a_head.a_ops = ops;
404 ap.a_events = events;
407 DO_OPS(ops, error, &ap, vop_poll);
412 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
414 struct vop_kqfilter_args ap;
417 ap.a_head.a_desc = &vop_kqfilter_desc;
418 ap.a_head.a_ops = ops;
422 DO_OPS(ops, error, &ap, vop_kqfilter);
427 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
429 struct vop_revoke_args ap;
432 ap.a_head.a_desc = &vop_revoke_desc;
433 ap.a_head.a_ops = ops;
437 DO_OPS(ops, error, &ap, vop_revoke);
442 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
444 struct vop_mmap_args ap;
447 ap.a_head.a_desc = &vop_mmap_desc;
448 ap.a_head.a_ops = ops;
450 ap.a_fflags = fflags;
453 DO_OPS(ops, error, &ap, vop_mmap);
458 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor)
460 struct vop_fsync_args ap;
463 ap.a_head.a_desc = &vop_fsync_desc;
464 ap.a_head.a_ops = ops;
466 ap.a_waitfor = waitfor;
468 DO_OPS(ops, error, &ap, vop_fsync);
473 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
474 struct vnode *vp, struct componentname *cnp)
476 struct vop_old_remove_args ap;
479 ap.a_head.a_desc = &vop_old_remove_desc;
480 ap.a_head.a_ops = ops;
485 DO_OPS(ops, error, &ap, vop_old_remove);
490 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
491 struct vnode *vp, struct componentname *cnp)
493 struct vop_old_link_args ap;
496 ap.a_head.a_desc = &vop_old_link_desc;
497 ap.a_head.a_ops = ops;
502 DO_OPS(ops, error, &ap, vop_old_link);
507 vop_old_rename(struct vop_ops *ops,
508 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
509 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
511 struct vop_old_rename_args ap;
514 ap.a_head.a_desc = &vop_old_rename_desc;
515 ap.a_head.a_ops = ops;
523 DO_OPS(ops, error, &ap, vop_old_rename);
528 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
529 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
531 struct vop_old_mkdir_args ap;
534 ap.a_head.a_desc = &vop_old_mkdir_desc;
535 ap.a_head.a_ops = ops;
541 DO_OPS(ops, error, &ap, vop_old_mkdir);
546 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
547 struct vnode *vp, struct componentname *cnp)
549 struct vop_old_rmdir_args ap;
552 ap.a_head.a_desc = &vop_old_rmdir_desc;
553 ap.a_head.a_ops = ops;
558 DO_OPS(ops, error, &ap, vop_old_rmdir);
563 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
564 struct vnode **vpp, struct componentname *cnp,
565 struct vattr *vap, char *target)
567 struct vop_old_symlink_args ap;
570 ap.a_head.a_desc = &vop_old_symlink_desc;
571 ap.a_head.a_ops = ops;
576 ap.a_target = target;
578 DO_OPS(ops, error, &ap, vop_old_symlink);
583 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
584 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
586 struct vop_readdir_args ap;
589 ap.a_head.a_desc = &vop_readdir_desc;
590 ap.a_head.a_ops = ops;
594 ap.a_eofflag = eofflag;
595 ap.a_ncookies = ncookies;
596 ap.a_cookies = cookies;
598 DO_OPS(ops, error, &ap, vop_readdir);
603 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
606 struct vop_readlink_args ap;
609 ap.a_head.a_desc = &vop_readlink_desc;
610 ap.a_head.a_ops = ops;
615 DO_OPS(ops, error, &ap, vop_readlink);
620 vop_inactive(struct vop_ops *ops, struct vnode *vp)
622 struct vop_inactive_args ap;
625 ap.a_head.a_desc = &vop_inactive_desc;
626 ap.a_head.a_ops = ops;
629 DO_OPS(ops, error, &ap, vop_inactive);
634 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
636 struct vop_reclaim_args ap;
639 ap.a_head.a_desc = &vop_reclaim_desc;
640 ap.a_head.a_ops = ops;
643 DO_OPS(ops, error, &ap, vop_reclaim);
648 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags)
650 struct vop_lock_args ap;
653 ap.a_head.a_desc = &vop_lock_desc;
654 ap.a_head.a_ops = ops;
658 DO_OPS(ops, error, &ap, vop_lock);
663 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags)
665 struct vop_unlock_args ap;
668 ap.a_head.a_desc = &vop_unlock_desc;
669 ap.a_head.a_ops = ops;
673 DO_OPS(ops, error, &ap, vop_unlock);
678 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
679 struct vnode **vpp, off_t *doffsetp, int *runp, int *runb)
681 struct vop_bmap_args ap;
684 ap.a_head.a_desc = &vop_bmap_desc;
685 ap.a_head.a_ops = ops;
687 ap.a_loffset = loffset;
689 ap.a_doffsetp = doffsetp;
693 DO_OPS(ops, error, &ap, vop_bmap);
698 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
700 struct vop_strategy_args ap;
703 ap.a_head.a_desc = &vop_strategy_desc;
704 ap.a_head.a_ops = ops;
708 DO_OPS(ops, error, &ap, vop_strategy);
709 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
710 cache_update_fsmid_vp(vp);
715 vop_print(struct vop_ops *ops, struct vnode *vp)
717 struct vop_print_args ap;
720 ap.a_head.a_desc = &vop_print_desc;
721 ap.a_head.a_ops = ops;
724 DO_OPS(ops, error, &ap, vop_print);
729 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
732 struct vop_pathconf_args ap;
735 ap.a_head.a_desc = &vop_pathconf_desc;
736 ap.a_head.a_ops = ops;
739 ap.a_retval = retval;
741 DO_OPS(ops, error, &ap, vop_pathconf);
746 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
747 struct flock *fl, int flags)
749 struct vop_advlock_args ap;
752 ap.a_head.a_desc = &vop_advlock_desc;
753 ap.a_head.a_ops = ops;
760 DO_OPS(ops, error, &ap, vop_advlock);
765 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
766 int size, struct ucred *cred, int flags,
769 struct vop_balloc_args ap;
772 ap.a_head.a_desc = &vop_balloc_desc;
773 ap.a_head.a_ops = ops;
775 ap.a_startoffset = startoffset;
781 DO_OPS(ops, error, &ap, vop_balloc);
786 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
787 struct cluster_save *buflist)
789 struct vop_reallocblks_args ap;
792 ap.a_head.a_desc = &vop_reallocblks_desc;
793 ap.a_head.a_ops = ops;
795 ap.a_buflist = buflist;
797 DO_OPS(ops, error, &ap, vop_reallocblks);
802 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
803 int reqpage, vm_ooffset_t offset)
805 struct vop_getpages_args ap;
808 ap.a_head.a_desc = &vop_getpages_desc;
809 ap.a_head.a_ops = ops;
813 ap.a_reqpage = reqpage;
814 ap.a_offset = offset;
816 DO_OPS(ops, error, &ap, vop_getpages);
821 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
822 int sync, int *rtvals, vm_ooffset_t offset)
824 struct vop_putpages_args ap;
827 ap.a_head.a_desc = &vop_putpages_desc;
828 ap.a_head.a_ops = ops;
833 ap.a_rtvals = rtvals;
834 ap.a_offset = offset;
836 DO_OPS(ops, error, &ap, vop_putpages);
838 cache_update_fsmid_vp(vp);
843 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
845 struct vop_freeblks_args ap;
848 ap.a_head.a_desc = &vop_freeblks_desc;
849 ap.a_head.a_ops = ops;
851 ap.a_offset = offset;
852 ap.a_length = length;
854 DO_OPS(ops, error, &ap, vop_freeblks);
859 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
860 struct acl *aclp, struct ucred *cred)
862 struct vop_getacl_args ap;
865 ap.a_head.a_desc = &vop_getacl_desc;
866 ap.a_head.a_ops = ops;
872 DO_OPS(ops, error, &ap, vop_getacl);
877 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
878 struct acl *aclp, struct ucred *cred)
880 struct vop_setacl_args ap;
883 ap.a_head.a_desc = &vop_setacl_desc;
884 ap.a_head.a_ops = ops;
890 DO_OPS(ops, error, &ap, vop_setacl);
892 cache_update_fsmid_vp(vp);
897 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
898 struct acl *aclp, struct ucred *cred)
900 struct vop_aclcheck_args ap;
903 ap.a_head.a_desc = &vop_aclcheck_desc;
904 ap.a_head.a_ops = ops;
910 DO_OPS(ops, error, &ap, vop_aclcheck);
915 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
916 struct uio *uio, struct ucred *cred)
918 struct vop_getextattr_args ap;
921 ap.a_head.a_desc = &vop_getextattr_desc;
922 ap.a_head.a_ops = ops;
928 DO_OPS(ops, error, &ap, vop_getextattr);
933 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
934 struct uio *uio, struct ucred *cred)
936 struct vop_setextattr_args ap;
939 ap.a_head.a_desc = &vop_setextattr_desc;
940 ap.a_head.a_ops = ops;
946 DO_OPS(ops, error, &ap, vop_setextattr);
948 cache_update_fsmid_vp(vp);
953 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
954 const void *ctl, int ctllen, void *buf, int buflen, int *res)
956 struct vop_mountctl_args ap;
959 ap.a_head.a_desc = &vop_mountctl_desc;
960 ap.a_head.a_ops = ops;
964 ap.a_ctllen = ctllen;
966 ap.a_buflen = buflen;
969 DO_OPS(ops, error, &ap, vop_mountctl);
976 * nresolve takes a locked ncp and a cred and resolves the ncp into a
977 * positive or negative hit.
979 * The namecache is automatically adjusted by this function. The ncp
980 * is left locked on return.
983 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
985 struct vop_nresolve_args ap;
988 ap.a_head.a_desc = &vop_nresolve_desc;
989 ap.a_head.a_ops = ops;
993 DO_OPS(ops, error, &ap, vop_nresolve);
998 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
999 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
1002 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1003 struct vnode **vpp, struct ucred *cred)
1005 struct vop_nlookupdotdot_args ap;
1008 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1009 ap.a_head.a_ops = ops;
1014 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1019 * ncreate takes a locked, resolved ncp that typically represents a negative
1020 * cache hit and creates the file or node specified by the ncp, cred, and
1021 * vattr. If no error occurs a locked vnode is returned in *vpp.
1023 * The namecache is automatically adjusted by this function. The ncp
1024 * is left locked on return.
1027 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1028 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1030 struct vop_ncreate_args ap;
1033 ap.a_head.a_desc = &vop_ncreate_desc;
1034 ap.a_head.a_ops = ops;
1040 DO_OPS(ops, error, &ap, vop_ncreate);
1041 if (error == 0 && *vpp)
1042 cache_update_fsmid_vp(*vpp);
1047 * nmkdir takes a locked, resolved ncp that typically represents a negative
1048 * cache hit and creates the directory specified by the ncp, cred, and
1049 * vattr. If no error occurs a locked vnode is returned in *vpp.
1051 * The namecache is automatically adjusted by this function. The ncp
1052 * is left locked on return.
1055 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1056 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1058 struct vop_nmkdir_args ap;
1061 ap.a_head.a_desc = &vop_nmkdir_desc;
1062 ap.a_head.a_ops = ops;
1068 DO_OPS(ops, error, &ap, vop_nmkdir);
1069 if (error == 0 && *vpp)
1070 cache_update_fsmid_vp(*vpp);
1075 * nmknod takes a locked, resolved ncp that typically represents a negative
1076 * cache hit and creates the node specified by the ncp, cred, and
1077 * vattr. If no error occurs a locked vnode is returned in *vpp.
1079 * The namecache is automatically adjusted by this function. The ncp
1080 * is left locked on return.
1083 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1084 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1086 struct vop_nmknod_args ap;
1089 ap.a_head.a_desc = &vop_nmknod_desc;
1090 ap.a_head.a_ops = ops;
1096 DO_OPS(ops, error, &ap, vop_nmknod);
1097 if (error == 0 && *vpp)
1098 cache_update_fsmid_vp(*vpp);
1103 * nlink takes a locked, resolved ncp that typically represents a negative
1104 * cache hit and creates the node specified by the ncp, cred, and
1105 * existing vnode. The passed vp must be locked and will remain locked
1106 * on return, as does the ncp, whether an error occurs or not.
1108 * The namecache is automatically adjusted by this function. The ncp
1109 * is left locked on return.
1112 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1113 struct vnode *vp, struct ucred *cred)
1115 struct vop_nlink_args ap;
1118 ap.a_head.a_desc = &vop_nlink_desc;
1119 ap.a_head.a_ops = ops;
1124 DO_OPS(ops, error, &ap, vop_nlink);
1126 cache_update_fsmid(ncp);
1131 * nsymlink takes a locked, resolved ncp that typically represents a negative
1132 * cache hit and creates a symbolic link based on cred, vap, and target (the
1133 * contents of the link). If no error occurs a locked vnode is returned in
1136 * The namecache is automatically adjusted by this function. The ncp
1137 * is left locked on return.
1140 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1141 struct vnode **vpp, struct ucred *cred,
1142 struct vattr *vap, char *target)
1144 struct vop_nsymlink_args ap;
1147 ap.a_head.a_desc = &vop_nsymlink_desc;
1148 ap.a_head.a_ops = ops;
1153 ap.a_target = target;
1155 DO_OPS(ops, error, &ap, vop_nsymlink);
1157 cache_update_fsmid(ncp);
1162 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1163 * negative hit and executes the whiteout function specified in flags.
1165 * The namecache is automatically adjusted by this function. The ncp
1166 * is left locked on return.
1169 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1170 struct ucred *cred, int flags)
1172 struct vop_nwhiteout_args ap;
1175 ap.a_head.a_desc = &vop_nwhiteout_desc;
1176 ap.a_head.a_ops = ops;
1181 DO_OPS(ops, error, &ap, vop_nwhiteout);
1183 cache_update_fsmid(ncp);
1188 * nremove takes a locked, resolved ncp that generally represents a
1189 * positive hit and removes the file.
1191 * The namecache is automatically adjusted by this function. The ncp
1192 * is left locked on return.
1195 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1197 struct vop_nremove_args ap;
1200 ap.a_head.a_desc = &vop_nremove_desc;
1201 ap.a_head.a_ops = ops;
1205 DO_OPS(ops, error, &ap, vop_nremove);
1207 cache_update_fsmid(ncp);
1212 * nrmdir takes a locked, resolved ncp that generally represents a
1213 * directory and removes the directory.
1215 * The namecache is automatically adjusted by this function. The ncp
1216 * is left locked on return.
1219 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1221 struct vop_nrmdir_args ap;
1224 ap.a_head.a_desc = &vop_nrmdir_desc;
1225 ap.a_head.a_ops = ops;
1229 DO_OPS(ops, error, &ap, vop_nrmdir);
1231 cache_update_fsmid(ncp);
1236 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1237 * and renames the source ncp to the target ncp. The target ncp may
1238 * represent a positive or negative hit.
1240 * The namecache is automatically adjusted by this function. The ncp
1241 * is left locked on return. The source ncp is typically changed to
1242 * a negative cache hit and the target ncp typically takes on the
1243 * source ncp's underlying file.
1246 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1247 struct namecache *tncp, struct ucred *cred)
1249 struct vop_nrename_args ap;
1252 ap.a_head.a_desc = &vop_nrename_desc;
1253 ap.a_head.a_ops = ops;
1258 DO_OPS(ops, error, &ap, vop_nrename);
1260 cache_update_fsmid(fncp);
1261 cache_update_fsmid(tncp);
1266 /************************************************************************
1267 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1268 ************************************************************************
1270 * These procedures are called from VFSs such as unionfs and nullfs
1271 * when they wish to forward an operation on one VFS to another. The
1272 * argument structure/message is modified and then directly passed to the
1273 * appropriate routine. This routines may also be called by initiators
1274 * who have an argument structure in hand rather then discreet arguments.
1277 vop_vnoperate_ap(struct vop_generic_args *ap)
1279 struct vop_ops *ops;
1283 error = VOCALL(ops, ap);
1289 * This routine is called by the cache coherency layer to execute the actual
1290 * VFS operation. If a journaling layer is present we call though it, else
1291 * we call the native VOP functions.
1294 vop_cache_operate_ap(struct vop_generic_args *ap)
1296 struct vop_ops *ops;
1300 if (ops->head.vv_mount->mnt_vn_journal_ops)
1301 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1303 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1309 * This routine is called by the journaling layer to execute the actual
1313 vop_journal_operate_ap(struct vop_generic_args *ap)
1315 struct vop_ops *ops;
1319 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1325 vop_islocked_ap(struct vop_islocked_args *ap)
1329 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1334 vop_open_ap(struct vop_open_args *ap)
1338 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1343 vop_close_ap(struct vop_close_args *ap)
1347 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1352 vop_access_ap(struct vop_access_args *ap)
1356 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1361 vop_getattr_ap(struct vop_getattr_args *ap)
1365 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1370 vop_setattr_ap(struct vop_setattr_args *ap)
1374 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1379 vop_read_ap(struct vop_read_args *ap)
1383 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1388 vop_write_ap(struct vop_write_args *ap)
1392 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1397 vop_ioctl_ap(struct vop_ioctl_args *ap)
1401 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1406 vop_poll_ap(struct vop_poll_args *ap)
1410 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1415 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1419 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1424 vop_revoke_ap(struct vop_revoke_args *ap)
1428 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1433 vop_mmap_ap(struct vop_mmap_args *ap)
1437 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1442 vop_fsync_ap(struct vop_fsync_args *ap)
1446 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1451 vop_readdir_ap(struct vop_readdir_args *ap)
1455 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1460 vop_readlink_ap(struct vop_readlink_args *ap)
1464 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1469 vop_inactive_ap(struct vop_inactive_args *ap)
1473 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1478 vop_reclaim_ap(struct vop_reclaim_args *ap)
1482 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1487 vop_lock_ap(struct vop_lock_args *ap)
1491 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1496 vop_unlock_ap(struct vop_unlock_args *ap)
1500 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1505 vop_bmap_ap(struct vop_bmap_args *ap)
1509 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1514 vop_strategy_ap(struct vop_strategy_args *ap)
1518 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1523 vop_print_ap(struct vop_print_args *ap)
1527 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1532 vop_pathconf_ap(struct vop_pathconf_args *ap)
1536 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1541 vop_advlock_ap(struct vop_advlock_args *ap)
1545 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1550 vop_balloc_ap(struct vop_balloc_args *ap)
1554 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1559 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1563 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1568 vop_getpages_ap(struct vop_getpages_args *ap)
1572 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1577 vop_putpages_ap(struct vop_putpages_args *ap)
1581 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1586 vop_freeblks_ap(struct vop_freeblks_args *ap)
1590 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1595 vop_getacl_ap(struct vop_getacl_args *ap)
1599 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1604 vop_setacl_ap(struct vop_setacl_args *ap)
1608 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1613 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1617 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1622 vop_getextattr_ap(struct vop_getextattr_args *ap)
1626 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1631 vop_setextattr_ap(struct vop_setextattr_args *ap)
1635 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1640 vop_mountctl_ap(struct vop_mountctl_args *ap)
1644 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1649 vop_nresolve_ap(struct vop_nresolve_args *ap)
1653 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1658 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1662 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1667 vop_ncreate_ap(struct vop_ncreate_args *ap)
1671 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1676 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1680 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1685 vop_nmknod_ap(struct vop_nmknod_args *ap)
1689 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1694 vop_nlink_ap(struct vop_nlink_args *ap)
1698 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1703 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1707 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1712 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1716 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1721 vop_nremove_ap(struct vop_nremove_args *ap)
1725 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1730 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1734 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1739 vop_nrename_ap(struct vop_nrename_args *ap)
1743 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);