/*ARGSUSED*/ static int zfs_vfsinit(int fstype, char *name) { int error; zfsfstype = fstype; /* * Setup vfsops and vnodeops tables. */ error = vfs_setfsops(fstype, zfs_vfsops_template, &zfs_vfsops); if (error != 0) { cmn_err(CE_WARN, "zfs: bad vfs ops template"); } error = zfs_create_op_tables(); if (error) { zfs_remove_op_tables(); cmn_err(CE_WARN, "zfs: bad vnode ops template"); (void) vfs_freevfsops_by_type(zfsfstype); return (error); } mutex_init(&zfs_dev_mtx, NULL, MUTEX_DEFAULT, NULL); /* * Unique major number for all zfs mounts. * If we run out of 32-bit minors, we'll getudev() another major. */ zfs_major = ddi_name_to_major(ZFS_DRIVER); zfs_minor = ZFS_MIN_MINOR; return (0); }
void zfs_remove_op_tables() { /* * Remove vfs ops */ ASSERT(zfsfstype); (void) vfs_freevfsops_by_type(zfsfstype); zfsfstype = 0; /* * Remove vnode ops */ if (zfs_dvnodeops) vn_freevnodeops(zfs_dvnodeops); if (zfs_fvnodeops) vn_freevnodeops(zfs_fvnodeops); if (zfs_symvnodeops) vn_freevnodeops(zfs_symvnodeops); if (zfs_xdvnodeops) vn_freevnodeops(zfs_xdvnodeops); if (zfs_evnodeops) vn_freevnodeops(zfs_evnodeops); zfs_dvnodeops = NULL; zfs_fvnodeops = NULL; zfs_symvnodeops = NULL; zfs_xdvnodeops = NULL; zfs_evnodeops = NULL; }
int VMBlockInit(int fstype, // IN: file system type char *name) // IN: Name of the file system { int ret; static const fs_operation_def_t vfsOpsArr[] = { VMBLOCK_VOP(VFSNAME_MOUNT, vfs_mount, VMBlockMount), VMBLOCK_VOP(VFSNAME_UNMOUNT, vfs_unmount, VMBlockUnmount), VMBLOCK_VOP(VFSNAME_ROOT, vfs_root, VMBlockRoot), VMBLOCK_VOP(VFSNAME_STATVFS, vfs_statvfs, VMBlockStatvfs), { NULL } }; if (!name) { Warning("VMBlockInit: received NULL input from kernel.\n"); return EINVAL; } Debug(VMBLOCK_ENTRY_LOGLEVEL, "VMBlockInit: fstype=%d, name=\"%s\"\n", fstype, name); /* * Set our file system type and the vfs operations in the kernel's VFS * switch table. */ vmblockType = fstype; ret = vfs_setfsops(vmblockType, vfsOpsArr, &vmblockVfsOps); if (ret) { Warning("VMBlockInit: could not set vfs operations.\n"); return ret; } ret = vn_make_ops(name, vnodeOpsArr, &vmblockVnodeOps); if (ret) { Warning("VMBlockInit: could not create vnode operations.\n"); /* * It's important not to call vfs_freevfsops() here; that's only for * freeing ops created with vfs_makefsops(). */ vfs_freevfsops_by_type(vmblockType); return ret; } /* * We need to find a unique device number for this instance of the module; * it will be used at each mount to secure a unique device number and file * system identifier. If one cannot be located, we'll just use zero like * other Solaris file systems. */ if ((vmblockMajor = getudev()) == (major_t)-1) { Warning("VMBlockInit: could not obtain unique device.\n"); vmblockMajor = 0; } vmblockMinor = 0; mutex_init(&vmblockMutex, NULL, MUTEX_DEFAULT, NULL); return 0; }
void smbfsfini() { if (smbfs_vfsops) { (void) vfs_freevfsops_by_type(smbfsfstyp); smbfs_vfsops = NULL; } if (smbfs_vnodeops) { vn_freevnodeops(smbfs_vnodeops); smbfs_vnodeops = NULL; } }
int _fini() { int error; error = mod_remove(&modlinkage); if (error) return (error); /* * Tear down the operations vectors */ (void) vfs_freevfsops_by_type(tmpfsfstype); vn_freevnodeops(tmp_vnodeops); return (0); }
int _fini(void) { int error; error = mod_remove(&VMBlockModlinkage); if (error) { Warning("Could not remove vmblock module.\n"); return error; } BlockCleanup(); vfs_freevfsops_by_type(vmblockType); vn_freevnodeops(vmblockVnodeOps); return 0; }
int _fini() { int error; error = mod_remove(&modlinkage); if (error) return (error); /* * Tear down the operations vectors */ sffs_vnode_fini(); (void) vfs_freevfsops_by_type(sffs_fstype); /* * close connection to the provider */ sfprov_disconnect(sfprov); return (0); }
int _fini() { int error; /* * If a forceably unmounted instance is still hanging around, we cannot * allow the module to be unloaded because that would cause panics once * the VFS framework decides it's time to call into VFS_FREEVFS(). */ if (tmpfs_mountcount) return (EBUSY); error = mod_remove(&modlinkage); if (error) return (error); /* * Tear down the operations vectors */ (void) vfs_freevfsops_by_type(tmpfsfstype); vn_freevnodeops(tmp_vnodeops); return (0); }
iumfs_init(struct vfssw *iumfs_vfssw, int fstype) #endif { int err; DEBUG_PRINT((CE_CONT, "iumfs_init called\n")); DEBUG_PRINT((CE_CONT, "iumfs_init: fstype = %d(0x%x)\n", fstype, fstype)); iumfs_fstype = fstype; #ifdef SOL10 do { err = vfs_setfsops(fstype, iumfs_vfs_ops_def_array, &iumfs_vfsops); if (err) break; err = vn_make_ops(fsname, iumfs_vnode_ops_def_array, &iumfs_vnodeops); if (err) break; } while (FALSE); if (err) { if (iumfs_vfsops != NULL) { vfs_freevfsops_by_type(fstype); } if (iumfs_vnodeops != NULL) { vn_freevnodeops(iumfs_vnodeops); } } #endif /* * filesystem id に使うデバイス番号を決める。 */ iumfs_major = getudev(); DEBUG_PRINT((CE_CONT, "iumfs_init: major = %d(0x%x)\n", iumfs_major, iumfs_major)); DEBUG_PRINT((CE_CONT, "iumfs_init: return(%d)\n", err)); return (err); }
int _fini(void) { int error; error = mod_remove(&modlinkage); DTRACE_PROBE1(mod_remove, int, error); if (error) return (error); mutex_destroy(&hs_mounttab_lock); /* * Tear down the operations vectors */ (void) vfs_freevfsops_by_type(hsfsfstype); vn_freevnodeops(hsfs_vnodeops); hs_fini_hsnode_cache(); hsched_fini_caches(); return (0); }
int smbfsinit(int fstyp, char *name) { int error; error = vfs_setfsops(fstyp, smbfs_vfsops_template, &smbfs_vfsops); if (error != 0) { zcmn_err(GLOBAL_ZONEID, CE_WARN, "smbfsinit: bad vfs ops template"); return (error); } error = vn_make_ops(name, smbfs_vnodeops_template, &smbfs_vnodeops); if (error != 0) { (void) vfs_freevfsops_by_type(fstyp); zcmn_err(GLOBAL_ZONEID, CE_WARN, "smbfsinit: bad vnode ops template"); return (error); } smbfsfstyp = fstyp; return (0); }
/* * Cache clean up routine. This routine is called if mod_install() failed * and we have to clean up because the module could not be installed, * or by _fini() when we're unloading the module. */ static void cachefs_fini() { extern int cachefsfstyp; extern struct vnodeops *cachefs_vnodeops; if (cachefs_up == B_FALSE) { /* * cachefs_init() was not called on _init(), * nothing to deallocate. */ return; } /* * Clean up cachefs.0.key kstat. * Currently, you can only do a * modunload if cachefs_unloadable is nonzero, and that's * pretty much just for debugging. however, if there ever * comes a day when cachefs is more freely unloadable * (e.g. the modunload daemon can do it normally), then we'll * have to make changes in the stats_ API. this is because a * stats_cookie_t holds the id # derived from here, and it * will all go away at modunload time. thus, the API will * need to somehow be more robust than is currently necessary. */ kstat_delete_byname("cachefs", 0, "key"); if (cachefs_kstat_key != NULL) { cachefs_kstat_key_t *key; int i; for (i = 0; i < cachefs_kstat_key_n; i++) { key = cachefs_kstat_key + i; cachefs_kmem_free((void *)(uintptr_t)key->ks_mountpoint, strlen((char *)(uintptr_t)key->ks_mountpoint) + 1); cachefs_kmem_free((void *)(uintptr_t)key->ks_backfs, strlen((char *)(uintptr_t)key->ks_backfs) + 1); cachefs_kmem_free((void *)(uintptr_t)key->ks_cachedir, strlen((char *)(uintptr_t)key->ks_cachedir) + 1); cachefs_kmem_free((void *)(uintptr_t)key->ks_cacheid, strlen((char *)(uintptr_t)key->ks_cacheid) + 1); } cachefs_kmem_free(cachefs_kstat_key, cachefs_kstat_key_n * sizeof (*cachefs_kstat_key)); } /* * Clean up kmem_cache entities */ kmem_cache_destroy(cachefs_cache_kmcache); kmem_cache_destroy(cachefs_filegrp_cache); kmem_cache_destroy(cachefs_fscache_cache); kmem_cache_destroy(cachefs_req_cache); kmem_cache_destroy(cachefs_cnode_cache); #ifdef CFSRLDEBUG if (cachefs_rl_debug_cache != NULL) kmem_cache_destroy(cachefs_rl_debug_cache); #endif /* CFSRLDEBUG */ /* * Clean up the operations structures */ (void) vfs_freevfsops_by_type(cachefsfstyp); vn_freevnodeops(cachefs_vnodeops); /* * Destroy mutexes */ #ifdef CFSRLDEBUG mutex_destroy(&cachefs_rl_debug_mutex); #endif /* CFSRLDEBUG */ mutex_destroy(&cachefs_async_lock); mutex_destroy(&cachefs_minor_lock); mutex_destroy(&cachefs_rename_lock); mutex_destroy(&cachefs_kmem_lock); mutex_destroy(&cachefs_kstat_key_lock); mutex_destroy(&cachefs_newnum_lock); mutex_destroy(&cachefs_cachelock); }
/* * Save file system type/index, initialize vfs operations vector, get * unique device number for FIFOFS and initialize the FIFOFS hash. * Create and initialize a "generic" vfs pointer that will be placed * in the v_vfsp field of each pipe's vnode. */ int fifoinit(int fstype, char *name) { static const fs_operation_def_t fifo_vfsops_template[] = { NULL, NULL }; int error; major_t dev; fifofstype = fstype; error = vfs_setfsops(fstype, fifo_vfsops_template, &fifo_vfsops); if (error != 0) { cmn_err(CE_WARN, "fifoinit: bad vfs ops template"); return (error); } error = vn_make_ops(name, fifo_vnodeops_template, &fifo_vnodeops); if (error != 0) { (void) vfs_freevfsops_by_type(fstype); cmn_err(CE_WARN, "fifoinit: bad vnode ops template"); return (error); } if ((dev = getudev()) == (major_t)-1) { cmn_err(CE_WARN, "fifoinit: can't get unique device number"); dev = 0; } fifodev = makedevice(dev, 0); fifovfsp = kmem_zalloc(sizeof (struct vfs), KM_SLEEP); fifovfsp->vfs_next = NULL; vfs_setops(fifovfsp, fifo_vfsops); fifovfsp->vfs_vnodecovered = NULL; fifovfsp->vfs_flag = 0; fifovfsp->vfs_bsize = 1024; fifovfsp->vfs_fstype = fifofstype; vfs_make_fsid(&fifovfsp->vfs_fsid, fifodev, fifofstype); fifovfsp->vfs_data = NULL; fifovfsp->vfs_dev = fifodev; fifovfsp->vfs_bcount = 0; /* * It is necessary to initialize vfs_count here to 1. * This prevents the fifovfsp from getting freed when * a thread does a VFS_HOLD followed by a VFS_RELE * on the fifovfsp * * The fifovfsp should never be freed. */ fifovfsp->vfs_count = 1; mutex_init(&ftable_lock, NULL, MUTEX_DEFAULT, NULL); mutex_init(&fino_lock, NULL, MUTEX_DEFAULT, NULL); /* * vnodes are cached aligned */ fnode_cache = kmem_cache_create("fnode_cache", sizeof (fifodata_t) - sizeof (fifonode_t), 32, fnode_constructor, fnode_destructor, NULL, (void *)(sizeof (fifodata_t) - sizeof (fifonode_t)), NULL, 0); pipe_cache = kmem_cache_create("pipe_cache", sizeof (fifodata_t), 32, pipe_constructor, pipe_destructor, NULL, (void *)(sizeof (fifodata_t)), NULL, 0); #if FIFODEBUG if (Fifohiwat < FIFOHIWAT) Fifohiwat = FIFOHIWAT; #endif /* FIFODEBUG */ fifo_strdata.qi_minfo->mi_hiwat = Fifohiwat; return (0); }