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, int flags,
265 struct vop_access_args ap;
268 ap.a_head.a_desc = &vop_access_desc;
269 ap.a_head.a_ops = ops;
275 DO_OPS(ops, error, &ap, vop_access);
280 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
282 struct vop_getattr_args ap;
285 ap.a_head.a_desc = &vop_getattr_desc;
286 ap.a_head.a_ops = ops;
290 DO_OPS(ops, error, &ap, vop_getattr);
293 * mount pointer may be NULL if vnode is dead.
295 if (ops->head.vv_mount &&
296 (ops->head.vv_mount->mnt_kern_flag & MNTK_FSMID) == 0) {
297 vap->va_fsmid = cache_sync_fsmid_vp(vp);
303 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
306 struct vop_setattr_args ap;
309 ap.a_head.a_desc = &vop_setattr_desc;
310 ap.a_head.a_ops = ops;
315 DO_OPS(ops, error, &ap, vop_setattr);
317 cache_update_fsmid_vp(vp);
322 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
325 struct vop_read_args ap;
328 ap.a_head.a_desc = &vop_read_desc;
329 ap.a_head.a_ops = ops;
332 ap.a_ioflag = ioflag;
335 DO_OPS(ops, error, &ap, vop_read);
340 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
343 struct vop_write_args ap;
346 ap.a_head.a_desc = &vop_write_desc;
347 ap.a_head.a_ops = ops;
350 ap.a_ioflag = ioflag;
353 DO_OPS(ops, error, &ap, vop_write);
355 cache_update_fsmid_vp(vp);
360 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
361 int fflag, struct ucred *cred)
363 struct vop_ioctl_args ap;
366 ap.a_head.a_desc = &vop_ioctl_desc;
367 ap.a_head.a_ops = ops;
369 ap.a_command = command;
374 DO_OPS(ops, error, &ap, vop_ioctl);
379 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
381 struct vop_poll_args ap;
384 ap.a_head.a_desc = &vop_poll_desc;
385 ap.a_head.a_ops = ops;
387 ap.a_events = events;
390 DO_OPS(ops, error, &ap, vop_poll);
395 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
397 struct vop_kqfilter_args ap;
400 ap.a_head.a_desc = &vop_kqfilter_desc;
401 ap.a_head.a_ops = ops;
405 DO_OPS(ops, error, &ap, vop_kqfilter);
410 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
412 struct vop_mmap_args ap;
415 ap.a_head.a_desc = &vop_mmap_desc;
416 ap.a_head.a_ops = ops;
418 ap.a_fflags = fflags;
421 DO_OPS(ops, error, &ap, vop_mmap);
426 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor, int flags)
428 struct vop_fsync_args ap;
431 ap.a_head.a_desc = &vop_fsync_desc;
432 ap.a_head.a_ops = ops;
434 ap.a_waitfor = waitfor;
437 DO_OPS(ops, error, &ap, vop_fsync);
442 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
443 struct vnode *vp, struct componentname *cnp)
445 struct vop_old_remove_args ap;
448 ap.a_head.a_desc = &vop_old_remove_desc;
449 ap.a_head.a_ops = ops;
454 DO_OPS(ops, error, &ap, vop_old_remove);
459 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
460 struct vnode *vp, struct componentname *cnp)
462 struct vop_old_link_args ap;
465 ap.a_head.a_desc = &vop_old_link_desc;
466 ap.a_head.a_ops = ops;
471 DO_OPS(ops, error, &ap, vop_old_link);
476 vop_old_rename(struct vop_ops *ops,
477 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
478 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
480 struct vop_old_rename_args ap;
483 ap.a_head.a_desc = &vop_old_rename_desc;
484 ap.a_head.a_ops = ops;
492 DO_OPS(ops, error, &ap, vop_old_rename);
497 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
498 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
500 struct vop_old_mkdir_args ap;
503 ap.a_head.a_desc = &vop_old_mkdir_desc;
504 ap.a_head.a_ops = ops;
510 DO_OPS(ops, error, &ap, vop_old_mkdir);
515 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
516 struct vnode *vp, struct componentname *cnp)
518 struct vop_old_rmdir_args ap;
521 ap.a_head.a_desc = &vop_old_rmdir_desc;
522 ap.a_head.a_ops = ops;
527 DO_OPS(ops, error, &ap, vop_old_rmdir);
532 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
533 struct vnode **vpp, struct componentname *cnp,
534 struct vattr *vap, char *target)
536 struct vop_old_symlink_args ap;
539 ap.a_head.a_desc = &vop_old_symlink_desc;
540 ap.a_head.a_ops = ops;
545 ap.a_target = target;
547 DO_OPS(ops, error, &ap, vop_old_symlink);
552 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
553 struct ucred *cred, int *eofflag, int *ncookies, off_t **cookies)
555 struct vop_readdir_args ap;
558 ap.a_head.a_desc = &vop_readdir_desc;
559 ap.a_head.a_ops = ops;
563 ap.a_eofflag = eofflag;
564 ap.a_ncookies = ncookies;
565 ap.a_cookies = cookies;
567 DO_OPS(ops, error, &ap, vop_readdir);
572 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
575 struct vop_readlink_args ap;
578 ap.a_head.a_desc = &vop_readlink_desc;
579 ap.a_head.a_ops = ops;
584 DO_OPS(ops, error, &ap, vop_readlink);
589 vop_inactive(struct vop_ops *ops, struct vnode *vp)
591 struct vop_inactive_args ap;
594 ap.a_head.a_desc = &vop_inactive_desc;
595 ap.a_head.a_ops = ops;
598 DO_OPS(ops, error, &ap, vop_inactive);
603 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
605 struct vop_reclaim_args ap;
608 ap.a_head.a_desc = &vop_reclaim_desc;
609 ap.a_head.a_ops = ops;
612 DO_OPS(ops, error, &ap, vop_reclaim);
617 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
618 off_t *doffsetp, int *runp, int *runb, buf_cmd_t cmd)
620 struct vop_bmap_args ap;
623 ap.a_head.a_desc = &vop_bmap_desc;
624 ap.a_head.a_ops = ops;
626 ap.a_loffset = loffset;
627 ap.a_doffsetp = doffsetp;
632 DO_OPS(ops, error, &ap, vop_bmap);
637 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
639 struct vop_strategy_args ap;
642 ap.a_head.a_desc = &vop_strategy_desc;
643 ap.a_head.a_ops = ops;
647 DO_OPS(ops, error, &ap, vop_strategy);
648 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
649 cache_update_fsmid_vp(vp);
654 vop_print(struct vop_ops *ops, struct vnode *vp)
656 struct vop_print_args ap;
659 ap.a_head.a_desc = &vop_print_desc;
660 ap.a_head.a_ops = ops;
663 DO_OPS(ops, error, &ap, vop_print);
668 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
671 struct vop_pathconf_args ap;
674 ap.a_head.a_desc = &vop_pathconf_desc;
675 ap.a_head.a_ops = ops;
678 ap.a_retval = retval;
680 DO_OPS(ops, error, &ap, vop_pathconf);
685 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
686 struct flock *fl, int flags)
688 struct vop_advlock_args ap;
691 ap.a_head.a_desc = &vop_advlock_desc;
692 ap.a_head.a_ops = ops;
699 DO_OPS(ops, error, &ap, vop_advlock);
704 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
705 int size, struct ucred *cred, int flags,
708 struct vop_balloc_args ap;
711 ap.a_head.a_desc = &vop_balloc_desc;
712 ap.a_head.a_ops = ops;
714 ap.a_startoffset = startoffset;
720 DO_OPS(ops, error, &ap, vop_balloc);
725 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
726 struct cluster_save *buflist)
728 struct vop_reallocblks_args ap;
731 ap.a_head.a_desc = &vop_reallocblks_desc;
732 ap.a_head.a_ops = ops;
734 ap.a_buflist = buflist;
736 DO_OPS(ops, error, &ap, vop_reallocblks);
741 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
742 int reqpage, vm_ooffset_t offset)
744 struct vop_getpages_args ap;
747 ap.a_head.a_desc = &vop_getpages_desc;
748 ap.a_head.a_ops = ops;
752 ap.a_reqpage = reqpage;
753 ap.a_offset = offset;
755 DO_OPS(ops, error, &ap, vop_getpages);
760 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
761 int sync, int *rtvals, vm_ooffset_t offset)
763 struct vop_putpages_args ap;
766 ap.a_head.a_desc = &vop_putpages_desc;
767 ap.a_head.a_ops = ops;
772 ap.a_rtvals = rtvals;
773 ap.a_offset = offset;
775 DO_OPS(ops, error, &ap, vop_putpages);
777 cache_update_fsmid_vp(vp);
782 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
784 struct vop_freeblks_args ap;
787 ap.a_head.a_desc = &vop_freeblks_desc;
788 ap.a_head.a_ops = ops;
790 ap.a_offset = offset;
791 ap.a_length = length;
793 DO_OPS(ops, error, &ap, vop_freeblks);
798 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
799 struct acl *aclp, struct ucred *cred)
801 struct vop_getacl_args ap;
804 ap.a_head.a_desc = &vop_getacl_desc;
805 ap.a_head.a_ops = ops;
811 DO_OPS(ops, error, &ap, vop_getacl);
816 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
817 struct acl *aclp, struct ucred *cred)
819 struct vop_setacl_args ap;
822 ap.a_head.a_desc = &vop_setacl_desc;
823 ap.a_head.a_ops = ops;
829 DO_OPS(ops, error, &ap, vop_setacl);
831 cache_update_fsmid_vp(vp);
836 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
837 struct acl *aclp, struct ucred *cred)
839 struct vop_aclcheck_args ap;
842 ap.a_head.a_desc = &vop_aclcheck_desc;
843 ap.a_head.a_ops = ops;
849 DO_OPS(ops, error, &ap, vop_aclcheck);
854 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
855 struct uio *uio, struct ucred *cred)
857 struct vop_getextattr_args ap;
860 ap.a_head.a_desc = &vop_getextattr_desc;
861 ap.a_head.a_ops = ops;
867 DO_OPS(ops, error, &ap, vop_getextattr);
872 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
873 struct uio *uio, struct ucred *cred)
875 struct vop_setextattr_args ap;
878 ap.a_head.a_desc = &vop_setextattr_desc;
879 ap.a_head.a_ops = ops;
885 DO_OPS(ops, error, &ap, vop_setextattr);
887 cache_update_fsmid_vp(vp);
892 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
893 const void *ctl, int ctllen, void *buf, int buflen, int *res)
895 struct vop_mountctl_args ap;
898 ap.a_head.a_desc = &vop_mountctl_desc;
899 ap.a_head.a_ops = ops;
903 ap.a_ctllen = ctllen;
905 ap.a_buflen = buflen;
908 DO_OPS(ops, error, &ap, vop_mountctl);
913 vop_markatime(struct vop_ops *ops, struct vnode *vp, struct ucred *cred)
915 struct vop_markatime_args ap;
918 ap.a_head.a_desc = &vop_markatime_desc;
919 ap.a_head.a_ops = ops;
923 DO_OPS(ops, error, &ap, vop_markatime);
930 * nresolve takes a locked ncp, a referenced but unlocked dvp, and a cred,
931 * and resolves the ncp into a positive or negative hit.
933 * The namecache is automatically adjusted by this function. The ncp
934 * is left locked on return.
937 vop_nresolve(struct vop_ops *ops, struct nchandle *nch,
938 struct vnode *dvp, struct ucred *cred)
940 struct vop_nresolve_args ap;
943 ap.a_head.a_desc = &vop_nresolve_desc;
944 ap.a_head.a_ops = ops;
949 DO_OPS(ops, error, &ap, vop_nresolve);
954 * nlookupdotdot takes an unlocked directory, referenced dvp, and looks
955 * up "..", returning a locked parent directory in *vpp. If an error
956 * occurs *vpp will be NULL.
959 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
960 struct vnode **vpp, struct ucred *cred, char **fakename)
962 struct vop_nlookupdotdot_args ap;
965 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
966 ap.a_head.a_ops = ops;
970 ap.a_fakename = fakename;
972 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
977 * ncreate takes a locked, resolved ncp that typically represents a negative
978 * cache hit and creates the file or node specified by the ncp, cred, and
979 * vattr. If no error occurs a locked vnode is returned in *vpp.
981 * The dvp passed in is referenced but unlocked.
983 * The namecache is automatically adjusted by this function. The ncp
984 * is left locked on return.
987 vop_ncreate(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
988 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
990 struct vop_ncreate_args ap;
993 ap.a_head.a_desc = &vop_ncreate_desc;
994 ap.a_head.a_ops = ops;
1001 DO_OPS(ops, error, &ap, vop_ncreate);
1002 if (error == 0 && *vpp)
1003 cache_update_fsmid_vp(*vpp);
1008 * nmkdir takes a locked, resolved ncp that typically represents a negative
1009 * cache hit and creates the directory specified by the ncp, cred, and
1010 * vattr. If no error occurs a locked vnode is returned in *vpp.
1012 * The dvp passed in is referenced but unlocked.
1014 * The namecache is automatically adjusted by this function. The ncp
1015 * is left locked on return.
1018 vop_nmkdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1019 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1021 struct vop_nmkdir_args ap;
1024 ap.a_head.a_desc = &vop_nmkdir_desc;
1025 ap.a_head.a_ops = ops;
1032 DO_OPS(ops, error, &ap, vop_nmkdir);
1033 if (error == 0 && *vpp)
1034 cache_update_fsmid_vp(*vpp);
1039 * nmknod takes a locked, resolved ncp that typically represents a negative
1040 * cache hit and creates the node specified by the ncp, cred, and
1041 * vattr. If no error occurs a locked vnode is returned in *vpp.
1043 * The dvp passed in is referenced but unlocked.
1045 * The namecache is automatically adjusted by this function. The ncp
1046 * is left locked on return.
1049 vop_nmknod(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1050 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1052 struct vop_nmknod_args ap;
1055 ap.a_head.a_desc = &vop_nmknod_desc;
1056 ap.a_head.a_ops = ops;
1063 DO_OPS(ops, error, &ap, vop_nmknod);
1064 if (error == 0 && *vpp)
1065 cache_update_fsmid_vp(*vpp);
1070 * nlink takes a locked, resolved ncp that typically represents a negative
1071 * cache hit and creates the node specified by the ncp, cred, and
1072 * existing vnode. The passed vp must be locked and will remain locked
1073 * on return, as does the ncp, whether an error occurs or not.
1075 * The dvp passed in is referenced but unlocked.
1077 * The namecache is automatically adjusted by this function. The ncp
1078 * is left locked on return.
1081 vop_nlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1082 struct vnode *vp, struct ucred *cred)
1084 struct vop_nlink_args ap;
1087 ap.a_head.a_desc = &vop_nlink_desc;
1088 ap.a_head.a_ops = ops;
1094 DO_OPS(ops, error, &ap, vop_nlink);
1096 cache_update_fsmid(nch);
1101 * nsymlink takes a locked, resolved ncp that typically represents a negative
1102 * cache hit and creates a symbolic link based on cred, vap, and target (the
1103 * contents of the link). If no error occurs a locked vnode is returned in
1106 * The dvp passed in is referenced but unlocked.
1108 * The namecache is automatically adjusted by this function. The ncp
1109 * is left locked on return.
1112 vop_nsymlink(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1113 struct vnode **vpp, struct ucred *cred,
1114 struct vattr *vap, char *target)
1116 struct vop_nsymlink_args ap;
1119 ap.a_head.a_desc = &vop_nsymlink_desc;
1120 ap.a_head.a_ops = ops;
1126 ap.a_target = target;
1128 DO_OPS(ops, error, &ap, vop_nsymlink);
1130 cache_update_fsmid(nch);
1135 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1136 * negative hit and executes the whiteout function specified in flags.
1138 * The dvp passed in is referenced but unlocked.
1140 * The namecache is automatically adjusted by this function. The ncp
1141 * is left locked on return.
1144 vop_nwhiteout(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1145 struct ucred *cred, int flags)
1147 struct vop_nwhiteout_args ap;
1150 ap.a_head.a_desc = &vop_nwhiteout_desc;
1151 ap.a_head.a_ops = ops;
1157 DO_OPS(ops, error, &ap, vop_nwhiteout);
1159 cache_update_fsmid(nch);
1164 * nremove takes a locked, resolved ncp that generally represents a
1165 * positive hit and removes the file.
1167 * The dvp passed in is referenced but unlocked.
1169 * The namecache is automatically adjusted by this function. The ncp
1170 * is left locked on return.
1173 vop_nremove(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1176 struct vop_nremove_args ap;
1179 ap.a_head.a_desc = &vop_nremove_desc;
1180 ap.a_head.a_ops = ops;
1185 DO_OPS(ops, error, &ap, vop_nremove);
1187 cache_update_fsmid(nch);
1192 * nrmdir takes a locked, resolved ncp that generally represents a
1193 * directory and removes the directory.
1195 * The dvp passed in is referenced but unlocked.
1197 * The namecache is automatically adjusted by this function. The ncp
1198 * is left locked on return.
1201 vop_nrmdir(struct vop_ops *ops, struct nchandle *nch, struct vnode *dvp,
1204 struct vop_nrmdir_args ap;
1207 ap.a_head.a_desc = &vop_nrmdir_desc;
1208 ap.a_head.a_ops = ops;
1213 DO_OPS(ops, error, &ap, vop_nrmdir);
1215 cache_update_fsmid(nch);
1220 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1221 * and renames the source ncp to the target ncp. The target ncp may
1222 * represent a positive or negative hit.
1224 * The fdvp and tdvp passed in are referenced but unlocked.
1226 * The namecache is automatically adjusted by this function. The ncp
1227 * is left locked on return. The source ncp is typically changed to
1228 * a negative cache hit and the target ncp typically takes on the
1229 * source ncp's underlying file.
1232 vop_nrename(struct vop_ops *ops,
1233 struct nchandle *fnch, struct nchandle *tnch,
1234 struct vnode *fdvp, struct vnode *tdvp,
1237 struct vop_nrename_args ap;
1240 ap.a_head.a_desc = &vop_nrename_desc;
1241 ap.a_head.a_ops = ops;
1248 DO_OPS(ops, error, &ap, vop_nrename);
1250 cache_update_fsmid(fnch);
1251 cache_update_fsmid(tnch);
1256 /************************************************************************
1257 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1258 ************************************************************************
1260 * These procedures are called from VFSs such as unionfs and nullfs
1261 * when they wish to forward an operation on one VFS to another. The
1262 * argument structure/message is modified and then directly passed to the
1263 * appropriate routine. This routines may also be called by initiators
1264 * who have an argument structure in hand rather then discreet arguments.
1267 vop_vnoperate_ap(struct vop_generic_args *ap)
1269 struct vop_ops *ops;
1273 error = VOCALL(ops, ap);
1279 * This routine is called by the cache coherency layer to execute the actual
1280 * VFS operation. If a journaling layer is present we call though it, else
1281 * we call the native VOP functions.
1284 vop_cache_operate_ap(struct vop_generic_args *ap)
1286 struct vop_ops *ops;
1290 if (ops->head.vv_mount->mnt_vn_journal_ops)
1291 error = VOCALL(ops->head.vv_mount->mnt_vn_journal_ops, ap);
1293 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1299 * This routine is called by the journaling layer to execute the actual
1303 vop_journal_operate_ap(struct vop_generic_args *ap)
1305 struct vop_ops *ops;
1309 error = VOCALL(ops->head.vv_mount->mnt_vn_norm_ops, ap);
1315 vop_open_ap(struct vop_open_args *ap)
1319 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1324 vop_close_ap(struct vop_close_args *ap)
1328 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1333 vop_access_ap(struct vop_access_args *ap)
1337 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1342 vop_getattr_ap(struct vop_getattr_args *ap)
1346 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1351 vop_setattr_ap(struct vop_setattr_args *ap)
1355 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1360 vop_read_ap(struct vop_read_args *ap)
1364 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1369 vop_write_ap(struct vop_write_args *ap)
1373 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1378 vop_ioctl_ap(struct vop_ioctl_args *ap)
1382 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1387 vop_poll_ap(struct vop_poll_args *ap)
1391 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1396 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1400 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1405 vop_mmap_ap(struct vop_mmap_args *ap)
1409 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1414 vop_fsync_ap(struct vop_fsync_args *ap)
1418 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1423 vop_readdir_ap(struct vop_readdir_args *ap)
1427 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1432 vop_readlink_ap(struct vop_readlink_args *ap)
1436 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1441 vop_inactive_ap(struct vop_inactive_args *ap)
1445 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1450 vop_reclaim_ap(struct vop_reclaim_args *ap)
1454 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1459 vop_bmap_ap(struct vop_bmap_args *ap)
1463 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1468 vop_strategy_ap(struct vop_strategy_args *ap)
1472 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1477 vop_print_ap(struct vop_print_args *ap)
1481 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1486 vop_pathconf_ap(struct vop_pathconf_args *ap)
1490 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1495 vop_advlock_ap(struct vop_advlock_args *ap)
1499 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1504 vop_balloc_ap(struct vop_balloc_args *ap)
1508 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1513 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1517 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1522 vop_getpages_ap(struct vop_getpages_args *ap)
1526 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1531 vop_putpages_ap(struct vop_putpages_args *ap)
1535 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1540 vop_freeblks_ap(struct vop_freeblks_args *ap)
1544 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1549 vop_getacl_ap(struct vop_getacl_args *ap)
1553 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1558 vop_setacl_ap(struct vop_setacl_args *ap)
1562 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1567 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1571 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1576 vop_getextattr_ap(struct vop_getextattr_args *ap)
1580 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1585 vop_setextattr_ap(struct vop_setextattr_args *ap)
1589 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1594 vop_mountctl_ap(struct vop_mountctl_args *ap)
1598 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1603 vop_markatime_ap(struct vop_markatime_args *ap)
1607 DO_OPS(ap->a_head.a_ops, error, ap, vop_markatime);
1612 vop_nresolve_ap(struct vop_nresolve_args *ap)
1616 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1621 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1625 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1630 vop_ncreate_ap(struct vop_ncreate_args *ap)
1634 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1639 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1643 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1648 vop_nmknod_ap(struct vop_nmknod_args *ap)
1652 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1657 vop_nlink_ap(struct vop_nlink_args *ap)
1661 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1666 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1670 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1675 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1679 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1684 vop_nremove_ap(struct vop_nremove_args *ap)
1688 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1693 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1697 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1702 vop_nrename_ap(struct vop_nrename_args *ap)
1706 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);