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.39 2008/06/19 23:27:35 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>
61 #include <sys/sysmsg.h>
63 #include <machine/limits.h>
66 #include <vm/vm_object.h>
67 #include <vm/vm_extern.h>
68 #include <vm/vm_kern.h>
70 #include <vm/vm_map.h>
71 #include <vm/vm_page.h>
72 #include <vm/vm_pager.h>
73 #include <vm/vnode_pager.h>
74 #include <vm/vm_zone.h>
77 #include <sys/thread2.h>
79 #define VDESCNAME(name) __CONCAT(__CONCAT(vop_,name),_desc)
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(old_lookup);
88 VNODEOP_DESC_INIT(old_create);
89 VNODEOP_DESC_INIT(old_whiteout);
90 VNODEOP_DESC_INIT(old_mknod);
91 VNODEOP_DESC_INIT(open);
92 VNODEOP_DESC_INIT(close);
93 VNODEOP_DESC_INIT(access);
94 VNODEOP_DESC_INIT(getattr);
95 VNODEOP_DESC_INIT(setattr);
96 VNODEOP_DESC_INIT(read);
97 VNODEOP_DESC_INIT(write);
98 VNODEOP_DESC_INIT(ioctl);
99 VNODEOP_DESC_INIT(poll);
100 VNODEOP_DESC_INIT(kqfilter);
101 VNODEOP_DESC_INIT(mmap);
102 VNODEOP_DESC_INIT(fsync);
103 VNODEOP_DESC_INIT(old_remove);
104 VNODEOP_DESC_INIT(old_link);
105 VNODEOP_DESC_INIT(old_rename);
107 VNODEOP_DESC_INIT(old_mkdir);
108 VNODEOP_DESC_INIT(old_rmdir);
109 VNODEOP_DESC_INIT(old_symlink);
110 VNODEOP_DESC_INIT(readdir);
111 VNODEOP_DESC_INIT(readlink);
112 VNODEOP_DESC_INIT(inactive);
113 VNODEOP_DESC_INIT(reclaim);
114 VNODEOP_DESC_INIT(bmap);
115 VNODEOP_DESC_INIT(strategy);
116 VNODEOP_DESC_INIT(print);
117 VNODEOP_DESC_INIT(pathconf);
118 VNODEOP_DESC_INIT(advlock);
119 VNODEOP_DESC_INIT(balloc);
120 VNODEOP_DESC_INIT(reallocblks);
121 VNODEOP_DESC_INIT(getpages);
122 VNODEOP_DESC_INIT(putpages);
123 VNODEOP_DESC_INIT(freeblks);
124 VNODEOP_DESC_INIT(getacl);
125 VNODEOP_DESC_INIT(setacl);
126 VNODEOP_DESC_INIT(aclcheck);
127 VNODEOP_DESC_INIT(getextattr);
128 VNODEOP_DESC_INIT(setextattr);
129 VNODEOP_DESC_INIT(mountctl);
130 VNODEOP_DESC_INIT(markatime);
132 VNODEOP_DESC_INIT(nresolve);
133 VNODEOP_DESC_INIT(nlookupdotdot);
134 VNODEOP_DESC_INIT(ncreate);
135 VNODEOP_DESC_INIT(nmkdir);
136 VNODEOP_DESC_INIT(nmknod);
137 VNODEOP_DESC_INIT(nlink);
138 VNODEOP_DESC_INIT(nsymlink);
139 VNODEOP_DESC_INIT(nwhiteout);
140 VNODEOP_DESC_INIT(nremove);
141 VNODEOP_DESC_INIT(nrmdir);
142 VNODEOP_DESC_INIT(nrename);
144 #define DO_OPS(ops, error, ap, vop_field) \
145 error = ops->vop_field(ap);
147 /************************************************************************
148 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
149 ************************************************************************
151 * These procedures are called directly from the kernel and/or fileops
152 * code to perform file/device operations on the system.
154 * NOTE: The old namespace api functions such as vop_rename() are no longer
155 * available for general use and have been renamed to vop_old_*(). Only
156 * the code in vfs_default.c is allowed to call those ops.
160 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
161 struct vnode **vpp, struct componentname *cnp)
163 struct vop_old_lookup_args ap;
166 ap.a_head.a_desc = &vop_old_lookup_desc;
167 ap.a_head.a_ops = ops;
172 DO_OPS(ops, error, &ap, vop_old_lookup);
177 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
178 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
180 struct vop_old_create_args ap;
183 ap.a_head.a_desc = &vop_old_create_desc;
184 ap.a_head.a_ops = ops;
190 DO_OPS(ops, error, &ap, vop_old_create);
195 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
196 struct componentname *cnp, int flags)
198 struct vop_old_whiteout_args ap;
201 ap.a_head.a_desc = &vop_old_whiteout_desc;
202 ap.a_head.a_ops = ops;
207 DO_OPS(ops, error, &ap, vop_old_whiteout);
212 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
213 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
215 struct vop_old_mknod_args ap;
218 ap.a_head.a_desc = &vop_old_mknod_desc;
219 ap.a_head.a_ops = ops;
225 DO_OPS(ops, error, &ap, vop_old_mknod);
230 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
233 struct vop_open_args ap;
236 ap.a_head.a_desc = &vop_open_desc;
237 ap.a_head.a_ops = ops;
243 DO_OPS(ops, error, &ap, vop_open);
248 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
250 struct vop_close_args ap;
253 ap.a_head.a_desc = &vop_close_desc;
254 ap.a_head.a_ops = ops;
258 DO_OPS(ops, error, &ap, vop_close);
263 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, int flags,
266 struct vop_access_args ap;
269 ap.a_head.a_desc = &vop_access_desc;
270 ap.a_head.a_ops = ops;
276 DO_OPS(ops, error, &ap, vop_access);
281 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
283 struct vop_getattr_args ap;
286 ap.a_head.a_desc = &vop_getattr_desc;
287 ap.a_head.a_ops = ops;
291 DO_OPS(ops, error, &ap, vop_getattr);
294 * mount pointer may be NULL if vnode is dead.
296 if (ops->head.vv_mount &&
297 (ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0) {
298 vap->va_fsmid = cache_sync_fsmid_vp(vp);
304 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
307 struct vop_setattr_args ap;
310 ap.a_head.a_desc = &vop_setattr_desc;
311 ap.a_head.a_ops = ops;
316 DO_OPS(ops, error, &ap, vop_setattr);
318 cache_update_fsmid_vp(vp);
323 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
326 struct vop_read_args ap;
329 ap.a_head.a_desc = &vop_read_desc;
330 ap.a_head.a_ops = ops;
333 ap.a_ioflag = ioflag;
336 DO_OPS(ops, error, &ap, vop_read);
341 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
344 struct vop_write_args ap;
347 ap.a_head.a_desc = &vop_write_desc;
348 ap.a_head.a_ops = ops;
351 ap.a_ioflag = ioflag;
354 DO_OPS(ops, error, &ap, vop_write);
356 cache_update_fsmid_vp(vp);
361 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
362 int fflag, struct ucred *cred, struct sysmsg *msg)
364 struct vop_ioctl_args ap;
367 ap.a_head.a_desc = &vop_ioctl_desc;
368 ap.a_head.a_ops = ops;
370 ap.a_command = command;
376 DO_OPS(ops, error, &ap, vop_ioctl);
381 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
383 struct vop_poll_args ap;
386 ap.a_head.a_desc = &vop_poll_desc;
387 ap.a_head.a_ops = ops;
389 ap.a_events = events;
392 DO_OPS(ops, error, &ap, vop_poll);
397 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
399 struct vop_kqfilter_args ap;
402 ap.a_head.a_desc = &vop_kqfilter_desc;
403 ap.a_head.a_ops = ops;
407 DO_OPS(ops, error, &ap, vop_kqfilter);
412 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
414 struct vop_mmap_args ap;
417 ap.a_head.a_desc = &vop_mmap_desc;
418 ap.a_head.a_ops = ops;
420 ap.a_fflags = fflags;
423 DO_OPS(ops, error, &ap, vop_mmap);
428 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, int flags)
430 struct vop_fsync_args ap;
433 ap.a_head.a_desc = &vop_fsync_desc;
434 ap.a_head.a_ops = ops;
436 ap.a_waitfor = waitfor;
439 DO_OPS(ops, error, &ap, vop_fsync);
444 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
445 struct vnode *vp, struct componentname *cnp)
447 struct vop_old_remove_args ap;
450 ap.a_head.a_desc = &vop_old_remove_desc;
451 ap.a_head.a_ops = ops;
456 DO_OPS(ops, error, &ap, vop_old_remove);
461 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
462 struct vnode *vp, struct componentname *cnp)
464 struct vop_old_link_args ap;
467 ap.a_head.a_desc = &vop_old_link_desc;
468 ap.a_head.a_ops = ops;
473 DO_OPS(ops, error, &ap, vop_old_link);
478 vop_old_rename(struct vop_ops *ops,
479 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
480 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
482 struct vop_old_rename_args ap;
485 ap.a_head.a_desc = &vop_old_rename_desc;
486 ap.a_head.a_ops = ops;
494 DO_OPS(ops, error, &ap, vop_old_rename);
499 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
500 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
502 struct vop_old_mkdir_args ap;
505 ap.a_head.a_desc = &vop_old_mkdir_desc;
506 ap.a_head.a_ops = ops;
512 DO_OPS(ops, error, &ap, vop_old_mkdir);
517 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
518 struct vnode *vp, struct componentname *cnp)
520 struct vop_old_rmdir_args ap;
523 ap.a_head.a_desc = &vop_old_rmdir_desc;
524 ap.a_head.a_ops = ops;
529 DO_OPS(ops, error, &ap, vop_old_rmdir);
534 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
535 struct vnode **vpp, struct componentname *cnp,
536 struct vattr *vap, char *target)
538 struct vop_old_symlink_args ap;
541 ap.a_head.a_desc = &vop_old_symlink_desc;
542 ap.a_head.a_ops = ops;
547 ap.a_target = target;
549 DO_OPS(ops, error, &ap, vop_old_symlink);
554 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
555 struct ucred *cred, int *eofflag, int *ncookies, off_t **cookies)
557 struct vop_readdir_args ap;
560 ap.a_head.a_desc = &vop_readdir_desc;
561 ap.a_head.a_ops = ops;
565 ap.a_eofflag = eofflag;
566 ap.a_ncookies = ncookies;
567 ap.a_cookies = cookies;
569 DO_OPS(ops, error, &ap, vop_readdir);
574 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
577 struct vop_readlink_args ap;
580 ap.a_head.a_desc = &vop_readlink_desc;
581 ap.a_head.a_ops = ops;
586 DO_OPS(ops, error, &ap, vop_readlink);
591 vop_inactive(struct vop_ops *ops, struct vnode *vp)
593 struct vop_inactive_args ap;
596 ap.a_head.a_desc = &vop_inactive_desc;
597 ap.a_head.a_ops = ops;
600 DO_OPS(ops, error, &ap, vop_inactive);
605 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
607 struct vop_reclaim_args ap;
610 ap.a_head.a_desc = &vop_reclaim_desc;
611 ap.a_head.a_ops = ops;
614 DO_OPS(ops, error, &ap, vop_reclaim);
619 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
620 off_t *doffsetp, int *runp, int *runb, buf_cmd_t cmd)
622 struct vop_bmap_args ap;
625 ap.a_head.a_desc = &vop_bmap_desc;
626 ap.a_head.a_ops = ops;
628 ap.a_loffset = loffset;
629 ap.a_doffsetp = doffsetp;
634 DO_OPS(ops, error, &ap, vop_bmap);
639 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
641 struct vop_strategy_args ap;
644 ap.a_head.a_desc = &vop_strategy_desc;
645 ap.a_head.a_ops = ops;
649 DO_OPS(ops, error, &ap, vop_strategy);
650 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
651 cache_update_fsmid_vp(vp);
656 vop_print(struct vop_ops *ops, struct vnode *vp)
658 struct vop_print_args ap;
661 ap.a_head.a_desc = &vop_print_desc;
662 ap.a_head.a_ops = ops;
665 DO_OPS(ops, error, &ap, vop_print);
670 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
673 struct vop_pathconf_args ap;
676 ap.a_head.a_desc = &vop_pathconf_desc;
677 ap.a_head.a_ops = ops;
680 ap.a_retval = retval;
682 DO_OPS(ops, error, &ap, vop_pathconf);
687 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
688 struct flock *fl, int flags)
690 struct vop_advlock_args ap;
693 ap.a_head.a_desc = &vop_advlock_desc;
694 ap.a_head.a_ops = ops;
701 DO_OPS(ops, error, &ap, vop_advlock);
706 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
707 int size, struct ucred *cred, int flags,
710 struct vop_balloc_args ap;
713 ap.a_head.a_desc = &vop_balloc_desc;
714 ap.a_head.a_ops = ops;
716 ap.a_startoffset = startoffset;
722 DO_OPS(ops, error, &ap, vop_balloc);
727 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
728 struct cluster_save *buflist)
730 struct vop_reallocblks_args ap;
733 ap.a_head.a_desc = &vop_reallocblks_desc;
734 ap.a_head.a_ops = ops;
736 ap.a_buflist = buflist;
738 DO_OPS(ops, error, &ap, vop_reallocblks);
743 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
744 int reqpage, vm_ooffset_t offset)
746 struct vop_getpages_args ap;
749 ap.a_head.a_desc = &vop_getpages_desc;
750 ap.a_head.a_ops = ops;
754 ap.a_reqpage = reqpage;
755 ap.a_offset = offset;
757 DO_OPS(ops, error, &ap, vop_getpages);
762 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
763 int sync, int *rtvals, vm_ooffset_t offset)
765 struct vop_putpages_args ap;
768 ap.a_head.a_desc = &vop_putpages_desc;
769 ap.a_head.a_ops = ops;
774 ap.a_rtvals = rtvals;
775 ap.a_offset = offset;
777 DO_OPS(ops, error, &ap, vop_putpages);
779 cache_update_fsmid_vp(vp);
784 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
786 struct vop_freeblks_args ap;
789 ap.a_head.a_desc = &vop_freeblks_desc;
790 ap.a_head.a_ops = ops;
792 ap.a_offset = offset;
793 ap.a_length = length;
795 DO_OPS(ops, error, &ap, vop_freeblks);
800 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
801 struct acl *aclp, struct ucred *cred)
803 struct vop_getacl_args ap;
806 ap.a_head.a_desc = &vop_getacl_desc;
807 ap.a_head.a_ops = ops;
813 DO_OPS(ops, error, &ap, vop_getacl);
818 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
819 struct acl *aclp, struct ucred *cred)
821 struct vop_setacl_args ap;
824 ap.a_head.a_desc = &vop_setacl_desc;
825 ap.a_head.a_ops = ops;
831 DO_OPS(ops, error, &ap, vop_setacl);
833 cache_update_fsmid_vp(vp);
838 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
839 struct acl *aclp, struct ucred *cred)
841 struct vop_aclcheck_args ap;
844 ap.a_head.a_desc = &vop_aclcheck_desc;
845 ap.a_head.a_ops = ops;
851 DO_OPS(ops, error, &ap, vop_aclcheck);
856 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
857 struct uio *uio, struct ucred *cred)
859 struct vop_getextattr_args ap;
862 ap.a_head.a_desc = &vop_getextattr_desc;
863 ap.a_head.a_ops = ops;
869 DO_OPS(ops, error, &ap, vop_getextattr);
874 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
875 struct uio *uio, struct ucred *cred)
877 struct vop_setextattr_args ap;
880 ap.a_head.a_desc = &vop_setextattr_desc;
881 ap.a_head.a_ops = ops;
887 DO_OPS(ops, error, &ap, vop_setextattr);
889 cache_update_fsmid_vp(vp);
894 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
895 const void *ctl, int ctllen, void *buf, int buflen, int *res)
897 struct vop_mountctl_args ap;
900 ap.a_head.a_desc = &vop_mountctl_desc;
901 ap.a_head.a_ops = ops;
905 ap.a_ctllen = ctllen;
907 ap.a_buflen = buflen;
910 DO_OPS(ops, error, &ap, vop_mountctl);
915 vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
917 struct vop_markatime_args ap;
920 ap.a_head.a_desc = &vop_markatime_desc;
921 ap.a_head.a_ops = ops;
925 DO_OPS(ops, error, &ap, vop_markatime);
932 * nresolve takes a locked ncp, a referenced but unlocked dvp, and a cred,
933 * and resolves the ncp into a positive or negative hit.
935 * The namecache is automatically adjusted by this function. The ncp
936 * is left locked on return.
939 vop_nresolve(struct vop_ops *ops, struct nchandle *nch,
940 struct vnode *dvp, struct ucred *cred)
942 struct vop_nresolve_args ap;
945 ap.a_head.a_desc = &vop_nresolve_desc;
946 ap.a_head.a_ops = ops;
951 DO_OPS(ops, error, &ap, vop_nresolve);
956 * nlookupdotdot takes an unlocked directory, referenced dvp, and looks
957 * up "..", returning a locked parent directory in *vpp. If an error
958 * occurs *vpp will be NULL.
961 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
962 struct vnode **vpp, struct ucred *cred, char **fakename)
964 struct vop_nlookupdotdot_args ap;
967 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
968 ap.a_head.a_ops = ops;
972 ap.a_fakename = fakename;
974 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
979 * ncreate takes a locked, resolved ncp that typically represents a negative
980 * cache hit and creates the file or node specified by the ncp, cred, and
981 * vattr. If no error occurs a locked vnode is returned in *vpp.
983 * The dvp passed in is referenced but unlocked.
985 * The namecache is automatically adjusted by this function. The ncp
986 * is left locked on return.
989 vop_ncreate(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
990 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
992 struct vop_ncreate_args ap;
995 ap.a_head.a_desc = &vop_ncreate_desc;
996 ap.a_head.a_ops = ops;
1003 DO_OPS(ops, error, &ap, vop_ncreate);
1004 if (error == 0 && *vpp)
1005 cache_update_fsmid_vp(*vpp);
1010 * nmkdir takes a locked, resolved ncp that typically represents a negative
1011 * cache hit and creates the directory specified by the ncp, cred, and
1012 * vattr. If no error occurs a locked vnode is returned in *vpp.
1014 * The dvp passed in is referenced but unlocked.
1016 * The namecache is automatically adjusted by this function. The ncp
1017 * is left locked on return.
1020 vop_nmkdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1021 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1023 struct vop_nmkdir_args ap;
1026 ap.a_head.a_desc = &vop_nmkdir_desc;
1027 ap.a_head.a_ops = ops;
1034 DO_OPS(ops, error, &ap, vop_nmkdir);
1035 if (error == 0 && *vpp)
1036 cache_update_fsmid_vp(*vpp);
1041 * nmknod takes a locked, resolved ncp that typically represents a negative
1042 * cache hit and creates the node specified by the ncp, cred, and
1043 * vattr. If no error occurs a locked vnode is returned in *vpp.
1045 * The dvp passed in is referenced but unlocked.
1047 * The namecache is automatically adjusted by this function. The ncp
1048 * is left locked on return.
1051 vop_nmknod(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1052 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1054 struct vop_nmknod_args ap;
1057 ap.a_head.a_desc = &vop_nmknod_desc;
1058 ap.a_head.a_ops = ops;
1065 DO_OPS(ops, error, &ap, vop_nmknod);
1066 if (error == 0 && *vpp)
1067 cache_update_fsmid_vp(*vpp);
1072 * nlink takes a locked, resolved ncp that typically represents a negative
1073 * cache hit and creates the node specified by the ncp, cred, and
1074 * existing vnode. The passed vp must be locked and will remain locked
1075 * on return, as does the ncp, whether an error occurs or not.
1077 * The dvp passed in is referenced but unlocked.
1079 * The namecache is automatically adjusted by this function. The ncp
1080 * is left locked on return.
1083 vop_nlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1084 struct vnode *vp, struct ucred *cred)
1086 struct vop_nlink_args ap;
1089 ap.a_head.a_desc = &vop_nlink_desc;
1090 ap.a_head.a_ops = ops;
1096 DO_OPS(ops, error, &ap, vop_nlink);
1098 cache_update_fsmid(nch);
1103 * nsymlink takes a locked, resolved ncp that typically represents a negative
1104 * cache hit and creates a symbolic link based on cred, vap, and target (the
1105 * contents of the link). If no error occurs a locked vnode is returned in
1108 * The dvp passed in is referenced but unlocked.
1110 * The namecache is automatically adjusted by this function. The ncp
1111 * is left locked on return.
1114 vop_nsymlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1115 struct vnode **vpp, struct ucred *cred,
1116 struct vattr *vap, char *target)
1118 struct vop_nsymlink_args ap;
1121 ap.a_head.a_desc = &vop_nsymlink_desc;
1122 ap.a_head.a_ops = ops;
1128 ap.a_target = target;
1130 DO_OPS(ops, error, &ap, vop_nsymlink);
1132 cache_update_fsmid(nch);
1137 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1138 * negative hit and executes the whiteout function specified in flags.
1140 * The dvp passed in is referenced but unlocked.
1142 * The namecache is automatically adjusted by this function. The ncp
1143 * is left locked on return.
1146 vop_nwhiteout(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1147 struct ucred *cred, int flags)
1149 struct vop_nwhiteout_args ap;
1152 ap.a_head.a_desc = &vop_nwhiteout_desc;
1153 ap.a_head.a_ops = ops;
1159 DO_OPS(ops, error, &ap, vop_nwhiteout);
1161 cache_update_fsmid(nch);
1166 * nremove takes a locked, resolved ncp that generally represents a
1167 * positive hit and removes the file.
1169 * The dvp passed in is referenced but unlocked.
1171 * The namecache is automatically adjusted by this function. The ncp
1172 * is left locked on return.
1175 vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1178 struct vop_nremove_args ap;
1181 ap.a_head.a_desc = &vop_nremove_desc;
1182 ap.a_head.a_ops = ops;
1187 DO_OPS(ops, error, &ap, vop_nremove);
1189 cache_update_fsmid(nch);
1194 * nrmdir takes a locked, resolved ncp that generally represents a
1195 * directory and removes the directory.
1197 * The dvp passed in is referenced but unlocked.
1199 * The namecache is automatically adjusted by this function. The ncp
1200 * is left locked on return.
1203 vop_nrmdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1206 struct vop_nrmdir_args ap;
1209 ap.a_head.a_desc = &vop_nrmdir_desc;
1210 ap.a_head.a_ops = ops;
1215 DO_OPS(ops, error, &ap, vop_nrmdir);
1217 cache_update_fsmid(nch);
1222 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1223 * and renames the source ncp to the target ncp. The target ncp may
1224 * represent a positive or negative hit.
1226 * The fdvp and tdvp passed in are referenced but unlocked.
1228 * The namecache is automatically adjusted by this function. The ncp
1229 * is left locked on return. The source ncp is typically changed to
1230 * a negative cache hit and the target ncp typically takes on the
1231 * source ncp's underlying file.
1234 vop_nrename(struct vop_ops *ops,
1235 struct nchandle *fnch, struct nchandle *tnch,
1236 struct vnode *fdvp, struct vnode *tdvp,
1239 struct vop_nrename_args ap;
1242 ap.a_head.a_desc = &vop_nrename_desc;
1243 ap.a_head.a_ops = ops;
1250 DO_OPS(ops, error, &ap, vop_nrename);
1252 cache_update_fsmid(fnch);
1253 cache_update_fsmid(tnch);
1258 /************************************************************************
1259 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1260 ************************************************************************
1262 * These procedures are called from VFSs such as unionfs and nullfs
1263 * when they wish to forward an operation on one VFS to another. The
1264 * argument structure/message is modified and then directly passed to the
1265 * appropriate routine. This routines may also be called by initiators
1266 * who have an argument structure in hand rather then discreet arguments.
1269 vop_vnoperate_ap(struct vop_generic_args *ap)
1271 struct vop_ops *ops;
1275 error = VOCALL(ops, ap);
1281 * This routine is called by the cache coherency layer to execute the actual
1282 * VFS operation. If a journaling layer is present we call though it, else
1283 * we call the native VOP functions.
1286 vop_cache_operate_ap(struct vop_generic_args *ap)
1288 struct vop_ops *ops;
1292 if (ops->head.vv_mount->mnt_vn_journal_ops)
1293 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1295 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1301 * This routine is called by the journaling layer to execute the actual
1305 vop_journal_operate_ap(struct vop_generic_args *ap)
1307 struct vop_ops *ops;
1311 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1317 vop_open_ap(struct vop_open_args *ap)
1321 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1326 vop_close_ap(struct vop_close_args *ap)
1330 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1335 vop_access_ap(struct vop_access_args *ap)
1339 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1344 vop_getattr_ap(struct vop_getattr_args *ap)
1348 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1353 vop_setattr_ap(struct vop_setattr_args *ap)
1357 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1362 vop_read_ap(struct vop_read_args *ap)
1366 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1371 vop_write_ap(struct vop_write_args *ap)
1375 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1380 vop_ioctl_ap(struct vop_ioctl_args *ap)
1384 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1389 vop_poll_ap(struct vop_poll_args *ap)
1393 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1398 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1402 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1407 vop_mmap_ap(struct vop_mmap_args *ap)
1411 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1416 vop_fsync_ap(struct vop_fsync_args *ap)
1420 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1425 vop_readdir_ap(struct vop_readdir_args *ap)
1429 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1434 vop_readlink_ap(struct vop_readlink_args *ap)
1438 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1443 vop_inactive_ap(struct vop_inactive_args *ap)
1447 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1452 vop_reclaim_ap(struct vop_reclaim_args *ap)
1456 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1461 vop_bmap_ap(struct vop_bmap_args *ap)
1465 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1470 vop_strategy_ap(struct vop_strategy_args *ap)
1474 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1479 vop_print_ap(struct vop_print_args *ap)
1483 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1488 vop_pathconf_ap(struct vop_pathconf_args *ap)
1492 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1497 vop_advlock_ap(struct vop_advlock_args *ap)
1501 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1506 vop_balloc_ap(struct vop_balloc_args *ap)
1510 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1515 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1519 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1524 vop_getpages_ap(struct vop_getpages_args *ap)
1528 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1533 vop_putpages_ap(struct vop_putpages_args *ap)
1537 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1542 vop_freeblks_ap(struct vop_freeblks_args *ap)
1546 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1551 vop_getacl_ap(struct vop_getacl_args *ap)
1555 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1560 vop_setacl_ap(struct vop_setacl_args *ap)
1564 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1569 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1573 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1578 vop_getextattr_ap(struct vop_getextattr_args *ap)
1582 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1587 vop_setextattr_ap(struct vop_setextattr_args *ap)
1591 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1596 vop_mountctl_ap(struct vop_mountctl_args *ap)
1600 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1605 vop_markatime_ap(struct vop_markatime_args *ap)
1609 DO_OPS(ap->a_head.a_ops, error, ap, vop_markatime);
1614 vop_nresolve_ap(struct vop_nresolve_args *ap)
1618 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1623 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1627 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1632 vop_ncreate_ap(struct vop_ncreate_args *ap)
1636 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1641 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1645 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1650 vop_nmknod_ap(struct vop_nmknod_args *ap)
1654 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1659 vop_nlink_ap(struct vop_nlink_args *ap)
1663 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1668 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1672 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1677 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1681 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1686 vop_nremove_ap(struct vop_nremove_args *ap)
1690 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1695 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1699 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1704 vop_nrename_ap(struct vop_nrename_args *ap)
1708 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);