static int fuse_loader(struct module *m, int what, void *arg) { static eventhandler_tag eh_tag = NULL; int err = 0; switch (what) { case MOD_LOAD: /* kldload */ fuse_pbuf_freecnt = nswbuf / 2 + 1; clone_setup(&fuseclones); mtx_init(&fuse_mtx, "fuse_mtx", NULL, MTX_DEF); eh_tag = EVENTHANDLER_REGISTER(dev_clone, fuse_device_clone, 0, 1000); if (eh_tag == NULL) { clone_cleanup(&fuseclones); mtx_destroy(&fuse_mtx); return (ENOMEM); } fuse_ipc_init(); /* vfs_modevent ignores its first arg */ if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) 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; case MOD_UNLOAD: if ((err = vfs_modevent(NULL, what, &fuse_vfsconf))) return (err); fuse_bringdown(eh_tag); break; default: return (EINVAL); } return (err); }
static int click_modevent(module_t mod, int type, void *data) { int ret; /* Load and unload the VFS part first */ ret = vfs_modevent(mod, type, data); if (ret != 0) { return ret; } switch (type) { case MOD_LOAD: printf("Click module loading\n"); if (init_module()) { ret = EINVAL; break; } ret = 0; break; case MOD_UNLOAD: printf("Click module unloading\n"); cleanup_module(); ret = 0; break; case MOD_SHUTDOWN: printf("Click module shutdown\n"); ret = 0; break; default: printf("Click: unknown module command %d\n", type); ret = EOPNOTSUPP; break; } return ret; }