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>
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)
80 #define VNODEOP_DESC_INIT(name) \
81 struct syslink_desc VDESCNAME(name) = { \
82 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
85 VNODEOP_DESC_INIT(default);
86 VNODEOP_DESC_INIT(old_lookup);
87 VNODEOP_DESC_INIT(old_create);
88 VNODEOP_DESC_INIT(old_whiteout);
89 VNODEOP_DESC_INIT(old_mknod);
90 VNODEOP_DESC_INIT(open);
91 VNODEOP_DESC_INIT(close);
92 VNODEOP_DESC_INIT(access);
93 VNODEOP_DESC_INIT(getattr);
94 VNODEOP_DESC_INIT(setattr);
95 VNODEOP_DESC_INIT(read);
96 VNODEOP_DESC_INIT(write);
97 VNODEOP_DESC_INIT(ioctl);
98 VNODEOP_DESC_INIT(poll);
99 VNODEOP_DESC_INIT(kqfilter);
100 VNODEOP_DESC_INIT(mmap);
101 VNODEOP_DESC_INIT(fsync);
102 VNODEOP_DESC_INIT(old_remove);
103 VNODEOP_DESC_INIT(old_link);
104 VNODEOP_DESC_INIT(old_rename);
106 VNODEOP_DESC_INIT(old_mkdir);
107 VNODEOP_DESC_INIT(old_rmdir);
108 VNODEOP_DESC_INIT(old_symlink);
109 VNODEOP_DESC_INIT(readdir);
110 VNODEOP_DESC_INIT(readlink);
111 VNODEOP_DESC_INIT(inactive);
112 VNODEOP_DESC_INIT(reclaim);
113 VNODEOP_DESC_INIT(bmap);
114 VNODEOP_DESC_INIT(strategy);
115 VNODEOP_DESC_INIT(print);
116 VNODEOP_DESC_INIT(pathconf);
117 VNODEOP_DESC_INIT(advlock);
118 VNODEOP_DESC_INIT(balloc);
119 VNODEOP_DESC_INIT(reallocblks);
120 VNODEOP_DESC_INIT(getpages);
121 VNODEOP_DESC_INIT(putpages);
122 VNODEOP_DESC_INIT(freeblks);
123 VNODEOP_DESC_INIT(getacl);
124 VNODEOP_DESC_INIT(setacl);
125 VNODEOP_DESC_INIT(aclcheck);
126 VNODEOP_DESC_INIT(getextattr);
127 VNODEOP_DESC_INIT(setextattr);
128 VNODEOP_DESC_INIT(mountctl);
129 VNODEOP_DESC_INIT(markatime);
131 VNODEOP_DESC_INIT(nresolve);
132 VNODEOP_DESC_INIT(nlookupdotdot);
133 VNODEOP_DESC_INIT(ncreate);
134 VNODEOP_DESC_INIT(nmkdir);
135 VNODEOP_DESC_INIT(nmknod);
136 VNODEOP_DESC_INIT(nlink);
137 VNODEOP_DESC_INIT(nsymlink);
138 VNODEOP_DESC_INIT(nwhiteout);
139 VNODEOP_DESC_INIT(nremove);
140 VNODEOP_DESC_INIT(nrmdir);
141 VNODEOP_DESC_INIT(nrename);
143 #define DO_OPS(ops, error, ap, vop_field) \
144 error = ops->vop_field(ap);
146 /************************************************************************
147 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
148 ************************************************************************
150 * These procedures are called directly from the kernel and/or fileops
151 * code to perform file/device operations on the system.
153 * NOTE: The old namespace api functions such as vop_rename() are no longer
154 * available for general use and have been renamed to vop_old_*(). Only
155 * the code in vfs_default.c is allowed to call those ops.
159 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
160 struct vnode **vpp, struct componentname *cnp)
162 struct vop_old_lookup_args ap;
165 ap.a_head.a_desc = &vop_old_lookup_desc;
166 ap.a_head.a_ops = ops;
171 DO_OPS(ops, error, &ap, vop_old_lookup);
176 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
177 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
179 struct vop_old_create_args ap;
182 ap.a_head.a_desc = &vop_old_create_desc;
183 ap.a_head.a_ops = ops;
189 DO_OPS(ops, error, &ap, vop_old_create);
194 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
195 struct componentname *cnp, int flags)
197 struct vop_old_whiteout_args ap;
200 ap.a_head.a_desc = &vop_old_whiteout_desc;
201 ap.a_head.a_ops = ops;
206 DO_OPS(ops, error, &ap, vop_old_whiteout);
211 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
212 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
214 struct vop_old_mknod_args ap;
217 ap.a_head.a_desc = &vop_old_mknod_desc;
218 ap.a_head.a_ops = ops;
224 DO_OPS(ops, error, &ap, vop_old_mknod);
229 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
232 struct vop_open_args ap;
235 ap.a_head.a_desc = &vop_open_desc;
236 ap.a_head.a_ops = ops;
242 DO_OPS(ops, error, &ap, vop_open);
247 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
249 struct vop_close_args ap;
252 ap.a_head.a_desc = &vop_close_desc;
253 ap.a_head.a_ops = ops;
257 DO_OPS(ops, error, &ap, vop_close);
262 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred)
264 struct vop_access_args ap;
267 ap.a_head.a_desc = &vop_access_desc;
268 ap.a_head.a_ops = ops;
273 DO_OPS(ops, error, &ap, vop_access);
278 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
280 struct vop_getattr_args ap;
283 ap.a_head.a_desc = &vop_getattr_desc;
284 ap.a_head.a_ops = ops;
288 DO_OPS(ops, error, &ap, vop_getattr);
291 * mount pointer may be NULL if vnode is dead.
293 if (ops->head.vv_mount &&
294 (ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0) {
295 vap->va_fsmid = cache_sync_fsmid_vp(vp);
301 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
304 struct vop_setattr_args ap;
307 ap.a_head.a_desc = &vop_setattr_desc;
308 ap.a_head.a_ops = ops;
313 DO_OPS(ops, error, &ap, vop_setattr);
315 cache_update_fsmid_vp(vp);
320 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
323 struct vop_read_args ap;
326 ap.a_head.a_desc = &vop_read_desc;
327 ap.a_head.a_ops = ops;
330 ap.a_ioflag = ioflag;
333 DO_OPS(ops, error, &ap, vop_read);
338 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
341 struct vop_write_args ap;
344 ap.a_head.a_desc = &vop_write_desc;
345 ap.a_head.a_ops = ops;
348 ap.a_ioflag = ioflag;
351 DO_OPS(ops, error, &ap, vop_write);
353 cache_update_fsmid_vp(vp);
358 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
359 int fflag, struct ucred *cred)
361 struct vop_ioctl_args ap;
364 ap.a_head.a_desc = &vop_ioctl_desc;
365 ap.a_head.a_ops = ops;
367 ap.a_command = command;
372 DO_OPS(ops, error, &ap, vop_ioctl);
377 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
379 struct vop_poll_args ap;
382 ap.a_head.a_desc = &vop_poll_desc;
383 ap.a_head.a_ops = ops;
385 ap.a_events = events;
388 DO_OPS(ops, error, &ap, vop_poll);
393 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
395 struct vop_kqfilter_args ap;
398 ap.a_head.a_desc = &vop_kqfilter_desc;
399 ap.a_head.a_ops = ops;
403 DO_OPS(ops, error, &ap, vop_kqfilter);
408 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
410 struct vop_mmap_args ap;
413 ap.a_head.a_desc = &vop_mmap_desc;
414 ap.a_head.a_ops = ops;
416 ap.a_fflags = fflags;
419 DO_OPS(ops, error, &ap, vop_mmap);
424 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor)
426 struct vop_fsync_args ap;
429 ap.a_head.a_desc = &vop_fsync_desc;
430 ap.a_head.a_ops = ops;
432 ap.a_waitfor = waitfor;
434 DO_OPS(ops, error, &ap, vop_fsync);
439 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
440 struct vnode *vp, struct componentname *cnp)
442 struct vop_old_remove_args ap;
445 ap.a_head.a_desc = &vop_old_remove_desc;
446 ap.a_head.a_ops = ops;
451 DO_OPS(ops, error, &ap, vop_old_remove);
456 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
457 struct vnode *vp, struct componentname *cnp)
459 struct vop_old_link_args ap;
462 ap.a_head.a_desc = &vop_old_link_desc;
463 ap.a_head.a_ops = ops;
468 DO_OPS(ops, error, &ap, vop_old_link);
473 vop_old_rename(struct vop_ops *ops,
474 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
475 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
477 struct vop_old_rename_args ap;
480 ap.a_head.a_desc = &vop_old_rename_desc;
481 ap.a_head.a_ops = ops;
489 DO_OPS(ops, error, &ap, vop_old_rename);
494 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
495 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
497 struct vop_old_mkdir_args ap;
500 ap.a_head.a_desc = &vop_old_mkdir_desc;
501 ap.a_head.a_ops = ops;
507 DO_OPS(ops, error, &ap, vop_old_mkdir);
512 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
513 struct vnode *vp, struct componentname *cnp)
515 struct vop_old_rmdir_args ap;
518 ap.a_head.a_desc = &vop_old_rmdir_desc;
519 ap.a_head.a_ops = ops;
524 DO_OPS(ops, error, &ap, vop_old_rmdir);
529 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
530 struct vnode **vpp, struct componentname *cnp,
531 struct vattr *vap, char *target)
533 struct vop_old_symlink_args ap;
536 ap.a_head.a_desc = &vop_old_symlink_desc;
537 ap.a_head.a_ops = ops;
542 ap.a_target = target;
544 DO_OPS(ops, error, &ap, vop_old_symlink);
549 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
550 struct ucred *cred, int *eofflag, int *ncookies, off_t **cookies)
552 struct vop_readdir_args ap;
555 ap.a_head.a_desc = &vop_readdir_desc;
556 ap.a_head.a_ops = ops;
560 ap.a_eofflag = eofflag;
561 ap.a_ncookies = ncookies;
562 ap.a_cookies = cookies;
564 DO_OPS(ops, error, &ap, vop_readdir);
569 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
572 struct vop_readlink_args ap;
575 ap.a_head.a_desc = &vop_readlink_desc;
576 ap.a_head.a_ops = ops;
581 DO_OPS(ops, error, &ap, vop_readlink);
586 vop_inactive(struct vop_ops *ops, struct vnode *vp)
588 struct vop_inactive_args ap;
591 ap.a_head.a_desc = &vop_inactive_desc;
592 ap.a_head.a_ops = ops;
595 DO_OPS(ops, error, &ap, vop_inactive);
600 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
602 struct vop_reclaim_args ap;
605 ap.a_head.a_desc = &vop_reclaim_desc;
606 ap.a_head.a_ops = ops;
609 DO_OPS(ops, error, &ap, vop_reclaim);
614 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
615 off_t *doffsetp, int *runp, int *runb, buf_cmd_t cmd)
617 struct vop_bmap_args ap;
620 ap.a_head.a_desc = &vop_bmap_desc;
621 ap.a_head.a_ops = ops;
623 ap.a_loffset = loffset;
624 ap.a_doffsetp = doffsetp;
629 DO_OPS(ops, error, &ap, vop_bmap);
634 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
636 struct vop_strategy_args ap;
639 ap.a_head.a_desc = &vop_strategy_desc;
640 ap.a_head.a_ops = ops;
644 DO_OPS(ops, error, &ap, vop_strategy);
645 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
646 cache_update_fsmid_vp(vp);
651 vop_print(struct vop_ops *ops, struct vnode *vp)
653 struct vop_print_args ap;
656 ap.a_head.a_desc = &vop_print_desc;
657 ap.a_head.a_ops = ops;
660 DO_OPS(ops, error, &ap, vop_print);
665 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
668 struct vop_pathconf_args ap;
671 ap.a_head.a_desc = &vop_pathconf_desc;
672 ap.a_head.a_ops = ops;
675 ap.a_retval = retval;
677 DO_OPS(ops, error, &ap, vop_pathconf);
682 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
683 struct flock *fl, int flags)
685 struct vop_advlock_args ap;
688 ap.a_head.a_desc = &vop_advlock_desc;
689 ap.a_head.a_ops = ops;
696 DO_OPS(ops, error, &ap, vop_advlock);
701 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
702 int size, struct ucred *cred, int flags,
705 struct vop_balloc_args ap;
708 ap.a_head.a_desc = &vop_balloc_desc;
709 ap.a_head.a_ops = ops;
711 ap.a_startoffset = startoffset;
717 DO_OPS(ops, error, &ap, vop_balloc);
722 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
723 struct cluster_save *buflist)
725 struct vop_reallocblks_args ap;
728 ap.a_head.a_desc = &vop_reallocblks_desc;
729 ap.a_head.a_ops = ops;
731 ap.a_buflist = buflist;
733 DO_OPS(ops, error, &ap, vop_reallocblks);
738 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
739 int reqpage, vm_ooffset_t offset)
741 struct vop_getpages_args ap;
744 ap.a_head.a_desc = &vop_getpages_desc;
745 ap.a_head.a_ops = ops;
749 ap.a_reqpage = reqpage;
750 ap.a_offset = offset;
752 DO_OPS(ops, error, &ap, vop_getpages);
757 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
758 int sync, int *rtvals, vm_ooffset_t offset)
760 struct vop_putpages_args ap;
763 ap.a_head.a_desc = &vop_putpages_desc;
764 ap.a_head.a_ops = ops;
769 ap.a_rtvals = rtvals;
770 ap.a_offset = offset;
772 DO_OPS(ops, error, &ap, vop_putpages);
774 cache_update_fsmid_vp(vp);
779 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
781 struct vop_freeblks_args ap;
784 ap.a_head.a_desc = &vop_freeblks_desc;
785 ap.a_head.a_ops = ops;
787 ap.a_offset = offset;
788 ap.a_length = length;
790 DO_OPS(ops, error, &ap, vop_freeblks);
795 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
796 struct acl *aclp, struct ucred *cred)
798 struct vop_getacl_args ap;
801 ap.a_head.a_desc = &vop_getacl_desc;
802 ap.a_head.a_ops = ops;
808 DO_OPS(ops, error, &ap, vop_getacl);
813 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
814 struct acl *aclp, struct ucred *cred)
816 struct vop_setacl_args ap;
819 ap.a_head.a_desc = &vop_setacl_desc;
820 ap.a_head.a_ops = ops;
826 DO_OPS(ops, error, &ap, vop_setacl);
828 cache_update_fsmid_vp(vp);
833 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
834 struct acl *aclp, struct ucred *cred)
836 struct vop_aclcheck_args ap;
839 ap.a_head.a_desc = &vop_aclcheck_desc;
840 ap.a_head.a_ops = ops;
846 DO_OPS(ops, error, &ap, vop_aclcheck);
851 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
852 struct uio *uio, struct ucred *cred)
854 struct vop_getextattr_args ap;
857 ap.a_head.a_desc = &vop_getextattr_desc;
858 ap.a_head.a_ops = ops;
864 DO_OPS(ops, error, &ap, vop_getextattr);
869 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
870 struct uio *uio, struct ucred *cred)
872 struct vop_setextattr_args ap;
875 ap.a_head.a_desc = &vop_setextattr_desc;
876 ap.a_head.a_ops = ops;
882 DO_OPS(ops, error, &ap, vop_setextattr);
884 cache_update_fsmid_vp(vp);
889 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
890 const void *ctl, int ctllen, void *buf, int buflen, int *res)
892 struct vop_mountctl_args ap;
895 ap.a_head.a_desc = &vop_mountctl_desc;
896 ap.a_head.a_ops = ops;
900 ap.a_ctllen = ctllen;
902 ap.a_buflen = buflen;
905 DO_OPS(ops, error, &ap, vop_mountctl);
910 vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
912 struct vop_markatime_args ap;
915 ap.a_head.a_desc = &vop_markatime_desc;
916 ap.a_head.a_ops = ops;
920 DO_OPS(ops, error, &ap, vop_markatime);
927 * nresolve takes a locked ncp, a referenced but unlocked dvp, and a cred,
928 * and resolves the ncp into a positive or negative hit.
930 * The namecache is automatically adjusted by this function. The ncp
931 * is left locked on return.
934 vop_nresolve(struct vop_ops *ops, struct nchandle *nch,
935 struct vnode *dvp, struct ucred *cred)
937 struct vop_nresolve_args ap;
940 ap.a_head.a_desc = &vop_nresolve_desc;
941 ap.a_head.a_ops = ops;
946 DO_OPS(ops, error, &ap, vop_nresolve);
951 * nlookupdotdot takes an unlocked directory, referenced dvp, and looks
952 * up "..", returning a locked parent directory in *vpp. If an error
953 * occurs *vpp will be NULL.
956 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
957 struct vnode **vpp, struct ucred *cred, char **fakename)
959 struct vop_nlookupdotdot_args ap;
962 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
963 ap.a_head.a_ops = ops;
967 ap.a_fakename = fakename;
969 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
974 * ncreate takes a locked, resolved ncp that typically represents a negative
975 * cache hit and creates the file or node specified by the ncp, cred, and
976 * vattr. If no error occurs a locked vnode is returned in *vpp.
978 * The dvp passed in is referenced but unlocked.
980 * The namecache is automatically adjusted by this function. The ncp
981 * is left locked on return.
984 vop_ncreate(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
985 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
987 struct vop_ncreate_args ap;
990 ap.a_head.a_desc = &vop_ncreate_desc;
991 ap.a_head.a_ops = ops;
998 DO_OPS(ops, error, &ap, vop_ncreate);
999 if (error == 0 && *vpp)
1000 cache_update_fsmid_vp(*vpp);
1005 * nmkdir takes a locked, resolved ncp that typically represents a negative
1006 * cache hit and creates the directory specified by the ncp, cred, and
1007 * vattr. If no error occurs a locked vnode is returned in *vpp.
1009 * The dvp passed in is referenced but unlocked.
1011 * The namecache is automatically adjusted by this function. The ncp
1012 * is left locked on return.
1015 vop_nmkdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1016 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1018 struct vop_nmkdir_args ap;
1021 ap.a_head.a_desc = &vop_nmkdir_desc;
1022 ap.a_head.a_ops = ops;
1029 DO_OPS(ops, error, &ap, vop_nmkdir);
1030 if (error == 0 && *vpp)
1031 cache_update_fsmid_vp(*vpp);
1036 * nmknod takes a locked, resolved ncp that typically represents a negative
1037 * cache hit and creates the node specified by the ncp, cred, and
1038 * vattr. If no error occurs a locked vnode is returned in *vpp.
1040 * The dvp passed in is referenced but unlocked.
1042 * The namecache is automatically adjusted by this function. The ncp
1043 * is left locked on return.
1046 vop_nmknod(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1047 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1049 struct vop_nmknod_args ap;
1052 ap.a_head.a_desc = &vop_nmknod_desc;
1053 ap.a_head.a_ops = ops;
1060 DO_OPS(ops, error, &ap, vop_nmknod);
1061 if (error == 0 && *vpp)
1062 cache_update_fsmid_vp(*vpp);
1067 * nlink takes a locked, resolved ncp that typically represents a negative
1068 * cache hit and creates the node specified by the ncp, cred, and
1069 * existing vnode. The passed vp must be locked and will remain locked
1070 * on return, as does the ncp, whether an error occurs or not.
1072 * The dvp passed in is referenced but unlocked.
1074 * The namecache is automatically adjusted by this function. The ncp
1075 * is left locked on return.
1078 vop_nlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1079 struct vnode *vp, struct ucred *cred)
1081 struct vop_nlink_args ap;
1084 ap.a_head.a_desc = &vop_nlink_desc;
1085 ap.a_head.a_ops = ops;
1091 DO_OPS(ops, error, &ap, vop_nlink);
1093 cache_update_fsmid(nch);
1098 * nsymlink takes a locked, resolved ncp that typically represents a negative
1099 * cache hit and creates a symbolic link based on cred, vap, and target (the
1100 * contents of the link). If no error occurs a locked vnode is returned in
1103 * The dvp passed in is referenced but unlocked.
1105 * The namecache is automatically adjusted by this function. The ncp
1106 * is left locked on return.
1109 vop_nsymlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1110 struct vnode **vpp, struct ucred *cred,
1111 struct vattr *vap, char *target)
1113 struct vop_nsymlink_args ap;
1116 ap.a_head.a_desc = &vop_nsymlink_desc;
1117 ap.a_head.a_ops = ops;
1123 ap.a_target = target;
1125 DO_OPS(ops, error, &ap, vop_nsymlink);
1127 cache_update_fsmid(nch);
1132 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1133 * negative hit and executes the whiteout function specified in flags.
1135 * The dvp passed in is referenced but unlocked.
1137 * The namecache is automatically adjusted by this function. The ncp
1138 * is left locked on return.
1141 vop_nwhiteout(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1142 struct ucred *cred, int flags)
1144 struct vop_nwhiteout_args ap;
1147 ap.a_head.a_desc = &vop_nwhiteout_desc;
1148 ap.a_head.a_ops = ops;
1154 DO_OPS(ops, error, &ap, vop_nwhiteout);
1156 cache_update_fsmid(nch);
1161 * nremove takes a locked, resolved ncp that generally represents a
1162 * positive hit and removes the file.
1164 * The dvp passed in is referenced but unlocked.
1166 * The namecache is automatically adjusted by this function. The ncp
1167 * is left locked on return.
1170 vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1173 struct vop_nremove_args ap;
1176 ap.a_head.a_desc = &vop_nremove_desc;
1177 ap.a_head.a_ops = ops;
1182 DO_OPS(ops, error, &ap, vop_nremove);
1184 cache_update_fsmid(nch);
1189 * nrmdir takes a locked, resolved ncp that generally represents a
1190 * directory and removes the directory.
1192 * The dvp passed in is referenced but unlocked.
1194 * The namecache is automatically adjusted by this function. The ncp
1195 * is left locked on return.
1198 vop_nrmdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1201 struct vop_nrmdir_args ap;
1204 ap.a_head.a_desc = &vop_nrmdir_desc;
1205 ap.a_head.a_ops = ops;
1210 DO_OPS(ops, error, &ap, vop_nrmdir);
1212 cache_update_fsmid(nch);
1217 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1218 * and renames the source ncp to the target ncp. The target ncp may
1219 * represent a positive or negative hit.
1221 * The fdvp and tdvp passed in are referenced but unlocked.
1223 * The namecache is automatically adjusted by this function. The ncp
1224 * is left locked on return. The source ncp is typically changed to
1225 * a negative cache hit and the target ncp typically takes on the
1226 * source ncp's underlying file.
1229 vop_nrename(struct vop_ops *ops,
1230 struct nchandle *fnch, struct nchandle *tnch,
1231 struct vnode *fdvp, struct vnode *tdvp,
1234 struct vop_nrename_args ap;
1237 ap.a_head.a_desc = &vop_nrename_desc;
1238 ap.a_head.a_ops = ops;
1245 DO_OPS(ops, error, &ap, vop_nrename);
1247 cache_update_fsmid(fnch);
1248 cache_update_fsmid(tnch);
1253 /************************************************************************
1254 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1255 ************************************************************************
1257 * These procedures are called from VFSs such as unionfs and nullfs
1258 * when they wish to forward an operation on one VFS to another. The
1259 * argument structure/message is modified and then directly passed to the
1260 * appropriate routine. This routines may also be called by initiators
1261 * who have an argument structure in hand rather then discreet arguments.
1264 vop_vnoperate_ap(struct vop_generic_args *ap)
1266 struct vop_ops *ops;
1270 error = VOCALL(ops, ap);
1276 * This routine is called by the cache coherency layer to execute the actual
1277 * VFS operation. If a journaling layer is present we call though it, else
1278 * we call the native VOP functions.
1281 vop_cache_operate_ap(struct vop_generic_args *ap)
1283 struct vop_ops *ops;
1287 if (ops->head.vv_mount->mnt_vn_journal_ops)
1288 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1290 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1296 * This routine is called by the journaling layer to execute the actual
1300 vop_journal_operate_ap(struct vop_generic_args *ap)
1302 struct vop_ops *ops;
1306 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1312 vop_open_ap(struct vop_open_args *ap)
1316 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1321 vop_close_ap(struct vop_close_args *ap)
1325 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1330 vop_access_ap(struct vop_access_args *ap)
1334 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1339 vop_getattr_ap(struct vop_getattr_args *ap)
1343 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1348 vop_setattr_ap(struct vop_setattr_args *ap)
1352 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1357 vop_read_ap(struct vop_read_args *ap)
1361 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1366 vop_write_ap(struct vop_write_args *ap)
1370 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1375 vop_ioctl_ap(struct vop_ioctl_args *ap)
1379 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1384 vop_poll_ap(struct vop_poll_args *ap)
1388 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1393 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1397 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1402 vop_mmap_ap(struct vop_mmap_args *ap)
1406 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1411 vop_fsync_ap(struct vop_fsync_args *ap)
1415 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1420 vop_readdir_ap(struct vop_readdir_args *ap)
1424 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1429 vop_readlink_ap(struct vop_readlink_args *ap)
1433 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1438 vop_inactive_ap(struct vop_inactive_args *ap)
1442 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1447 vop_reclaim_ap(struct vop_reclaim_args *ap)
1451 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1456 vop_bmap_ap(struct vop_bmap_args *ap)
1460 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1465 vop_strategy_ap(struct vop_strategy_args *ap)
1469 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1474 vop_print_ap(struct vop_print_args *ap)
1478 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1483 vop_pathconf_ap(struct vop_pathconf_args *ap)
1487 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1492 vop_advlock_ap(struct vop_advlock_args *ap)
1496 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1501 vop_balloc_ap(struct vop_balloc_args *ap)
1505 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1510 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1514 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1519 vop_getpages_ap(struct vop_getpages_args *ap)
1523 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1528 vop_putpages_ap(struct vop_putpages_args *ap)
1532 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1537 vop_freeblks_ap(struct vop_freeblks_args *ap)
1541 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1546 vop_getacl_ap(struct vop_getacl_args *ap)
1550 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1555 vop_setacl_ap(struct vop_setacl_args *ap)
1559 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1564 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1568 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1573 vop_getextattr_ap(struct vop_getextattr_args *ap)
1577 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1582 vop_setextattr_ap(struct vop_setextattr_args *ap)
1586 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1591 vop_mountctl_ap(struct vop_mountctl_args *ap)
1595 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1600 vop_markatime_ap(struct vop_markatime_args *ap)
1604 DO_OPS(ap->a_head.a_ops, error, ap, vop_markatime);
1609 vop_nresolve_ap(struct vop_nresolve_args *ap)
1613 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1618 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1622 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1627 vop_ncreate_ap(struct vop_ncreate_args *ap)
1631 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1636 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1640 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1645 vop_nmknod_ap(struct vop_nmknod_args *ap)
1649 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1654 vop_nlink_ap(struct vop_nlink_args *ap)
1658 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1663 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1667 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1672 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1676 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1681 vop_nremove_ap(struct vop_nremove_args *ap)
1685 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1690 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1694 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1699 vop_nrename_ap(struct vop_nrename_args *ap)
1703 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);