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.27 2006/06/04 17:33: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)
79 #define VARGSSTRUCT(name) struct __CONCAT(__CONCAT(vop_,name),_args)
81 #define VNODEOP_DESC_INIT(name) \
82 struct vnodeop_desc VDESCNAME(name) = { \
83 __offsetof(struct vop_ops, __CONCAT(vop_, name)), \
86 #define VNODEOP_DESC_INIT_SIMPLE(name) \
87 VNODEOP_DESC_INIT(name)
89 VNODEOP_DESC_INIT_SIMPLE(default);
90 VNODEOP_DESC_INIT_SIMPLE(islocked);
91 VNODEOP_DESC_INIT_SIMPLE(old_lookup);
92 VNODEOP_DESC_INIT_SIMPLE(old_create);
93 VNODEOP_DESC_INIT_SIMPLE(old_whiteout);
94 VNODEOP_DESC_INIT_SIMPLE(old_mknod);
95 VNODEOP_DESC_INIT_SIMPLE(open);
96 VNODEOP_DESC_INIT_SIMPLE(close);
97 VNODEOP_DESC_INIT_SIMPLE(access);
98 VNODEOP_DESC_INIT_SIMPLE(getattr);
99 VNODEOP_DESC_INIT_SIMPLE(setattr);
100 VNODEOP_DESC_INIT_SIMPLE(read);
101 VNODEOP_DESC_INIT_SIMPLE(write);
102 VNODEOP_DESC_INIT_SIMPLE(ioctl);
103 VNODEOP_DESC_INIT_SIMPLE(poll);
104 VNODEOP_DESC_INIT_SIMPLE(kqfilter);
105 VNODEOP_DESC_INIT_SIMPLE(revoke);
106 VNODEOP_DESC_INIT_SIMPLE(mmap);
107 VNODEOP_DESC_INIT_SIMPLE(fsync);
108 VNODEOP_DESC_INIT_SIMPLE(old_remove);
109 VNODEOP_DESC_INIT_SIMPLE(old_link);
110 VNODEOP_DESC_INIT_SIMPLE(old_rename);
112 VNODEOP_DESC_INIT_SIMPLE(old_mkdir);
113 VNODEOP_DESC_INIT_SIMPLE(old_rmdir);
114 VNODEOP_DESC_INIT_SIMPLE(old_symlink);
115 VNODEOP_DESC_INIT_SIMPLE(readdir);
116 VNODEOP_DESC_INIT_SIMPLE(readlink);
117 VNODEOP_DESC_INIT_SIMPLE(inactive);
118 VNODEOP_DESC_INIT_SIMPLE(reclaim);
119 VNODEOP_DESC_INIT_SIMPLE(lock);
120 VNODEOP_DESC_INIT_SIMPLE(unlock);
121 VNODEOP_DESC_INIT_SIMPLE(bmap);
122 VNODEOP_DESC_INIT_SIMPLE(strategy);
123 VNODEOP_DESC_INIT_SIMPLE(print);
124 VNODEOP_DESC_INIT_SIMPLE(pathconf);
125 VNODEOP_DESC_INIT_SIMPLE(advlock);
126 VNODEOP_DESC_INIT_SIMPLE(balloc);
127 VNODEOP_DESC_INIT_SIMPLE(reallocblks);
128 VNODEOP_DESC_INIT_SIMPLE(getpages);
129 VNODEOP_DESC_INIT_SIMPLE(putpages);
130 VNODEOP_DESC_INIT_SIMPLE(freeblks);
131 VNODEOP_DESC_INIT_SIMPLE(getacl);
132 VNODEOP_DESC_INIT_SIMPLE(setacl);
133 VNODEOP_DESC_INIT_SIMPLE(aclcheck);
134 VNODEOP_DESC_INIT_SIMPLE(getextattr);
135 VNODEOP_DESC_INIT_SIMPLE(setextattr);
136 VNODEOP_DESC_INIT_SIMPLE(mountctl);
138 VNODEOP_DESC_INIT_SIMPLE(nresolve);
139 VNODEOP_DESC_INIT_SIMPLE(nlookupdotdot);
140 VNODEOP_DESC_INIT_SIMPLE(ncreate);
141 VNODEOP_DESC_INIT_SIMPLE(nmkdir);
142 VNODEOP_DESC_INIT_SIMPLE(nmknod);
143 VNODEOP_DESC_INIT_SIMPLE(nlink);
144 VNODEOP_DESC_INIT_SIMPLE(nsymlink);
145 VNODEOP_DESC_INIT_SIMPLE(nwhiteout);
146 VNODEOP_DESC_INIT_SIMPLE(nremove);
147 VNODEOP_DESC_INIT_SIMPLE(nrmdir);
148 VNODEOP_DESC_INIT_SIMPLE(nrename);
150 #define DO_OPS(ops, error, ap, vop_field) \
151 error = ops->vop_field(ap);
153 /************************************************************************
154 * PRIMARY HIGH LEVEL VNODE OPERATIONS CALLS *
155 ************************************************************************
157 * These procedures are called directly from the kernel and/or fileops
158 * code to perform file/device operations on the system.
160 * NOTE: The old namespace api functions such as vop_rename() are no longer
161 * available for general use and have been renamed to vop_old_*(). Only
162 * the code in vfs_default.c is allowed to call those ops.
166 vop_islocked(struct vop_ops *ops, struct vnode *vp, struct thread *td)
168 struct vop_islocked_args ap;
171 ap.a_head.a_desc = &vop_islocked_desc;
172 ap.a_head.a_ops = ops;
176 DO_OPS(ops, error, &ap, vop_islocked);
181 vop_old_lookup(struct vop_ops *ops, struct vnode *dvp,
182 struct vnode **vpp, struct componentname *cnp)
184 struct vop_old_lookup_args ap;
187 ap.a_head.a_desc = &vop_old_lookup_desc;
188 ap.a_head.a_ops = ops;
193 DO_OPS(ops, error, &ap, vop_old_lookup);
198 vop_old_create(struct vop_ops *ops, struct vnode *dvp,
199 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
201 struct vop_old_create_args ap;
204 ap.a_head.a_desc = &vop_old_create_desc;
205 ap.a_head.a_ops = ops;
211 DO_OPS(ops, error, &ap, vop_old_create);
216 vop_old_whiteout(struct vop_ops *ops, struct vnode *dvp,
217 struct componentname *cnp, int flags)
219 struct vop_old_whiteout_args ap;
222 ap.a_head.a_desc = &vop_old_whiteout_desc;
223 ap.a_head.a_ops = ops;
228 DO_OPS(ops, error, &ap, vop_old_whiteout);
233 vop_old_mknod(struct vop_ops *ops, struct vnode *dvp,
234 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
236 struct vop_old_mknod_args ap;
239 ap.a_head.a_desc = &vop_old_mknod_desc;
240 ap.a_head.a_ops = ops;
246 DO_OPS(ops, error, &ap, vop_old_mknod);
251 vop_open(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred,
254 struct vop_open_args ap;
257 ap.a_head.a_desc = &vop_open_desc;
258 ap.a_head.a_ops = ops;
264 DO_OPS(ops, error, &ap, vop_open);
269 vop_close(struct vop_ops *ops, struct vnode *vp, int fflag)
271 struct vop_close_args ap;
274 ap.a_head.a_desc = &vop_close_desc;
275 ap.a_head.a_ops = ops;
279 DO_OPS(ops, error, &ap, vop_close);
284 vop_access(struct vop_ops *ops, struct vnode *vp, int mode, struct ucred *cred)
286 struct vop_access_args ap;
289 ap.a_head.a_desc = &vop_access_desc;
290 ap.a_head.a_ops = ops;
295 DO_OPS(ops, error, &ap, vop_access);
300 vop_getattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap)
302 struct vop_getattr_args ap;
305 ap.a_head.a_desc = &vop_getattr_desc;
306 ap.a_head.a_ops = ops;
310 DO_OPS(ops, error, &ap, vop_getattr);
311 if ((ops->vv_flags & VVF_SUPPORTS_FSMID) == 0)
312 vap->va_fsmid = cache_sync_fsmid_vp(vp);
317 vop_setattr(struct vop_ops *ops, struct vnode *vp, struct vattr *vap,
320 struct vop_setattr_args ap;
323 ap.a_head.a_desc = &vop_setattr_desc;
324 ap.a_head.a_ops = ops;
329 DO_OPS(ops, error, &ap, vop_setattr);
331 cache_update_fsmid_vp(vp);
336 vop_read(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
339 struct vop_read_args ap;
342 ap.a_head.a_desc = &vop_read_desc;
343 ap.a_head.a_ops = ops;
346 ap.a_ioflag = ioflag;
349 DO_OPS(ops, error, &ap, vop_read);
354 vop_write(struct vop_ops *ops, struct vnode *vp, struct uio *uio, int ioflag,
357 struct vop_write_args ap;
360 ap.a_head.a_desc = &vop_write_desc;
361 ap.a_head.a_ops = ops;
364 ap.a_ioflag = ioflag;
367 DO_OPS(ops, error, &ap, vop_write);
369 cache_update_fsmid_vp(vp);
374 vop_ioctl(struct vop_ops *ops, struct vnode *vp, u_long command, caddr_t data,
375 int fflag, struct ucred *cred)
377 struct vop_ioctl_args ap;
380 ap.a_head.a_desc = &vop_ioctl_desc;
381 ap.a_head.a_ops = ops;
383 ap.a_command = command;
388 DO_OPS(ops, error, &ap, vop_ioctl);
393 vop_poll(struct vop_ops *ops, struct vnode *vp, int events, struct ucred *cred)
395 struct vop_poll_args ap;
398 ap.a_head.a_desc = &vop_poll_desc;
399 ap.a_head.a_ops = ops;
401 ap.a_events = events;
404 DO_OPS(ops, error, &ap, vop_poll);
409 vop_kqfilter(struct vop_ops *ops, struct vnode *vp, struct knote *kn)
411 struct vop_kqfilter_args ap;
414 ap.a_head.a_desc = &vop_kqfilter_desc;
415 ap.a_head.a_ops = ops;
419 DO_OPS(ops, error, &ap, vop_kqfilter);
424 vop_revoke(struct vop_ops *ops, struct vnode *vp, int flags)
426 struct vop_revoke_args ap;
429 ap.a_head.a_desc = &vop_revoke_desc;
430 ap.a_head.a_ops = ops;
434 DO_OPS(ops, error, &ap, vop_revoke);
439 vop_mmap(struct vop_ops *ops, struct vnode *vp, int fflags, struct ucred *cred)
441 struct vop_mmap_args ap;
444 ap.a_head.a_desc = &vop_mmap_desc;
445 ap.a_head.a_ops = ops;
447 ap.a_fflags = fflags;
450 DO_OPS(ops, error, &ap, vop_mmap);
455 vop_fsync(struct vop_ops *ops, struct vnode *vp, int waitfor)
457 struct vop_fsync_args ap;
460 ap.a_head.a_desc = &vop_fsync_desc;
461 ap.a_head.a_ops = ops;
463 ap.a_waitfor = waitfor;
465 DO_OPS(ops, error, &ap, vop_fsync);
470 vop_old_remove(struct vop_ops *ops, struct vnode *dvp,
471 struct vnode *vp, struct componentname *cnp)
473 struct vop_old_remove_args ap;
476 ap.a_head.a_desc = &vop_old_remove_desc;
477 ap.a_head.a_ops = ops;
482 DO_OPS(ops, error, &ap, vop_old_remove);
487 vop_old_link(struct vop_ops *ops, struct vnode *tdvp,
488 struct vnode *vp, struct componentname *cnp)
490 struct vop_old_link_args ap;
493 ap.a_head.a_desc = &vop_old_link_desc;
494 ap.a_head.a_ops = ops;
499 DO_OPS(ops, error, &ap, vop_old_link);
504 vop_old_rename(struct vop_ops *ops,
505 struct vnode *fdvp, struct vnode *fvp, struct componentname *fcnp,
506 struct vnode *tdvp, struct vnode *tvp, struct componentname *tcnp)
508 struct vop_old_rename_args ap;
511 ap.a_head.a_desc = &vop_old_rename_desc;
512 ap.a_head.a_ops = ops;
520 DO_OPS(ops, error, &ap, vop_old_rename);
525 vop_old_mkdir(struct vop_ops *ops, struct vnode *dvp,
526 struct vnode **vpp, struct componentname *cnp, struct vattr *vap)
528 struct vop_old_mkdir_args ap;
531 ap.a_head.a_desc = &vop_old_mkdir_desc;
532 ap.a_head.a_ops = ops;
538 DO_OPS(ops, error, &ap, vop_old_mkdir);
543 vop_old_rmdir(struct vop_ops *ops, struct vnode *dvp,
544 struct vnode *vp, struct componentname *cnp)
546 struct vop_old_rmdir_args ap;
549 ap.a_head.a_desc = &vop_old_rmdir_desc;
550 ap.a_head.a_ops = ops;
555 DO_OPS(ops, error, &ap, vop_old_rmdir);
560 vop_old_symlink(struct vop_ops *ops, struct vnode *dvp,
561 struct vnode **vpp, struct componentname *cnp,
562 struct vattr *vap, char *target)
564 struct vop_old_symlink_args ap;
567 ap.a_head.a_desc = &vop_old_symlink_desc;
568 ap.a_head.a_ops = ops;
573 ap.a_target = target;
575 DO_OPS(ops, error, &ap, vop_old_symlink);
580 vop_readdir(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
581 struct ucred *cred, int *eofflag, int *ncookies, u_long **cookies)
583 struct vop_readdir_args ap;
586 ap.a_head.a_desc = &vop_readdir_desc;
587 ap.a_head.a_ops = ops;
591 ap.a_eofflag = eofflag;
592 ap.a_ncookies = ncookies;
593 ap.a_cookies = cookies;
595 DO_OPS(ops, error, &ap, vop_readdir);
600 vop_readlink(struct vop_ops *ops, struct vnode *vp, struct uio *uio,
603 struct vop_readlink_args ap;
606 ap.a_head.a_desc = &vop_readlink_desc;
607 ap.a_head.a_ops = ops;
612 DO_OPS(ops, error, &ap, vop_readlink);
617 vop_inactive(struct vop_ops *ops, struct vnode *vp)
619 struct vop_inactive_args ap;
622 ap.a_head.a_desc = &vop_inactive_desc;
623 ap.a_head.a_ops = ops;
626 DO_OPS(ops, error, &ap, vop_inactive);
631 vop_reclaim(struct vop_ops *ops, struct vnode *vp)
633 struct vop_reclaim_args ap;
636 ap.a_head.a_desc = &vop_reclaim_desc;
637 ap.a_head.a_ops = ops;
640 DO_OPS(ops, error, &ap, vop_reclaim);
645 vop_lock(struct vop_ops *ops, struct vnode *vp, int flags)
647 struct vop_lock_args ap;
650 ap.a_head.a_desc = &vop_lock_desc;
651 ap.a_head.a_ops = ops;
655 DO_OPS(ops, error, &ap, vop_lock);
660 vop_unlock(struct vop_ops *ops, struct vnode *vp, int flags)
662 struct vop_unlock_args ap;
665 ap.a_head.a_desc = &vop_unlock_desc;
666 ap.a_head.a_ops = ops;
670 DO_OPS(ops, error, &ap, vop_unlock);
675 vop_bmap(struct vop_ops *ops, struct vnode *vp, off_t loffset,
676 struct vnode **vpp, off_t *doffsetp, int *runp, int *runb)
678 struct vop_bmap_args ap;
681 ap.a_head.a_desc = &vop_bmap_desc;
682 ap.a_head.a_ops = ops;
684 ap.a_loffset = loffset;
686 ap.a_doffsetp = doffsetp;
690 DO_OPS(ops, error, &ap, vop_bmap);
695 vop_strategy(struct vop_ops *ops, struct vnode *vp, struct bio *bio)
697 struct vop_strategy_args ap;
700 ap.a_head.a_desc = &vop_strategy_desc;
701 ap.a_head.a_ops = ops;
705 DO_OPS(ops, error, &ap, vop_strategy);
706 if (error == 0 && bio->bio_buf->b_cmd != BUF_CMD_READ)
707 cache_update_fsmid_vp(vp);
712 vop_print(struct vop_ops *ops, struct vnode *vp)
714 struct vop_print_args ap;
717 ap.a_head.a_desc = &vop_print_desc;
718 ap.a_head.a_ops = ops;
721 DO_OPS(ops, error, &ap, vop_print);
726 vop_pathconf(struct vop_ops *ops, struct vnode *vp, int name,
729 struct vop_pathconf_args ap;
732 ap.a_head.a_desc = &vop_pathconf_desc;
733 ap.a_head.a_ops = ops;
736 ap.a_retval = retval;
738 DO_OPS(ops, error, &ap, vop_pathconf);
743 vop_advlock(struct vop_ops *ops, struct vnode *vp, caddr_t id, int op,
744 struct flock *fl, int flags)
746 struct vop_advlock_args ap;
749 ap.a_head.a_desc = &vop_advlock_desc;
750 ap.a_head.a_ops = ops;
757 DO_OPS(ops, error, &ap, vop_advlock);
762 vop_balloc(struct vop_ops *ops, struct vnode *vp, off_t startoffset,
763 int size, struct ucred *cred, int flags,
766 struct vop_balloc_args ap;
769 ap.a_head.a_desc = &vop_balloc_desc;
770 ap.a_head.a_ops = ops;
772 ap.a_startoffset = startoffset;
778 DO_OPS(ops, error, &ap, vop_balloc);
783 vop_reallocblks(struct vop_ops *ops, struct vnode *vp,
784 struct cluster_save *buflist)
786 struct vop_reallocblks_args ap;
789 ap.a_head.a_desc = &vop_reallocblks_desc;
790 ap.a_head.a_ops = ops;
792 ap.a_buflist = buflist;
794 DO_OPS(ops, error, &ap, vop_reallocblks);
799 vop_getpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
800 int reqpage, vm_ooffset_t offset)
802 struct vop_getpages_args ap;
805 ap.a_head.a_desc = &vop_getpages_desc;
806 ap.a_head.a_ops = ops;
810 ap.a_reqpage = reqpage;
811 ap.a_offset = offset;
813 DO_OPS(ops, error, &ap, vop_getpages);
818 vop_putpages(struct vop_ops *ops, struct vnode *vp, vm_page_t *m, int count,
819 int sync, int *rtvals, vm_ooffset_t offset)
821 struct vop_putpages_args ap;
824 ap.a_head.a_desc = &vop_putpages_desc;
825 ap.a_head.a_ops = ops;
830 ap.a_rtvals = rtvals;
831 ap.a_offset = offset;
833 DO_OPS(ops, error, &ap, vop_putpages);
835 cache_update_fsmid_vp(vp);
840 vop_freeblks(struct vop_ops *ops, struct vnode *vp, off_t offset, int length)
842 struct vop_freeblks_args ap;
845 ap.a_head.a_desc = &vop_freeblks_desc;
846 ap.a_head.a_ops = ops;
848 ap.a_offset = offset;
849 ap.a_length = length;
851 DO_OPS(ops, error, &ap, vop_freeblks);
856 vop_getacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
857 struct acl *aclp, struct ucred *cred)
859 struct vop_getacl_args ap;
862 ap.a_head.a_desc = &vop_getacl_desc;
863 ap.a_head.a_ops = ops;
869 DO_OPS(ops, error, &ap, vop_getacl);
874 vop_setacl(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
875 struct acl *aclp, struct ucred *cred)
877 struct vop_setacl_args ap;
880 ap.a_head.a_desc = &vop_setacl_desc;
881 ap.a_head.a_ops = ops;
887 DO_OPS(ops, error, &ap, vop_setacl);
889 cache_update_fsmid_vp(vp);
894 vop_aclcheck(struct vop_ops *ops, struct vnode *vp, acl_type_t type,
895 struct acl *aclp, struct ucred *cred)
897 struct vop_aclcheck_args ap;
900 ap.a_head.a_desc = &vop_aclcheck_desc;
901 ap.a_head.a_ops = ops;
907 DO_OPS(ops, error, &ap, vop_aclcheck);
912 vop_getextattr(struct vop_ops *ops, struct vnode *vp, char *name,
913 struct uio *uio, struct ucred *cred)
915 struct vop_getextattr_args ap;
918 ap.a_head.a_desc = &vop_getextattr_desc;
919 ap.a_head.a_ops = ops;
925 DO_OPS(ops, error, &ap, vop_getextattr);
930 vop_setextattr(struct vop_ops *ops, struct vnode *vp, char *name,
931 struct uio *uio, struct ucred *cred)
933 struct vop_setextattr_args ap;
936 ap.a_head.a_desc = &vop_setextattr_desc;
937 ap.a_head.a_ops = ops;
943 DO_OPS(ops, error, &ap, vop_setextattr);
945 cache_update_fsmid_vp(vp);
950 vop_mountctl(struct vop_ops *ops, int op, struct file *fp,
951 const void *ctl, int ctllen, void *buf, int buflen, int *res)
953 struct vop_mountctl_args ap;
956 ap.a_head.a_desc = &vop_mountctl_desc;
957 ap.a_head.a_ops = ops;
961 ap.a_ctllen = ctllen;
963 ap.a_buflen = buflen;
966 DO_OPS(ops, error, &ap, vop_mountctl);
973 * nresolve takes a locked ncp and a cred and resolves the ncp into a
974 * positive or negative hit.
976 * The namecache is automatically adjusted by this function. The ncp
977 * is left locked on return.
980 vop_nresolve(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
982 struct vop_nresolve_args ap;
985 ap.a_head.a_desc = &vop_nresolve_desc;
986 ap.a_head.a_ops = ops;
990 DO_OPS(ops, error, &ap, vop_nresolve);
995 * nlookupdotdot takes an unlocked directory, dvp, and looks up "..", returning
996 * a locked parent directory in *vpp. If an error occurs *vpp will be NULL.
999 vop_nlookupdotdot(struct vop_ops *ops, struct vnode *dvp,
1000 struct vnode **vpp, struct ucred *cred)
1002 struct vop_nlookupdotdot_args ap;
1005 ap.a_head.a_desc = &vop_nlookupdotdot_desc;
1006 ap.a_head.a_ops = ops;
1011 DO_OPS(ops, error, &ap, vop_nlookupdotdot);
1016 * ncreate takes a locked, resolved ncp that typically represents a negative
1017 * cache hit and creates the file or node specified by the ncp, cred, and
1018 * vattr. If no error occurs a locked vnode is returned in *vpp.
1020 * The namecache is automatically adjusted by this function. The ncp
1021 * is left locked on return.
1024 vop_ncreate(struct vop_ops *ops, struct namecache *ncp,
1025 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1027 struct vop_ncreate_args ap;
1030 ap.a_head.a_desc = &vop_ncreate_desc;
1031 ap.a_head.a_ops = ops;
1037 DO_OPS(ops, error, &ap, vop_ncreate);
1038 if (error == 0 && *vpp)
1039 cache_update_fsmid_vp(*vpp);
1044 * nmkdir takes a locked, resolved ncp that typically represents a negative
1045 * cache hit and creates the directory specified by the ncp, cred, and
1046 * vattr. If no error occurs a locked vnode is returned in *vpp.
1048 * The namecache is automatically adjusted by this function. The ncp
1049 * is left locked on return.
1052 vop_nmkdir(struct vop_ops *ops, struct namecache *ncp,
1053 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1055 struct vop_nmkdir_args ap;
1058 ap.a_head.a_desc = &vop_nmkdir_desc;
1059 ap.a_head.a_ops = ops;
1065 DO_OPS(ops, error, &ap, vop_nmkdir);
1066 if (error == 0 && *vpp)
1067 cache_update_fsmid_vp(*vpp);
1072 * nmknod takes a locked, resolved ncp that typically represents a negative
1073 * cache hit and creates the node specified by the ncp, cred, and
1074 * vattr. If no error occurs a locked vnode is returned in *vpp.
1076 * The namecache is automatically adjusted by this function. The ncp
1077 * is left locked on return.
1080 vop_nmknod(struct vop_ops *ops, struct namecache *ncp,
1081 struct vnode **vpp, struct ucred *cred, struct vattr *vap)
1083 struct vop_nmknod_args ap;
1086 ap.a_head.a_desc = &vop_nmknod_desc;
1087 ap.a_head.a_ops = ops;
1093 DO_OPS(ops, error, &ap, vop_nmknod);
1094 if (error == 0 && *vpp)
1095 cache_update_fsmid_vp(*vpp);
1100 * nlink takes a locked, resolved ncp that typically represents a negative
1101 * cache hit and creates the node specified by the ncp, cred, and
1102 * existing vnode. The passed vp must be locked and will remain locked
1103 * on return, as does the ncp, whether an error occurs or not.
1105 * The namecache is automatically adjusted by this function. The ncp
1106 * is left locked on return.
1109 vop_nlink(struct vop_ops *ops, struct namecache *ncp,
1110 struct vnode *vp, struct ucred *cred)
1112 struct vop_nlink_args ap;
1115 ap.a_head.a_desc = &vop_nlink_desc;
1116 ap.a_head.a_ops = ops;
1121 DO_OPS(ops, error, &ap, vop_nlink);
1123 cache_update_fsmid(ncp);
1128 * nsymlink takes a locked, resolved ncp that typically represents a negative
1129 * cache hit and creates a symbolic link based on cred, vap, and target (the
1130 * contents of the link). If no error occurs a locked vnode is returned in
1133 * The namecache is automatically adjusted by this function. The ncp
1134 * is left locked on return.
1137 vop_nsymlink(struct vop_ops *ops, struct namecache *ncp,
1138 struct vnode **vpp, struct ucred *cred,
1139 struct vattr *vap, char *target)
1141 struct vop_nsymlink_args ap;
1144 ap.a_head.a_desc = &vop_nsymlink_desc;
1145 ap.a_head.a_ops = ops;
1150 ap.a_target = target;
1152 DO_OPS(ops, error, &ap, vop_nsymlink);
1154 cache_update_fsmid(ncp);
1159 * nwhiteout takes a locked, resolved ncp that can represent a positive or
1160 * negative hit and executes the whiteout function specified in flags.
1162 * The namecache is automatically adjusted by this function. The ncp
1163 * is left locked on return.
1166 vop_nwhiteout(struct vop_ops *ops, struct namecache *ncp,
1167 struct ucred *cred, int flags)
1169 struct vop_nwhiteout_args ap;
1172 ap.a_head.a_desc = &vop_nwhiteout_desc;
1173 ap.a_head.a_ops = ops;
1178 DO_OPS(ops, error, &ap, vop_nwhiteout);
1180 cache_update_fsmid(ncp);
1185 * nremove takes a locked, resolved ncp that generally represents a
1186 * positive hit and removes the file.
1188 * The namecache is automatically adjusted by this function. The ncp
1189 * is left locked on return.
1192 vop_nremove(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1194 struct vop_nremove_args ap;
1197 ap.a_head.a_desc = &vop_nremove_desc;
1198 ap.a_head.a_ops = ops;
1202 DO_OPS(ops, error, &ap, vop_nremove);
1204 cache_update_fsmid(ncp);
1209 * nrmdir takes a locked, resolved ncp that generally represents a
1210 * directory and removes the directory.
1212 * The namecache is automatically adjusted by this function. The ncp
1213 * is left locked on return.
1216 vop_nrmdir(struct vop_ops *ops, struct namecache *ncp, struct ucred *cred)
1218 struct vop_nrmdir_args ap;
1221 ap.a_head.a_desc = &vop_nrmdir_desc;
1222 ap.a_head.a_ops = ops;
1226 DO_OPS(ops, error, &ap, vop_nrmdir);
1228 cache_update_fsmid(ncp);
1233 * nrename takes TWO locked, resolved ncp's and the cred of the caller
1234 * and renames the source ncp to the target ncp. The target ncp may
1235 * represent a positive or negative hit.
1237 * The namecache is automatically adjusted by this function. The ncp
1238 * is left locked on return. The source ncp is typically changed to
1239 * a negative cache hit and the target ncp typically takes on the
1240 * source ncp's underlying file.
1243 vop_nrename(struct vop_ops *ops, struct namecache *fncp,
1244 struct namecache *tncp, struct ucred *cred)
1246 struct vop_nrename_args ap;
1249 ap.a_head.a_desc = &vop_nrename_desc;
1250 ap.a_head.a_ops = ops;
1255 DO_OPS(ops, error, &ap, vop_nrename);
1257 cache_update_fsmid(fncp);
1258 cache_update_fsmid(tncp);
1263 /************************************************************************
1264 * PRIMARY VNODE OPERATIONS FORWARDING CALLS *
1265 ************************************************************************
1267 * These procedures are called from VFSs such as unionfs and nullfs
1268 * when they wish to forward an operation on one VFS to another. The
1269 * argument structure/message is modified and then directly passed to the
1270 * appropriate routine. This routines may also be called by initiators
1271 * who have an argument structure in hand rather then discreet arguments.
1274 vop_vnoperate_ap(struct vop_generic_args *ap)
1276 struct vop_ops *ops;
1280 error = VOCALL(ops, ap);
1286 * This routine is called by the cache coherency layer to execute the actual
1287 * VFS operation. If a journaling layer is present we call though it, else
1288 * we call the native VOP functions.
1291 vop_cache_operate_ap(struct vop_generic_args *ap)
1293 struct vop_ops *ops;
1297 if (ops->vv_mount->mnt_vn_journal_ops)
1298 error = VOCALL(ops->vv_mount->mnt_vn_journal_ops, ap);
1300 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1306 * This routine is called by the journaling layer to execute the actual
1310 vop_journal_operate_ap(struct vop_generic_args *ap)
1312 struct vop_ops *ops;
1316 error = VOCALL(ops->vv_mount->mnt_vn_norm_ops, ap);
1322 vop_islocked_ap(struct vop_islocked_args *ap)
1326 DO_OPS(ap->a_head.a_ops, error, ap, vop_islocked);
1331 vop_open_ap(struct vop_open_args *ap)
1335 DO_OPS(ap->a_head.a_ops, error, ap, vop_open);
1340 vop_close_ap(struct vop_close_args *ap)
1344 DO_OPS(ap->a_head.a_ops, error, ap, vop_close);
1349 vop_access_ap(struct vop_access_args *ap)
1353 DO_OPS(ap->a_head.a_ops, error, ap, vop_access);
1358 vop_getattr_ap(struct vop_getattr_args *ap)
1362 DO_OPS(ap->a_head.a_ops, error, ap, vop_getattr);
1367 vop_setattr_ap(struct vop_setattr_args *ap)
1371 DO_OPS(ap->a_head.a_ops, error, ap, vop_setattr);
1376 vop_read_ap(struct vop_read_args *ap)
1380 DO_OPS(ap->a_head.a_ops, error, ap, vop_read);
1385 vop_write_ap(struct vop_write_args *ap)
1389 DO_OPS(ap->a_head.a_ops, error, ap, vop_write);
1394 vop_ioctl_ap(struct vop_ioctl_args *ap)
1398 DO_OPS(ap->a_head.a_ops, error, ap, vop_ioctl);
1403 vop_poll_ap(struct vop_poll_args *ap)
1407 DO_OPS(ap->a_head.a_ops, error, ap, vop_poll);
1412 vop_kqfilter_ap(struct vop_kqfilter_args *ap)
1416 DO_OPS(ap->a_head.a_ops, error, ap, vop_kqfilter);
1421 vop_revoke_ap(struct vop_revoke_args *ap)
1425 DO_OPS(ap->a_head.a_ops, error, ap, vop_revoke);
1430 vop_mmap_ap(struct vop_mmap_args *ap)
1434 DO_OPS(ap->a_head.a_ops, error, ap, vop_mmap);
1439 vop_fsync_ap(struct vop_fsync_args *ap)
1443 DO_OPS(ap->a_head.a_ops, error, ap, vop_fsync);
1448 vop_readdir_ap(struct vop_readdir_args *ap)
1452 DO_OPS(ap->a_head.a_ops, error, ap, vop_readdir);
1457 vop_readlink_ap(struct vop_readlink_args *ap)
1461 DO_OPS(ap->a_head.a_ops, error, ap, vop_readlink);
1466 vop_inactive_ap(struct vop_inactive_args *ap)
1470 DO_OPS(ap->a_head.a_ops, error, ap, vop_inactive);
1475 vop_reclaim_ap(struct vop_reclaim_args *ap)
1479 DO_OPS(ap->a_head.a_ops, error, ap, vop_reclaim);
1484 vop_lock_ap(struct vop_lock_args *ap)
1488 DO_OPS(ap->a_head.a_ops, error, ap, vop_lock);
1493 vop_unlock_ap(struct vop_unlock_args *ap)
1497 DO_OPS(ap->a_head.a_ops, error, ap, vop_unlock);
1502 vop_bmap_ap(struct vop_bmap_args *ap)
1506 DO_OPS(ap->a_head.a_ops, error, ap, vop_bmap);
1511 vop_strategy_ap(struct vop_strategy_args *ap)
1515 DO_OPS(ap->a_head.a_ops, error, ap, vop_strategy);
1520 vop_print_ap(struct vop_print_args *ap)
1524 DO_OPS(ap->a_head.a_ops, error, ap, vop_print);
1529 vop_pathconf_ap(struct vop_pathconf_args *ap)
1533 DO_OPS(ap->a_head.a_ops, error, ap, vop_pathconf);
1538 vop_advlock_ap(struct vop_advlock_args *ap)
1542 DO_OPS(ap->a_head.a_ops, error, ap, vop_advlock);
1547 vop_balloc_ap(struct vop_balloc_args *ap)
1551 DO_OPS(ap->a_head.a_ops, error, ap, vop_balloc);
1556 vop_reallocblks_ap(struct vop_reallocblks_args *ap)
1560 DO_OPS(ap->a_head.a_ops, error, ap, vop_reallocblks);
1565 vop_getpages_ap(struct vop_getpages_args *ap)
1569 DO_OPS(ap->a_head.a_ops, error, ap, vop_getpages);
1574 vop_putpages_ap(struct vop_putpages_args *ap)
1578 DO_OPS(ap->a_head.a_ops, error, ap, vop_putpages);
1583 vop_freeblks_ap(struct vop_freeblks_args *ap)
1587 DO_OPS(ap->a_head.a_ops, error, ap, vop_freeblks);
1592 vop_getacl_ap(struct vop_getacl_args *ap)
1596 DO_OPS(ap->a_head.a_ops, error, ap, vop_getacl);
1601 vop_setacl_ap(struct vop_setacl_args *ap)
1605 DO_OPS(ap->a_head.a_ops, error, ap, vop_setacl);
1610 vop_aclcheck_ap(struct vop_aclcheck_args *ap)
1614 DO_OPS(ap->a_head.a_ops, error, ap, vop_aclcheck);
1619 vop_getextattr_ap(struct vop_getextattr_args *ap)
1623 DO_OPS(ap->a_head.a_ops, error, ap, vop_getextattr);
1628 vop_setextattr_ap(struct vop_setextattr_args *ap)
1632 DO_OPS(ap->a_head.a_ops, error, ap, vop_setextattr);
1637 vop_mountctl_ap(struct vop_mountctl_args *ap)
1641 DO_OPS(ap->a_head.a_ops, error, ap, vop_mountctl);
1646 vop_nresolve_ap(struct vop_nresolve_args *ap)
1650 DO_OPS(ap->a_head.a_ops, error, ap, vop_nresolve);
1655 vop_nlookupdotdot_ap(struct vop_nlookupdotdot_args *ap)
1659 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlookupdotdot);
1664 vop_ncreate_ap(struct vop_ncreate_args *ap)
1668 DO_OPS(ap->a_head.a_ops, error, ap, vop_ncreate);
1673 vop_nmkdir_ap(struct vop_nmkdir_args *ap)
1677 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmkdir);
1682 vop_nmknod_ap(struct vop_nmknod_args *ap)
1686 DO_OPS(ap->a_head.a_ops, error, ap, vop_nmknod);
1691 vop_nlink_ap(struct vop_nlink_args *ap)
1695 DO_OPS(ap->a_head.a_ops, error, ap, vop_nlink);
1700 vop_nsymlink_ap(struct vop_nsymlink_args *ap)
1704 DO_OPS(ap->a_head.a_ops, error, ap, vop_nsymlink);
1709 vop_nwhiteout_ap(struct vop_nwhiteout_args *ap)
1713 DO_OPS(ap->a_head.a_ops, error, ap, vop_nwhiteout);
1718 vop_nremove_ap(struct vop_nremove_args *ap)
1722 DO_OPS(ap->a_head.a_ops, error, ap, vop_nremove);
1727 vop_nrmdir_ap(struct vop_nrmdir_args *ap)
1731 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrmdir);
1736 vop_nrename_ap(struct vop_nrename_args *ap)
1740 DO_OPS(ap->a_head.a_ops, error, ap, vop_nrename);