unionfs_vfsops.c revision 1.1 1 1.1 ad /*-
2 1.1 ad * Copyright (c) 1994, 1995 The Regents of the University of California.
3 1.1 ad * Copyright (c) 1994, 1995 Jan-Simon Pendry.
4 1.1 ad * Copyright (c) 2005, 2006 Masanori Ozawa <ozawa (at) ongs.co.jp>, ONGS Inc.
5 1.1 ad * Copyright (c) 2006 Daichi Goto <daichi (at) freebsd.org>
6 1.1 ad * All rights reserved.
7 1.1 ad *
8 1.1 ad * This code is derived from software donated to Berkeley by
9 1.1 ad * Jan-Simon Pendry.
10 1.1 ad *
11 1.1 ad * Redistribution and use in source and binary forms, with or without
12 1.1 ad * modification, are permitted provided that the following conditions
13 1.1 ad * are met:
14 1.1 ad * 1. Redistributions of source code must retain the above copyright
15 1.1 ad * notice, this list of conditions and the following disclaimer.
16 1.1 ad * 2. Redistributions in binary form must reproduce the above copyright
17 1.1 ad * notice, this list of conditions and the following disclaimer in the
18 1.1 ad * documentation and/or other materials provided with the distribution.
19 1.1 ad * 4. Neither the name of the University nor the names of its contributors
20 1.1 ad * may be used to endorse or promote products derived from this software
21 1.1 ad * without specific prior written permission.
22 1.1 ad *
23 1.1 ad * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 1.1 ad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 1.1 ad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 1.1 ad * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 1.1 ad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 1.1 ad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 1.1 ad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 1.1 ad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 1.1 ad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 1.1 ad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
33 1.1 ad * SUCH DAMAGE.
34 1.1 ad *
35 1.1 ad * @(#)union_vfsops.c 8.20 (Berkeley) 5/20/95
36 1.1 ad * $FreeBSD: src/sys/fs/unionfs/union_vfsops.c,v 1.89 2008/01/13 14:44:06 attilio Exp $
37 1.1 ad */
38 1.1 ad
39 1.1 ad #include <sys/param.h>
40 1.1 ad #include <sys/systm.h>
41 1.1 ad #include <sys/kernel.h>
42 1.1 ad #include <sys/lock.h>
43 1.1 ad #include <sys/malloc.h>
44 1.1 ad #include <sys/mount.h>
45 1.1 ad #include <sys/namei.h>
46 1.1 ad #include <sys/proc.h>
47 1.1 ad #include <sys/vnode.h>
48 1.1 ad #include <sys/stat.h>
49 1.1 ad #include <sys/sysctl.h>
50 1.1 ad
51 1.1 ad #include <fs/unionfs/unionfs.h>
52 1.1 ad
53 1.1 ad MALLOC_DEFINE(M_UNIONFSMNT, "UNIONFS mount", "UNIONFS mount structure");
54 1.1 ad
55 1.1 ad struct vfsops unionfs_vfsops;
56 1.1 ad
57 1.1 ad VFS_PROTOS(unionfs);
58 1.1 ad
59 1.1 ad /*
60 1.1 ad * Mount unionfs layer.
61 1.1 ad */
62 1.1 ad int
63 1.1 ad unionfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
64 1.1 ad {
65 1.1 ad int error;
66 1.1 ad struct vnode *lowerrootvp;
67 1.1 ad struct vnode *upperrootvp;
68 1.1 ad struct unionfs_mount *ump;
69 1.1 ad int below;
70 1.1 ad uid_t uid;
71 1.1 ad gid_t gid;
72 1.1 ad u_short udir;
73 1.1 ad u_short ufile;
74 1.1 ad unionfs_copymode copymode;
75 1.1 ad unionfs_whitemode whitemode;
76 1.1 ad struct componentname fakecn;
77 1.1 ad struct nameidata nd, *ndp;
78 1.1 ad struct vattr va;
79 1.1 ad struct union_args *args = data;
80 1.1 ad kauth_cred_t cred;
81 1.1 ad size_t size;
82 1.1 ad size_t len;
83 1.1 ad const char *cp;
84 1.1 ad char *xp;
85 1.1 ad
86 1.1 ad if (*data_len < sizeof *args)
87 1.1 ad return EINVAL;
88 1.1 ad
89 1.1 ad UNIONFSDEBUG("unionfs_mount(mp = %p)\n", (void *)mp);
90 1.1 ad
91 1.1 ad error = 0;
92 1.1 ad below = 0;
93 1.1 ad uid = 0;
94 1.1 ad gid = 0;
95 1.1 ad udir = 0;
96 1.1 ad ufile = 0;
97 1.1 ad copymode = UNIONFS_TRANSPARENT; /* default */
98 1.1 ad whitemode = UNIONFS_WHITE_ALWAYS;
99 1.1 ad ndp = &nd;
100 1.1 ad cred = kauth_cred_get();
101 1.1 ad
102 1.1 ad if (mp->mnt_flag & MNT_ROOTFS) {
103 1.1 ad printf("union_mount: cannot union mount root filesystem\n");
104 1.1 ad return (EOPNOTSUPP);
105 1.1 ad }
106 1.1 ad
107 1.1 ad if (mp->mnt_flag & MNT_GETARGS) {
108 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
109 1.1 ad if (ump == NULL)
110 1.1 ad return EIO;
111 1.1 ad args->target = NULL;
112 1.1 ad args->mntflags = ump->um_op;
113 1.1 ad *data_len = sizeof *args;
114 1.1 ad return 0;
115 1.1 ad }
116 1.1 ad
117 1.1 ad /*
118 1.1 ad * Update is a no operation.
119 1.1 ad */
120 1.1 ad if (mp->mnt_flag & MNT_UPDATE) {
121 1.1 ad printf("union_mount: cannot update union mount\n");
122 1.1 ad return (EOPNOTSUPP);
123 1.1 ad }
124 1.1 ad
125 1.1 ad vn_lock(mp->mnt_vnodecovered, LK_EXCLUSIVE | LK_RETRY);
126 1.1 ad error = VOP_GETATTR(mp->mnt_vnodecovered, &va, cred);
127 1.1 ad if (!error) {
128 1.1 ad if (udir == 0)
129 1.1 ad udir = va.va_mode;
130 1.1 ad if (ufile == 0)
131 1.1 ad ufile = va.va_mode;
132 1.1 ad uid = va.va_uid;
133 1.1 ad gid = va.va_gid;
134 1.1 ad }
135 1.1 ad VOP_UNLOCK(mp->mnt_vnodecovered, 0);
136 1.1 ad if (error)
137 1.1 ad return (error);
138 1.1 ad
139 1.1 ad switch (args->mntflags & UNMNT_OPMASK) {
140 1.1 ad case UNMNT_ABOVE:
141 1.1 ad below = 0;
142 1.1 ad break;
143 1.1 ad
144 1.1 ad case UNMNT_BELOW:
145 1.1 ad below = 1;
146 1.1 ad break;
147 1.1 ad
148 1.1 ad case UNMNT_REPLACE:
149 1.1 ad default:
150 1.1 ad return EINVAL;
151 1.1 ad }
152 1.1 ad
153 1.1 ad /* If copymode is UNIONFS_TRADITIONAL, uid/gid is mounted user. */
154 1.1 ad if (copymode == UNIONFS_TRADITIONAL) {
155 1.1 ad uid = kauth_cred_getuid(cred);
156 1.1 ad gid = kauth_cred_getgid(cred);
157 1.1 ad }
158 1.1 ad
159 1.1 ad UNIONFSDEBUG("unionfs_mount: uid=%d, gid=%d\n", uid, gid);
160 1.1 ad UNIONFSDEBUG("unionfs_mount: udir=0%03o, ufile=0%03o\n", udir, ufile);
161 1.1 ad UNIONFSDEBUG("unionfs_mount: copymode=%d\n", copymode);
162 1.1 ad
163 1.1 ad /*
164 1.1 ad * Find upper node
165 1.1 ad */
166 1.1 ad NDINIT(ndp, LOOKUP, FOLLOW | LOCKLEAF, UIO_USERSPACE, args->target);
167 1.1 ad if ((error = namei(ndp)))
168 1.1 ad return (error);
169 1.1 ad
170 1.1 ad /* get root vnodes */
171 1.1 ad lowerrootvp = mp->mnt_vnodecovered;
172 1.1 ad upperrootvp = ndp->ni_vp;
173 1.1 ad
174 1.1 ad vrele(ndp->ni_dvp);
175 1.1 ad ndp->ni_dvp = NULLVP;
176 1.1 ad
177 1.1 ad /* create unionfs_mount */
178 1.1 ad ump = (struct unionfs_mount *)malloc(sizeof(struct unionfs_mount),
179 1.1 ad M_UNIONFSMNT, M_WAITOK | M_ZERO);
180 1.1 ad
181 1.1 ad /*
182 1.1 ad * Save reference
183 1.1 ad */
184 1.1 ad if (below) {
185 1.1 ad VOP_UNLOCK(upperrootvp, 0);
186 1.1 ad vn_lock(lowerrootvp, LK_EXCLUSIVE | LK_RETRY);
187 1.1 ad ump->um_lowervp = upperrootvp;
188 1.1 ad ump->um_uppervp = lowerrootvp;
189 1.1 ad } else {
190 1.1 ad ump->um_lowervp = lowerrootvp;
191 1.1 ad ump->um_uppervp = upperrootvp;
192 1.1 ad }
193 1.1 ad ump->um_rootvp = NULLVP;
194 1.1 ad ump->um_uid = uid;
195 1.1 ad ump->um_gid = gid;
196 1.1 ad ump->um_udir = udir;
197 1.1 ad ump->um_ufile = ufile;
198 1.1 ad ump->um_copymode = copymode;
199 1.1 ad ump->um_whitemode = whitemode;
200 1.1 ad
201 1.1 ad if ((lowerrootvp->v_mount->mnt_iflag & IMNT_MPSAFE) &&
202 1.1 ad (upperrootvp->v_mount->mnt_flag & IMNT_MPSAFE))
203 1.1 ad mp->mnt_iflag |= IMNT_MPSAFE;
204 1.1 ad mp->mnt_data = ump;
205 1.1 ad
206 1.1 ad /*
207 1.1 ad * Copy upper layer's RDONLY flag.
208 1.1 ad */
209 1.1 ad mp->mnt_flag |= ump->um_uppervp->v_mount->mnt_flag & MNT_RDONLY;
210 1.1 ad
211 1.1 ad /*
212 1.1 ad * Check whiteout
213 1.1 ad */
214 1.1 ad if ((mp->mnt_flag & MNT_RDONLY) == 0) {
215 1.1 ad memset(&fakecn, 0, sizeof(fakecn));
216 1.1 ad fakecn.cn_nameiop = LOOKUP;
217 1.1 ad error = VOP_WHITEOUT(ump->um_uppervp, &fakecn, LOOKUP);
218 1.1 ad if (error) {
219 1.1 ad if (below) {
220 1.1 ad VOP_UNLOCK(ump->um_uppervp, 0);
221 1.1 ad vrele(upperrootvp);
222 1.1 ad } else
223 1.1 ad vput(ump->um_uppervp);
224 1.1 ad free(ump, M_UNIONFSMNT);
225 1.1 ad mp->mnt_data = NULL;
226 1.1 ad return (error);
227 1.1 ad }
228 1.1 ad }
229 1.1 ad
230 1.1 ad /*
231 1.1 ad * Unlock the node
232 1.1 ad */
233 1.1 ad VOP_UNLOCK(ump->um_uppervp, 0);
234 1.1 ad
235 1.1 ad ump->um_op = args->mntflags & UNMNT_OPMASK;
236 1.1 ad
237 1.1 ad /*
238 1.1 ad * Get the unionfs root vnode.
239 1.1 ad */
240 1.1 ad error = unionfs_nodeget(mp, ump->um_uppervp, ump->um_lowervp,
241 1.1 ad NULLVP, &(ump->um_rootvp), NULL);
242 1.1 ad vrele(upperrootvp);
243 1.1 ad if (error) {
244 1.1 ad free(ump, M_UNIONFSMNT);
245 1.1 ad mp->mnt_data = NULL;
246 1.1 ad return (error);
247 1.1 ad }
248 1.1 ad
249 1.1 ad /*
250 1.1 ad * Check mnt_flag
251 1.1 ad */
252 1.1 ad if ((ump->um_lowervp->v_mount->mnt_flag & MNT_LOCAL) &&
253 1.1 ad (ump->um_uppervp->v_mount->mnt_flag & MNT_LOCAL))
254 1.1 ad mp->mnt_flag |= MNT_LOCAL;
255 1.1 ad
256 1.1 ad /*
257 1.1 ad * Get new fsid
258 1.1 ad */
259 1.1 ad vfs_getnewfsid(mp);
260 1.1 ad
261 1.1 ad error = set_statvfs_info(path, UIO_USERSPACE, NULL, UIO_USERSPACE,
262 1.1 ad mp->mnt_op->vfs_name, mp, curlwp);
263 1.1 ad if (error) {
264 1.1 ad unionfs_noderem(ump->um_rootvp);
265 1.1 ad free(ump, M_UNIONFSMNT);
266 1.1 ad mp->mnt_data = NULL;
267 1.1 ad return (error);
268 1.1 ad }
269 1.1 ad
270 1.1 ad switch (ump->um_op) {
271 1.1 ad case UNMNT_ABOVE:
272 1.1 ad cp = "<above>:";
273 1.1 ad break;
274 1.1 ad case UNMNT_BELOW:
275 1.1 ad cp = "<below>:";
276 1.1 ad break;
277 1.1 ad default:
278 1.1 ad panic("union_mount: bad um_op");
279 1.1 ad break;
280 1.1 ad }
281 1.1 ad len = strlen(cp);
282 1.1 ad memcpy(mp->mnt_stat.f_mntfromname, cp, len);
283 1.1 ad xp = mp->mnt_stat.f_mntfromname + len;
284 1.1 ad len = MNAMELEN - len;
285 1.1 ad (void) copyinstr(args->target, xp, len - 1, &size);
286 1.1 ad memset(xp + size, 0, len - size);
287 1.1 ad
288 1.1 ad UNIONFSDEBUG("unionfs_mount: from %s, on %s\n",
289 1.1 ad mp->mnt_stat.f_mntfromname, mp->mnt_stat.f_mntonname);
290 1.1 ad
291 1.1 ad return (0);
292 1.1 ad }
293 1.1 ad
294 1.1 ad /*
295 1.1 ad * Free reference to unionfs layer
296 1.1 ad */
297 1.1 ad int
298 1.1 ad unionfs_unmount(struct mount *mp, int mntflags)
299 1.1 ad {
300 1.1 ad struct unionfs_mount *ump;
301 1.1 ad int error;
302 1.1 ad int freeing;
303 1.1 ad int flags;
304 1.1 ad
305 1.1 ad UNIONFSDEBUG("unionfs_unmount: mp = %p\n", (void *)mp);
306 1.1 ad
307 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
308 1.1 ad flags = 0;
309 1.1 ad
310 1.1 ad if (mntflags & MNT_FORCE)
311 1.1 ad flags |= FORCECLOSE;
312 1.1 ad
313 1.1 ad /* vflush (no need to call vrele) */
314 1.1 ad for (freeing = 0; (error = vflush(mp, NULL, flags)) != 0;) {
315 1.1 ad struct vnode *vp;
316 1.1 ad int n;
317 1.1 ad
318 1.1 ad /* count #vnodes held on mount list */
319 1.1 ad n = 0;
320 1.1 ad TAILQ_FOREACH(vp, &mp->mnt_vnodelist, v_mntvnodes)
321 1.1 ad n++;
322 1.1 ad
323 1.1 ad /* if this is unchanged then stop */
324 1.1 ad if (n == freeing)
325 1.1 ad break;
326 1.1 ad
327 1.1 ad /* otherwise try once more time */
328 1.1 ad freeing = n;
329 1.1 ad }
330 1.1 ad
331 1.1 ad if (error)
332 1.1 ad return (error);
333 1.1 ad
334 1.1 ad free(ump, M_UNIONFSMNT);
335 1.1 ad mp->mnt_data = 0;
336 1.1 ad
337 1.1 ad return (0);
338 1.1 ad }
339 1.1 ad
340 1.1 ad int
341 1.1 ad unionfs_root(struct mount *mp, struct vnode **vpp)
342 1.1 ad {
343 1.1 ad struct unionfs_mount *ump;
344 1.1 ad struct vnode *vp;
345 1.1 ad
346 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
347 1.1 ad vp = ump->um_rootvp;
348 1.1 ad
349 1.1 ad UNIONFSDEBUG("unionfs_root: rootvp=%p locked=%x\n",
350 1.1 ad vp, VOP_ISLOCKED(vp));
351 1.1 ad
352 1.1 ad vref(vp);
353 1.1 ad vn_lock(vp, LK_EXCLUSIVE);
354 1.1 ad
355 1.1 ad *vpp = vp;
356 1.1 ad
357 1.1 ad return (0);
358 1.1 ad }
359 1.1 ad
360 1.1 ad int
361 1.1 ad unionfs_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg)
362 1.1 ad {
363 1.1 ad struct unionfs_mount *ump;
364 1.1 ad
365 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
366 1.1 ad
367 1.1 ad /*
368 1.1 ad * Writing is always performed to upper vnode.
369 1.1 ad */
370 1.1 ad return (VFS_QUOTACTL(ump->um_uppervp->v_mount, cmd, uid, arg));
371 1.1 ad }
372 1.1 ad
373 1.1 ad int
374 1.1 ad unionfs_statvfs(struct mount *mp, struct statvfs *sbp)
375 1.1 ad {
376 1.1 ad struct unionfs_mount *ump;
377 1.1 ad int error;
378 1.1 ad uint64_t lbsize;
379 1.1 ad struct statvfs *sbuf = malloc(sizeof(*sbuf), M_TEMP, M_WAITOK | M_ZERO);
380 1.1 ad
381 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
382 1.1 ad
383 1.1 ad UNIONFSDEBUG("unionfs_statvfs(mp = %p, lvp = %p, uvp = %p)\n",
384 1.1 ad (void *)mp, (void *)ump->um_lowervp, (void *)ump->um_uppervp);
385 1.1 ad
386 1.1 ad error = VFS_STATVFS(ump->um_lowervp->v_mount, sbuf);
387 1.1 ad if (error)
388 1.1 ad goto done;
389 1.1 ad
390 1.1 ad /* now copy across the "interesting" information and fake the rest */
391 1.1 ad sbp->f_blocks = sbuf->f_blocks;
392 1.1 ad sbp->f_files = sbuf->f_files;
393 1.1 ad
394 1.1 ad lbsize = sbuf->f_bsize;
395 1.1 ad
396 1.1 ad error = VFS_STATVFS(ump->um_uppervp->v_mount, sbuf);
397 1.1 ad if (error)
398 1.1 ad goto done;
399 1.1 ad
400 1.1 ad /*
401 1.1 ad * The FS type etc is copy from upper vfs.
402 1.1 ad * (write able vfs have priority)
403 1.1 ad */
404 1.1 ad sbp->f_flag = sbuf->f_flag;
405 1.1 ad sbp->f_bsize = sbuf->f_bsize;
406 1.1 ad sbp->f_iosize = sbuf->f_iosize;
407 1.1 ad
408 1.1 ad if (sbuf->f_bsize != lbsize)
409 1.1 ad sbp->f_blocks = ((off_t)sbp->f_blocks * lbsize) / sbuf->f_bsize;
410 1.1 ad
411 1.1 ad sbp->f_blocks += sbuf->f_blocks;
412 1.1 ad sbp->f_bfree = sbuf->f_bfree;
413 1.1 ad sbp->f_bavail = sbuf->f_bavail;
414 1.1 ad sbp->f_files += sbuf->f_files;
415 1.1 ad sbp->f_ffree = sbuf->f_ffree;
416 1.1 ad
417 1.1 ad done:
418 1.1 ad free(sbuf, M_TEMP);
419 1.1 ad return (error);
420 1.1 ad }
421 1.1 ad
422 1.1 ad int
423 1.1 ad unionfs_sync(struct mount *mp, int waitfor, kauth_cred_t cred)
424 1.1 ad {
425 1.1 ad /* nothing to do */
426 1.1 ad return (0);
427 1.1 ad }
428 1.1 ad
429 1.1 ad int
430 1.1 ad unionfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
431 1.1 ad {
432 1.1 ad return (EOPNOTSUPP);
433 1.1 ad }
434 1.1 ad
435 1.1 ad int
436 1.1 ad unionfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp)
437 1.1 ad {
438 1.1 ad return (EOPNOTSUPP);
439 1.1 ad }
440 1.1 ad
441 1.1 ad int
442 1.1 ad unionfs_extattrctl(struct mount *mp, int cmd, struct vnode *filename_vp,
443 1.1 ad int namespace, const char *attrname)
444 1.1 ad {
445 1.1 ad struct unionfs_mount *ump;
446 1.1 ad struct unionfs_node *unp;
447 1.1 ad
448 1.1 ad ump = MOUNTTOUNIONFSMOUNT(mp);
449 1.1 ad unp = VTOUNIONFS(filename_vp);
450 1.1 ad
451 1.1 ad if (unp->un_uppervp != NULLVP) {
452 1.1 ad return (VFS_EXTATTRCTL(ump->um_uppervp->v_mount, cmd,
453 1.1 ad unp->un_uppervp, namespace, attrname));
454 1.1 ad } else {
455 1.1 ad return (VFS_EXTATTRCTL(ump->um_lowervp->v_mount, cmd,
456 1.1 ad unp->un_lowervp, namespace, attrname));
457 1.1 ad }
458 1.1 ad }
459 1.1 ad
460 1.1 ad /*
461 1.1 ad * Initialize
462 1.1 ad */
463 1.1 ad void
464 1.1 ad unionfs_init(void)
465 1.1 ad {
466 1.1 ad UNIONFSDEBUG("unionfs_init\n"); /* printed during system boot */
467 1.1 ad }
468 1.1 ad
469 1.1 ad static int
470 1.1 ad unionfs_renamelock_enter(struct mount *mp)
471 1.1 ad {
472 1.1 ad struct unionfs_mount *um = MOUNTTOUNIONFSMOUNT(mp);
473 1.1 ad
474 1.1 ad /* Lock just the upper fs, where the action happens. */
475 1.1 ad return VFS_RENAMELOCK_ENTER(um->um_uppervp->v_mount);
476 1.1 ad }
477 1.1 ad
478 1.1 ad static void
479 1.1 ad unionfs_renamelock_exit(struct mount *mp)
480 1.1 ad {
481 1.1 ad struct unionfs_mount *um = MOUNTTOUNIONFSMOUNT(mp);
482 1.1 ad
483 1.1 ad VFS_RENAMELOCK_EXIT(um->um_uppervp->v_mount);
484 1.1 ad }
485 1.1 ad
486 1.1 ad int
487 1.1 ad unionfs_start(struct mount *mp, int flags)
488 1.1 ad {
489 1.1 ad
490 1.1 ad return (0);
491 1.1 ad }
492 1.1 ad
493 1.1 ad void
494 1.1 ad unionfs_done(void)
495 1.1 ad {
496 1.1 ad
497 1.1 ad /* Make sure to unset the readdir hook. */
498 1.1 ad vn_union_readdir_hook = NULL;
499 1.1 ad }
500 1.1 ad
501 1.1 ad SYSCTL_SETUP(sysctl_vfs_unionfs_setup, "sysctl vfs.union subtree setup")
502 1.1 ad {
503 1.1 ad
504 1.1 ad sysctl_createv(clog, 0, NULL, NULL,
505 1.1 ad CTLFLAG_PERMANENT,
506 1.1 ad CTLTYPE_NODE, "vfs", NULL,
507 1.1 ad NULL, 0, NULL, 0,
508 1.1 ad CTL_VFS, CTL_EOL);
509 1.1 ad sysctl_createv(clog, 0, NULL, NULL,
510 1.1 ad CTLFLAG_PERMANENT,
511 1.1 ad CTLTYPE_NODE, "union",
512 1.1 ad SYSCTL_DESCR("Union file system"),
513 1.1 ad NULL, 0, NULL, 0,
514 1.1 ad CTL_VFS, 15, CTL_EOL);
515 1.1 ad /*
516 1.1 ad * XXX the "15" above could be dynamic, thereby eliminating
517 1.1 ad * one more instance of the "number to vfs" mapping problem,
518 1.1 ad * but "15" is the order as taken from sys/mount.h
519 1.1 ad */
520 1.1 ad }
521 1.1 ad
522 1.1 ad extern const struct vnodeopv_desc unionfs_vnodeop_opv_desc;
523 1.1 ad
524 1.1 ad const struct vnodeopv_desc * const unionfs_vnodeopv_descs[] = {
525 1.1 ad &unionfs_vnodeop_opv_desc,
526 1.1 ad NULL,
527 1.1 ad };
528 1.1 ad
529 1.1 ad struct vfsops unionfs_vfsops = {
530 1.1 ad MOUNT_UNION,
531 1.1 ad sizeof (struct unionfs_args),
532 1.1 ad unionfs_mount,
533 1.1 ad unionfs_start,
534 1.1 ad unionfs_unmount,
535 1.1 ad unionfs_root,
536 1.1 ad (void *)eopnotsupp, /* vfs_quotactl */
537 1.1 ad unionfs_statvfs,
538 1.1 ad unionfs_sync,
539 1.1 ad unionfs_vget,
540 1.1 ad (void *)eopnotsupp, /* vfs_fhtovp */
541 1.1 ad (void *)eopnotsupp, /* vfs_vptofh */
542 1.1 ad unionfs_init,
543 1.1 ad NULL, /* vfs_reinit */
544 1.1 ad unionfs_done,
545 1.1 ad NULL, /* vfs_mountroot */
546 1.1 ad (int (*)(struct mount *, struct vnode *, struct timespec *)) eopnotsupp,
547 1.1 ad vfs_stdextattrctl,
548 1.1 ad (void *)eopnotsupp, /* vfs_suspendctl */
549 1.1 ad unionfs_renamelock_enter,
550 1.1 ad unionfs_renamelock_exit,
551 1.1 ad unionfs_vnodeopv_descs,
552 1.1 ad 0, /* vfs_refcount */
553 1.1 ad { NULL, NULL },
554 1.1 ad };
555 1.1 ad VFS_ATTACH(unionfs_vfsops);
556