Changeset View
Changeset View
Standalone View
Standalone View
sys/fs/fuse/fuse_main.c
| Show All 27 Lines | |||||
| * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||||
| * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||||
| * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||||
| * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||||
| * | * | ||||
| * Copyright (C) 2005 Csaba Henk. | * Copyright (C) 2005 Csaba Henk. | ||||
| * All rights reserved. | * All rights reserved. | ||||
| * | * | ||||
| * Copyright (c) 2019 The FreeBSD Foundation | |||||
| * | |||||
| * Portions of this software were developed by BFF Storage Systems, LLC under | |||||
| * sponsorship from the FreeBSD Foundation. | |||||
| * | |||||
| * Redistribution and use in source and binary forms, with or without | * Redistribution and use in source and binary forms, with or without | ||||
| * modification, are permitted provided that the following conditions | * modification, are permitted provided that the following conditions | ||||
| * are met: | * are met: | ||||
| * 1. Redistributions of source code must retain the above copyright | * 1. Redistributions of source code must retain the above copyright | ||||
| * notice, this list of conditions and the following disclaimer. | * notice, this list of conditions and the following disclaimer. | ||||
| * 2. Redistributions in binary form must reproduce the above copyright | * 2. Redistributions in binary form must reproduce the above copyright | ||||
| * notice, this list of conditions and the following disclaimer in the | * notice, this list of conditions and the following disclaimer in the | ||||
| * documentation and/or other materials provided with the distribution. | * documentation and/or other materials provided with the distribution. | ||||
| Show All 28 Lines | |||||
| #include <sys/vnode.h> | #include <sys/vnode.h> | ||||
| #include <sys/stat.h> | #include <sys/stat.h> | ||||
| #include <sys/file.h> | #include <sys/file.h> | ||||
| #include <sys/buf.h> | #include <sys/buf.h> | ||||
| #include <sys/sdt.h> | #include <sys/sdt.h> | ||||
| #include <sys/sysctl.h> | #include <sys/sysctl.h> | ||||
| #include "fuse.h" | #include "fuse.h" | ||||
| #include "fuse_file.h" | |||||
| #include "fuse_ipc.h" | |||||
| #include "fuse_internal.h" | |||||
| #include "fuse_node.h" | |||||
| static void fuse_bringdown(eventhandler_tag eh_tag); | static void fuse_bringdown(eventhandler_tag eh_tag); | ||||
| static int fuse_loader(struct module *m, int what, void *arg); | static int fuse_loader(struct module *m, int what, void *arg); | ||||
| struct mtx fuse_mtx; | struct mtx fuse_mtx; | ||||
| extern struct vfsops fuse_vfsops; | extern struct vfsops fuse_vfsops; | ||||
| extern struct cdevsw fuse_cdevsw; | extern struct cdevsw fuse_cdevsw; | ||||
| extern struct vop_vector fuse_vnops; | extern struct vop_vector fuse_fifonops; | ||||
| extern uma_zone_t fuse_pbuf_zone; | extern uma_zone_t fuse_pbuf_zone; | ||||
| static struct vfsconf fuse_vfsconf = { | static struct vfsconf fuse_vfsconf = { | ||||
| .vfc_version = VFS_VERSION, | .vfc_version = VFS_VERSION, | ||||
| .vfc_name = "fusefs", | .vfc_name = "fusefs", | ||||
| .vfc_vfsops = &fuse_vfsops, | .vfc_vfsops = &fuse_vfsops, | ||||
| .vfc_typenum = -1, | .vfc_typenum = -1, | ||||
| .vfc_flags = VFCF_JAIL | VFCF_SYNTHETIC | .vfc_flags = VFCF_JAIL | VFCF_SYNTHETIC | ||||
| }; | }; | ||||
| SYSCTL_NODE(_vfs, OID_AUTO, fusefs, CTLFLAG_RW, 0, "FUSE tunables"); | |||||
| SYSCTL_NODE(_vfs_fusefs, OID_AUTO, stats, CTLFLAG_RW, 0, "FUSE statistics"); | |||||
| SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_major, CTLFLAG_RD, | SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_major, CTLFLAG_RD, | ||||
| SYSCTL_NULL_INT_PTR, FUSE_KERNEL_VERSION, "FUSE kernel abi major version"); | SYSCTL_NULL_INT_PTR, FUSE_KERNEL_VERSION, "FUSE kernel abi major version"); | ||||
| SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_minor, CTLFLAG_RD, | SYSCTL_INT(_vfs_fusefs, OID_AUTO, kernelabi_minor, CTLFLAG_RD, | ||||
| SYSCTL_NULL_INT_PTR, FUSE_KERNEL_MINOR_VERSION, "FUSE kernel abi minor version"); | SYSCTL_NULL_INT_PTR, FUSE_KERNEL_MINOR_VERSION, "FUSE kernel abi minor version"); | ||||
| SDT_PROVIDER_DEFINE(fuse); | SDT_PROVIDER_DEFINE(fusefs); | ||||
| /****************************** | /****************************** | ||||
| * | * | ||||
| * >>> Module management stuff | * >>> Module management stuff | ||||
| * | * | ||||
| ******************************/ | ******************************/ | ||||
| static void | static void | ||||
| fuse_bringdown(eventhandler_tag eh_tag) | fuse_bringdown(eventhandler_tag eh_tag) | ||||
| { | { | ||||
| fuse_node_destroy(); | |||||
| fuse_internal_destroy(); | |||||
| fuse_file_destroy(); | |||||
| fuse_ipc_destroy(); | fuse_ipc_destroy(); | ||||
| fuse_device_destroy(); | fuse_device_destroy(); | ||||
| mtx_destroy(&fuse_mtx); | mtx_destroy(&fuse_mtx); | ||||
| } | } | ||||
| static int | static int | ||||
| fuse_loader(struct module *m, int what, void *arg) | fuse_loader(struct module *m, int what, void *arg) | ||||
| { | { | ||||
| static eventhandler_tag eh_tag = NULL; | static eventhandler_tag eh_tag = NULL; | ||||
| int err = 0; | int err = 0; | ||||
| switch (what) { | switch (what) { | ||||
| case MOD_LOAD: /* kldload */ | case MOD_LOAD: /* kldload */ | ||||
| mtx_init(&fuse_mtx, "fuse_mtx", NULL, MTX_DEF); | mtx_init(&fuse_mtx, "fuse_mtx", NULL, MTX_DEF); | ||||
| err = fuse_device_init(); | err = fuse_device_init(); | ||||
| if (err) { | if (err) { | ||||
| mtx_destroy(&fuse_mtx); | mtx_destroy(&fuse_mtx); | ||||
| return (err); | return (err); | ||||
| } | } | ||||
| fuse_ipc_init(); | fuse_ipc_init(); | ||||
| fuse_file_init(); | |||||
| fuse_internal_init(); | |||||
| fuse_node_init(); | |||||
| fuse_pbuf_zone = pbuf_zsecond_create("fusepbuf", nswbuf / 2); | fuse_pbuf_zone = pbuf_zsecond_create("fusepbuf", nswbuf / 2); | ||||
| /* vfs_modevent ignores its first arg */ | /* vfs_modevent ignores its first arg */ | ||||
| if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) | if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) | ||||
| fuse_bringdown(eh_tag); | fuse_bringdown(eh_tag); | ||||
| else | |||||
| printf("fuse-freebsd: version %s, FUSE ABI %d.%d\n", | |||||
| FUSE_FREEBSD_VERSION, | |||||
| FUSE_KERNEL_VERSION, FUSE_KERNEL_MINOR_VERSION); | |||||
| break; | break; | ||||
| case MOD_UNLOAD: | case MOD_UNLOAD: | ||||
| if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) | if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) | ||||
| return (err); | return (err); | ||||
| fuse_bringdown(eh_tag); | fuse_bringdown(eh_tag); | ||||
| uma_zdestroy(fuse_pbuf_zone); | uma_zdestroy(fuse_pbuf_zone); | ||||
| break; | break; | ||||
| default: | default: | ||||
| Show All 16 Lines | |||||