bridge(4): document net.link.bridge.pfil_onlyip
[dragonfly.git] / sys / kern / vfs_vfsops.c
blobfe5eb5fd2eda512a430083e3096e9a4f3a2497c5
1 /*
2 * Copyright (c) 2009 The DragonFly Project. All rights reserved.
4 * This code is derived from software contributed to The DragonFly Project
5 * by Matthew Dillon <dillon@backplane.com>
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
16 * distribution.
17 * 3. Neither the name of The DragonFly Project nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific, prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25 * COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26 * INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING,
27 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
29 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
31 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE.
35 * Implement mp->mnt_ops function call wrappers.
37 * These wrappers are responsible for handling all MPSAFE issues related to
38 * a mount.
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/buf.h>
44 #include <sys/conf.h>
45 #include <sys/dirent.h>
46 #include <sys/domain.h>
47 #include <sys/eventhandler.h>
48 #include <sys/fcntl.h>
49 #include <sys/kernel.h>
50 #include <sys/kthread.h>
51 #include <sys/malloc.h>
52 #include <sys/mbuf.h>
53 #include <sys/mount.h>
54 #include <sys/proc.h>
55 #include <sys/reboot.h>
56 #include <sys/socket.h>
57 #include <sys/stat.h>
58 #include <sys/sysctl.h>
59 #include <sys/syslog.h>
60 #include <sys/vmmeter.h>
61 #include <sys/vnode.h>
62 #include <sys/vfsops.h>
63 #include <sys/sysmsg.h>
65 #include <machine/limits.h>
67 #include <vm/vm.h>
68 #include <vm/vm_object.h>
69 #include <vm/vm_extern.h>
70 #include <vm/vm_kern.h>
71 #include <vm/pmap.h>
72 #include <vm/vm_map.h>
73 #include <vm/vm_page.h>
74 #include <vm/vm_pager.h>
75 #include <vm/vnode_pager.h>
76 #include <vm/vm_zone.h>
78 #include <sys/buf2.h>
81 * MPSAFE
83 int
84 vfs_mount(struct mount *mp, char *path, caddr_t data, struct ucred *cred)
86 VFS_MPLOCK_DECLARE;
87 int error;
89 VFS_MPLOCK(mp);
90 if (!mp->mnt_cred)
91 mp->mnt_cred = crhold(cred); /* For cr_prison */
92 error = (mp->mnt_op->vfs_mount)(mp, path, data, cred);
93 VFS_MPUNLOCK();
95 return (error);
99 * MPSAFE
102 vfs_start(struct mount *mp, int flags)
104 VFS_MPLOCK_DECLARE;
105 int error;
107 VFS_MPLOCK_FLAG(mp, MNTK_ST_MPSAFE);
108 error = (mp->mnt_op->vfs_start)(mp, flags);
109 if (error == 0) {
110 /* do not call vfs_acinit on mount updates */
111 if ((mp->mnt_flag & MNT_UPDATE) == 0)
112 VFS_ACINIT(mp,error);
114 VFS_MPUNLOCK();
115 if (error == EMOUNTEXIT)
116 error = 0;
117 return (error);
121 * MPSAFE
124 vfs_unmount(struct mount *mp, int mntflags)
126 VFS_MPLOCK_DECLARE;
127 int error;
128 int flags;
130 VFS_MPLOCK(mp);
131 VFS_ACDONE(mp);
132 flags = mp->mnt_kern_flag;
133 error = (mp->mnt_op->vfs_unmount)(mp, mntflags);
134 if (error == 0)
135 vn_syncer_thr_stop(mp);
136 VFS_MPUNLOCK();
137 return (error);
141 * MPSAFE
144 vfs_root(struct mount *mp, struct vnode **vpp)
146 VFS_MPLOCK_DECLARE;
147 int error;
149 VFS_MPLOCK(mp);
150 error = (mp->mnt_op->vfs_root)(mp, vpp);
151 VFS_MPUNLOCK();
152 return (error);
156 * MPSAFE
159 vfs_quotactl(struct mount *mp, int cmds, uid_t uid, caddr_t arg,
160 struct ucred *cred)
162 VFS_MPLOCK_DECLARE;
163 int error;
165 VFS_MPLOCK(mp);
166 error = (mp->mnt_op->vfs_quotactl)(mp, cmds, uid, arg, cred);
167 VFS_MPUNLOCK();
168 return (error);
172 * MPSAFE
175 vfs_statfs(struct mount *mp, struct statfs *sbp, struct ucred *cred)
177 VFS_MPLOCK_DECLARE;
178 int error;
180 VFS_MPLOCK(mp);
181 error = (mp->mnt_op->vfs_statfs)(mp, sbp, cred);
182 VFS_MPUNLOCK();
183 return (error);
187 * MPSAFE
190 vfs_statvfs(struct mount *mp, struct statvfs *sbp, struct ucred *cred)
192 VFS_MPLOCK_DECLARE;
193 int error;
195 VFS_MPLOCK(mp);
196 error = (mp->mnt_op->vfs_statvfs)(mp, sbp, cred);
197 VFS_MPUNLOCK();
198 return (error);
202 * MPSAFE
205 vfs_sync(struct mount *mp, int waitfor)
207 VFS_MPLOCK_DECLARE;
208 int error;
210 VFS_MPLOCK(mp);
211 error = (mp->mnt_op->vfs_sync)(mp, waitfor);
212 VFS_MPUNLOCK();
213 return (error);
217 * MPSAFE
220 vfs_vget(struct mount *mp, struct vnode *dvp, ino_t ino, struct vnode **vpp)
222 VFS_MPLOCK_DECLARE;
223 int error;
225 VFS_MPLOCK(mp);
226 error = (mp->mnt_op->vfs_vget)(mp, dvp, ino, vpp);
227 VFS_MPUNLOCK();
228 return (error);
232 * MPSAFE
235 vfs_fhtovp(struct mount *mp, struct vnode *rootvp,
236 struct fid *fhp, struct vnode **vpp)
238 VFS_MPLOCK_DECLARE;
239 int error;
241 VFS_MPLOCK(mp);
242 error = (mp->mnt_op->vfs_fhtovp)(mp, rootvp, fhp, vpp);
243 VFS_MPUNLOCK();
244 return (error);
248 * MPSAFE
251 vfs_checkexp(struct mount *mp, struct sockaddr *nam,
252 int *extflagsp, struct ucred **credanonp)
254 VFS_MPLOCK_DECLARE;
255 int error;
257 VFS_MPLOCK(mp);
258 error = (mp->mnt_op->vfs_checkexp)(mp, nam, extflagsp, credanonp);
259 VFS_MPUNLOCK();
260 return (error);
264 * MPSAFE
267 vfs_vptofh(struct vnode *vp, struct fid *fhp)
269 VFS_MPLOCK_DECLARE;
270 int error;
272 VFS_MPLOCK(vp->v_mount);
273 error = (vp->v_mount->mnt_op->vfs_vptofh)(vp, fhp);
274 VFS_MPUNLOCK();
275 return (error);
279 * MPSAFE
282 vfs_init(struct vfsconf *vfc)
284 int error;
286 error = (vfc->vfc_vfsops->vfs_init)(vfc);
288 return (error);
292 * MPSAFE
295 vfs_uninit(struct vfsconf *vfc, struct vfsconf *vfsp)
297 int error;
299 error = (vfc->vfc_vfsops->vfs_uninit)(vfsp);
301 return (error);
305 * MPSAFE
308 vfs_extattrctl(struct mount *mp, int cmd, struct vnode *vp,
309 int attrnamespace, const char *attrname,
310 struct ucred *cred)
312 VFS_MPLOCK_DECLARE;
313 int error;
315 VFS_MPLOCK(mp);
316 error = (mp->mnt_op->vfs_extattrctl)(mp, cmd, vp,
317 attrnamespace, attrname,
318 cred);
319 VFS_MPUNLOCK();
320 return (error);