2 * Copyright (c) 2007-2009 Google Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * * Redistributions in binary form must reproduce the above
12 * copyright notice, this list of conditions and the following disclaimer
13 * in the documentation and/or other materials provided with the
15 * * Neither the name of Google Inc. nor the names of its
16 * contributors may be used to endorse or promote products derived from
17 * this software without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 * Copyright (C) 2005 Csaba Henk.
32 * All rights reserved.
34 * Redistribution and use in source and binary forms, with or without
35 * modification, are permitted provided that the following conditions
37 * 1. Redistributions of source code must retain the above copyright
38 * notice, this list of conditions and the following disclaimer.
39 * 2. Redistributions in binary form must reproduce the above copyright
40 * notice, this list of conditions and the following disclaimer in the
41 * documentation and/or other materials provided with the distribution.
43 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND
44 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
45 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
46 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE
47 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
48 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
49 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
50 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
51 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
52 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
56 #include <sys/cdefs.h>
57 __FBSDID("$FreeBSD$");
59 #include <sys/types.h>
60 #include <sys/module.h>
61 #include <sys/systm.h>
62 #include <sys/errno.h>
63 #include <sys/param.h>
64 #include <sys/kernel.h>
66 #include <sys/mutex.h>
68 #include <sys/mount.h>
69 #include <sys/vnode.h>
73 #include <sys/sysctl.h>
77 static void fuse_bringdown(eventhandler_tag eh_tag);
78 static int fuse_loader(struct module *m, int what, void *arg);
82 extern struct vfsops fuse_vfsops;
83 extern struct cdevsw fuse_cdevsw;
84 extern struct vop_vector fuse_vnops;
85 extern int fuse_pbuf_freecnt;
87 static struct vfsconf fuse_vfsconf = {
88 .vfc_version = VFS_VERSION,
90 .vfc_vfsops = &fuse_vfsops,
92 .vfc_flags = VFCF_SYNTHETIC
95 SYSCTL_INT(_vfs_fuse, OID_AUTO, kernelabi_major, CTLFLAG_RD,
96 SYSCTL_NULL_INT_PTR, FUSE_KERNEL_VERSION, "FUSE kernel abi major version");
97 SYSCTL_INT(_vfs_fuse, OID_AUTO, kernelabi_minor, CTLFLAG_RD,
98 SYSCTL_NULL_INT_PTR, FUSE_KERNEL_MINOR_VERSION, "FUSE kernel abi minor version");
100 /******************************
102 * >>> Module management stuff
104 ******************************/
107 fuse_bringdown(eventhandler_tag eh_tag)
111 fuse_device_destroy();
112 mtx_destroy(&fuse_mtx);
116 fuse_loader(struct module *m, int what, void *arg)
118 static eventhandler_tag eh_tag = NULL;
122 case MOD_LOAD: /* kldload */
123 fuse_pbuf_freecnt = nswbuf / 2 + 1;
124 mtx_init(&fuse_mtx, "fuse_mtx", NULL, MTX_DEF);
125 err = fuse_device_init();
127 mtx_destroy(&fuse_mtx);
132 /* vfs_modevent ignores its first arg */
133 if ((err = vfs_modevent(NULL, what, &fuse_vfsconf)))
134 fuse_bringdown(eh_tag);
136 printf("fuse-freebsd: version %s, FUSE ABI %d.%d\n",
137 FUSE_FREEBSD_VERSION,
138 FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION);
142 if ((err = vfs_modevent(NULL, what, &fuse_vfsconf)))
144 fuse_bringdown(eh_tag);
153 /* Registering the module */
155 static moduledata_t fuse_moddata = {
161 DECLARE_MODULE(fuse, fuse_moddata, SI_SUB_VFS, SI_ORDER_MIDDLE);
162 MODULE_VERSION(fuse, 1);