Home | History | Annotate | Line # | Download | only in tmpfs
tmpfs_vfsops.c revision 1.49
      1  1.49     rmind /*	$NetBSD: tmpfs_vfsops.c,v 1.49 2011/05/24 01:09:47 rmind Exp $	*/
      2   1.1      jmmv 
      3   1.1      jmmv /*
      4  1.34        ad  * Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
      5   1.1      jmmv  * All rights reserved.
      6   1.1      jmmv  *
      7   1.1      jmmv  * This code is derived from software contributed to The NetBSD Foundation
      8   1.6      jmmv  * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
      9   1.6      jmmv  * 2005 program.
     10   1.1      jmmv  *
     11   1.1      jmmv  * Redistribution and use in source and binary forms, with or without
     12   1.1      jmmv  * modification, are permitted provided that the following conditions
     13   1.1      jmmv  * are met:
     14   1.1      jmmv  * 1. Redistributions of source code must retain the above copyright
     15   1.1      jmmv  *    notice, this list of conditions and the following disclaimer.
     16   1.1      jmmv  * 2. Redistributions in binary form must reproduce the above copyright
     17   1.1      jmmv  *    notice, this list of conditions and the following disclaimer in the
     18   1.1      jmmv  *    documentation and/or other materials provided with the distribution.
     19   1.1      jmmv  *
     20   1.1      jmmv  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     21   1.1      jmmv  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     22   1.1      jmmv  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     23   1.1      jmmv  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     24   1.1      jmmv  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     25   1.1      jmmv  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     26   1.1      jmmv  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     27   1.1      jmmv  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     28   1.1      jmmv  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     29   1.1      jmmv  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     30   1.1      jmmv  * POSSIBILITY OF SUCH DAMAGE.
     31   1.1      jmmv  */
     32   1.1      jmmv 
     33   1.1      jmmv /*
     34   1.2      jmmv  * Efficient memory file system.
     35   1.6      jmmv  *
     36   1.6      jmmv  * tmpfs is a file system that uses NetBSD's virtual memory sub-system
     37   1.6      jmmv  * (the well-known UVM) to store file data and metadata in an efficient
     38   1.6      jmmv  * way.  This means that it does not follow the structure of an on-disk
     39   1.6      jmmv  * file system because it simply does not need to.  Instead, it uses
     40   1.6      jmmv  * memory-specific data structures and algorithms to automatically
     41   1.6      jmmv  * allocate and release resources.
     42   1.1      jmmv  */
     43   1.1      jmmv 
     44   1.1      jmmv #include <sys/cdefs.h>
     45  1.49     rmind __KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.49 2011/05/24 01:09:47 rmind Exp $");
     46   1.1      jmmv 
     47   1.1      jmmv #include <sys/param.h>
     48   1.1      jmmv #include <sys/types.h>
     49  1.34        ad #include <sys/kmem.h>
     50   1.1      jmmv #include <sys/mount.h>
     51   1.8      jmmv #include <sys/stat.h>
     52   1.1      jmmv #include <sys/systm.h>
     53   1.1      jmmv #include <sys/vnode.h>
     54  1.22        ad #include <sys/proc.h>
     55  1.41    rumble #include <sys/module.h>
     56   1.1      jmmv 
     57  1.36  dholland #include <miscfs/genfs/genfs.h>
     58   1.1      jmmv #include <fs/tmpfs/tmpfs.h>
     59  1.44     pooka #include <fs/tmpfs/tmpfs_args.h>
     60   1.1      jmmv 
     61  1.41    rumble MODULE(MODULE_CLASS_VFS, tmpfs, NULL);
     62  1.41    rumble 
     63  1.48     rmind struct pool	tmpfs_dirent_pool;
     64  1.48     rmind struct pool	tmpfs_node_pool;
     65   1.1      jmmv 
     66  1.32     pooka static int	tmpfs_mount(struct mount *, const char *, void *, size_t *);
     67  1.32     pooka static int	tmpfs_start(struct mount *, int);
     68  1.32     pooka static int	tmpfs_unmount(struct mount *, int);
     69   1.1      jmmv static int	tmpfs_root(struct mount *, struct vnode **);
     70   1.1      jmmv static int	tmpfs_vget(struct mount *, ino_t, struct vnode **);
     71   1.1      jmmv static int	tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **);
     72  1.13    martin static int	tmpfs_vptofh(struct vnode *, struct fid *, size_t *);
     73  1.32     pooka static int	tmpfs_statvfs(struct mount *, struct statvfs *);
     74  1.32     pooka static int	tmpfs_sync(struct mount *, int, kauth_cred_t);
     75   1.1      jmmv static void	tmpfs_init(void);
     76   1.1      jmmv static void	tmpfs_done(void);
     77   1.1      jmmv static int	tmpfs_snapshot(struct mount *, struct vnode *,
     78   1.1      jmmv 		    struct timespec *);
     79   1.1      jmmv 
     80  1.48     rmind static void
     81  1.48     rmind tmpfs_init(void)
     82  1.48     rmind {
     83  1.48     rmind 
     84  1.48     rmind 	pool_init(&tmpfs_dirent_pool, sizeof(struct tmpfs_dirent), 0, 0, 0,
     85  1.48     rmind 	    "tmpfs_dirent", &pool_allocator_nointr, IPL_NONE);
     86  1.48     rmind 	pool_init(&tmpfs_node_pool, sizeof(struct tmpfs_node), 0, 0, 0,
     87  1.48     rmind 	    "tmpfs_node", &pool_allocator_nointr, IPL_NONE);
     88  1.48     rmind }
     89  1.48     rmind 
     90  1.48     rmind static void
     91  1.48     rmind tmpfs_done(void)
     92  1.48     rmind {
     93  1.48     rmind 
     94  1.48     rmind 	pool_destroy(&tmpfs_dirent_pool);
     95  1.48     rmind 	pool_destroy(&tmpfs_node_pool);
     96  1.48     rmind }
     97   1.1      jmmv 
     98   1.1      jmmv static int
     99  1.32     pooka tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
    100   1.1      jmmv {
    101   1.1      jmmv 	struct tmpfs_mount *tmp;
    102   1.1      jmmv 	struct tmpfs_node *root;
    103  1.23       dsl 	struct tmpfs_args *args = data;
    104  1.45     rmind 	uint64_t memlimit;
    105  1.45     rmind 	ino_t nodes;
    106  1.45     rmind 	int error;
    107  1.23       dsl 
    108  1.49     rmind 	/* Validate the version. */
    109  1.49     rmind 	if (*data_len < sizeof(*args) ||
    110  1.49     rmind 	    args->ta_version != TMPFS_ARGS_VERSION)
    111  1.23       dsl 		return EINVAL;
    112   1.1      jmmv 
    113   1.1      jmmv 	/* Handle retrieval of mount point arguments. */
    114   1.1      jmmv 	if (mp->mnt_flag & MNT_GETARGS) {
    115   1.1      jmmv 		if (mp->mnt_data == NULL)
    116   1.1      jmmv 			return EIO;
    117   1.1      jmmv 		tmp = VFS_TO_TMPFS(mp);
    118   1.1      jmmv 
    119  1.23       dsl 		args->ta_version = TMPFS_ARGS_VERSION;
    120  1.23       dsl 		args->ta_nodes_max = tmp->tm_nodes_max;
    121  1.45     rmind 		args->ta_size_max = tmp->tm_mem_limit;
    122  1.31        ad 
    123  1.30        ad 		root = tmp->tm_root;
    124  1.23       dsl 		args->ta_root_uid = root->tn_uid;
    125  1.23       dsl 		args->ta_root_gid = root->tn_gid;
    126  1.23       dsl 		args->ta_root_mode = root->tn_mode;
    127   1.1      jmmv 
    128  1.45     rmind 		*data_len = sizeof(*args);
    129  1.23       dsl 		return 0;
    130   1.1      jmmv 	}
    131   1.1      jmmv 
    132   1.1      jmmv 	if (mp->mnt_flag & MNT_UPDATE) {
    133  1.49     rmind 		/* TODO */
    134   1.1      jmmv 		return EOPNOTSUPP;
    135   1.1      jmmv 	}
    136   1.1      jmmv 
    137  1.49     rmind 	/* Prohibit mounts if there is not enough memory. */
    138  1.20   thorpej 	if (tmpfs_mem_info(true) < TMPFS_PAGES_RESERVED)
    139   1.1      jmmv 		return EINVAL;
    140   1.1      jmmv 
    141  1.45     rmind 	/* Get the memory usage limit for this file-system. */
    142  1.45     rmind 	if (args->ta_size_max < PAGE_SIZE) {
    143  1.45     rmind 		memlimit = UINT64_MAX;
    144  1.45     rmind 	} else {
    145  1.45     rmind 		memlimit = args->ta_size_max;
    146  1.45     rmind 	}
    147  1.45     rmind 	KASSERT(memlimit > 0);
    148  1.45     rmind 
    149  1.45     rmind 	if (args->ta_nodes_max <= 3) {
    150  1.45     rmind 		nodes = 3 + (memlimit / 1024);
    151  1.45     rmind 	} else {
    152  1.23       dsl 		nodes = args->ta_nodes_max;
    153  1.45     rmind 	}
    154  1.45     rmind 	nodes = MIN(nodes, INT_MAX);
    155   1.7      jmmv 	KASSERT(nodes >= 3);
    156   1.1      jmmv 
    157   1.1      jmmv 	/* Allocate the tmpfs mount structure and fill it. */
    158  1.49     rmind 	tmp = kmem_zalloc(sizeof(struct tmpfs_mount), KM_SLEEP);
    159  1.34        ad 	if (tmp == NULL)
    160  1.34        ad 		return ENOMEM;
    161   1.1      jmmv 
    162   1.1      jmmv 	tmp->tm_nodes_max = nodes;
    163  1.34        ad 	tmp->tm_nodes_cnt = 0;
    164  1.34        ad 	LIST_INIT(&tmp->tm_nodes);
    165  1.34        ad 
    166  1.34        ad 	mutex_init(&tmp->tm_lock, MUTEX_DEFAULT, IPL_NONE);
    167  1.45     rmind 	tmpfs_mntmem_init(tmp, memlimit);
    168   1.1      jmmv 
    169   1.1      jmmv 	/* Allocate the root node. */
    170  1.23       dsl 	error = tmpfs_alloc_node(tmp, VDIR, args->ta_root_uid,
    171  1.23       dsl 	    args->ta_root_gid, args->ta_root_mode & ALLPERMS, NULL, NULL,
    172  1.33     pooka 	    VNOVAL, &root);
    173   1.1      jmmv 	KASSERT(error == 0 && root != NULL);
    174  1.34        ad 	root->tn_links++;
    175   1.1      jmmv 	tmp->tm_root = root;
    176   1.1      jmmv 
    177   1.1      jmmv 	mp->mnt_data = tmp;
    178   1.1      jmmv 	mp->mnt_flag |= MNT_LOCAL;
    179   1.1      jmmv 	mp->mnt_stat.f_namemax = MAXNAMLEN;
    180  1.27     pooka 	mp->mnt_fs_bshift = PAGE_SHIFT;
    181  1.27     pooka 	mp->mnt_dev_bshift = DEV_BSHIFT;
    182  1.34        ad 	mp->mnt_iflag |= IMNT_MPSAFE;
    183   1.1      jmmv 	vfs_getnewfsid(mp);
    184   1.1      jmmv 
    185  1.48     rmind 	error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
    186  1.45     rmind 	    mp->mnt_op->vfs_name, mp, curlwp);
    187  1.48     rmind 	if (error) {
    188  1.48     rmind 		(void)tmpfs_unmount(mp, MNT_FORCE);
    189  1.48     rmind 	}
    190  1.48     rmind 	return error;
    191   1.1      jmmv }
    192   1.1      jmmv 
    193   1.1      jmmv static int
    194  1.32     pooka tmpfs_start(struct mount *mp, int flags)
    195   1.1      jmmv {
    196   1.1      jmmv 
    197   1.1      jmmv 	return 0;
    198   1.1      jmmv }
    199   1.1      jmmv 
    200   1.1      jmmv static int
    201  1.32     pooka tmpfs_unmount(struct mount *mp, int mntflags)
    202   1.1      jmmv {
    203   1.1      jmmv 	struct tmpfs_mount *tmp;
    204   1.1      jmmv 	struct tmpfs_node *node;
    205  1.48     rmind 	int error, flags = 0;
    206   1.1      jmmv 
    207   1.1      jmmv 	/* Handle forced unmounts. */
    208   1.1      jmmv 	if (mntflags & MNT_FORCE)
    209   1.1      jmmv 		flags |= FORCECLOSE;
    210   1.1      jmmv 
    211   1.1      jmmv 	/* Finalize all pending I/O. */
    212   1.1      jmmv 	error = vflush(mp, NULL, flags);
    213   1.1      jmmv 	if (error != 0)
    214   1.1      jmmv 		return error;
    215   1.1      jmmv 
    216   1.1      jmmv 	tmp = VFS_TO_TMPFS(mp);
    217   1.1      jmmv 
    218   1.1      jmmv 	/* Free all associated data.  The loop iterates over the linked list
    219   1.1      jmmv 	 * we have containing all used nodes.  For each of them that is
    220   1.1      jmmv 	 * a directory, we free all its directory entries.  Note that after
    221   1.1      jmmv 	 * freeing a node, it will automatically go to the available list,
    222   1.1      jmmv 	 * so we will later have to iterate over it to release its items. */
    223  1.34        ad 	node = LIST_FIRST(&tmp->tm_nodes);
    224  1.31        ad 	while (node != NULL) {
    225  1.31        ad 		struct tmpfs_node *next;
    226  1.31        ad 
    227   1.1      jmmv 		if (node->tn_type == VDIR) {
    228   1.1      jmmv 			struct tmpfs_dirent *de;
    229   1.1      jmmv 
    230  1.11      jmmv 			de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir);
    231   1.1      jmmv 			while (de != NULL) {
    232   1.1      jmmv 				struct tmpfs_dirent *nde;
    233   1.1      jmmv 
    234   1.1      jmmv 				nde = TAILQ_NEXT(de, td_entries);
    235  1.20   thorpej 				tmpfs_free_dirent(tmp, de, false);
    236   1.1      jmmv 				de = nde;
    237   1.1      jmmv 				node->tn_size -= sizeof(struct tmpfs_dirent);
    238   1.1      jmmv 			}
    239   1.1      jmmv 		}
    240   1.1      jmmv 
    241  1.31        ad 		next = LIST_NEXT(node, tn_entries);
    242   1.1      jmmv 		tmpfs_free_node(tmp, node);
    243  1.31        ad 		node = next;
    244  1.31        ad 	}
    245   1.1      jmmv 
    246   1.1      jmmv 	/* Throw away the tmpfs_mount structure. */
    247  1.45     rmind 	tmpfs_mntmem_destroy(tmp);
    248  1.34        ad 	mutex_destroy(&tmp->tm_lock);
    249  1.34        ad 	kmem_free(tmp, sizeof(*tmp));
    250   1.1      jmmv 	mp->mnt_data = NULL;
    251   1.1      jmmv 
    252   1.1      jmmv 	return 0;
    253   1.1      jmmv }
    254   1.1      jmmv 
    255   1.1      jmmv /* --------------------------------------------------------------------- */
    256   1.1      jmmv 
    257   1.1      jmmv static int
    258   1.1      jmmv tmpfs_root(struct mount *mp, struct vnode **vpp)
    259   1.1      jmmv {
    260   1.1      jmmv 
    261   1.1      jmmv 	return tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, vpp);
    262   1.1      jmmv }
    263   1.1      jmmv 
    264   1.1      jmmv /* --------------------------------------------------------------------- */
    265   1.1      jmmv 
    266   1.1      jmmv static int
    267  1.17  christos tmpfs_vget(struct mount *mp, ino_t ino,
    268  1.38      jmmv     struct vnode **vpp)
    269   1.1      jmmv {
    270   1.1      jmmv 
    271   1.1      jmmv 	printf("tmpfs_vget called; need for it unknown yet\n");
    272   1.1      jmmv 	return EOPNOTSUPP;
    273   1.1      jmmv }
    274   1.1      jmmv 
    275   1.1      jmmv /* --------------------------------------------------------------------- */
    276   1.1      jmmv 
    277   1.1      jmmv static int
    278   1.1      jmmv tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
    279   1.1      jmmv {
    280  1.19   thorpej 	bool found;
    281  1.13    martin 	struct tmpfs_fid tfh;
    282   1.1      jmmv 	struct tmpfs_mount *tmp;
    283   1.1      jmmv 	struct tmpfs_node *node;
    284   1.1      jmmv 
    285   1.1      jmmv 	tmp = VFS_TO_TMPFS(mp);
    286   1.1      jmmv 
    287  1.13    martin 	if (fhp->fid_len != sizeof(struct tmpfs_fid))
    288   1.1      jmmv 		return EINVAL;
    289   1.1      jmmv 
    290  1.13    martin 	memcpy(&tfh, fhp, sizeof(struct tmpfs_fid));
    291  1.13    martin 
    292  1.20   thorpej 	found = false;
    293  1.34        ad 	mutex_enter(&tmp->tm_lock);
    294  1.34        ad 	LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) {
    295  1.13    martin 		if (node->tn_id == tfh.tf_id &&
    296  1.13    martin 		    node->tn_gen == tfh.tf_gen) {
    297  1.20   thorpej 			found = true;
    298   1.1      jmmv 			break;
    299   1.1      jmmv 		}
    300   1.1      jmmv 	}
    301  1.34        ad 	mutex_exit(&tmp->tm_lock);
    302   1.1      jmmv 
    303  1.34        ad 	/* XXXAD nothing to prevent 'node' from being removed. */
    304  1.47   hannken 	return found ? tmpfs_alloc_vp(mp, node, vpp) : ESTALE;
    305   1.1      jmmv }
    306   1.1      jmmv 
    307   1.1      jmmv /* --------------------------------------------------------------------- */
    308   1.1      jmmv 
    309   1.1      jmmv static int
    310  1.13    martin tmpfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
    311   1.1      jmmv {
    312  1.13    martin 	struct tmpfs_fid tfh;
    313   1.1      jmmv 	struct tmpfs_node *node;
    314   1.1      jmmv 
    315  1.13    martin 	if (*fh_size < sizeof(struct tmpfs_fid)) {
    316  1.13    martin 		*fh_size = sizeof(struct tmpfs_fid);
    317  1.13    martin 		return E2BIG;
    318  1.13    martin 	}
    319  1.13    martin 	*fh_size = sizeof(struct tmpfs_fid);
    320   1.1      jmmv 	node = VP_TO_TMPFS_NODE(vp);
    321   1.1      jmmv 
    322  1.13    martin 	memset(&tfh, 0, sizeof(tfh));
    323  1.13    martin 	tfh.tf_len = sizeof(struct tmpfs_fid);
    324  1.13    martin 	tfh.tf_gen = node->tn_gen;
    325  1.13    martin 	tfh.tf_id = node->tn_id;
    326  1.13    martin 	memcpy(fhp, &tfh, sizeof(tfh));
    327   1.1      jmmv 
    328   1.1      jmmv 	return 0;
    329   1.1      jmmv }
    330   1.1      jmmv 
    331   1.1      jmmv /* --------------------------------------------------------------------- */
    332   1.1      jmmv 
    333   1.1      jmmv static int
    334  1.32     pooka tmpfs_statvfs(struct mount *mp, struct statvfs *sbp)
    335   1.1      jmmv {
    336  1.46     rmind 	struct tmpfs_mount *tmp;
    337  1.34        ad 	fsfilcnt_t freenodes;
    338  1.46     rmind 	size_t avail;
    339   1.1      jmmv 
    340   1.1      jmmv 	tmp = VFS_TO_TMPFS(mp);
    341   1.1      jmmv 
    342   1.1      jmmv 	sbp->f_iosize = sbp->f_frsize = sbp->f_bsize = PAGE_SIZE;
    343   1.1      jmmv 
    344  1.46     rmind 	mutex_enter(&tmp->tm_acc_lock);
    345  1.46     rmind 	avail =  tmpfs_pages_avail(tmp);
    346  1.45     rmind 	sbp->f_blocks = (tmpfs_bytes_max(tmp) >> PAGE_SHIFT);
    347  1.46     rmind 	sbp->f_bavail = sbp->f_bfree = avail;
    348   1.1      jmmv 	sbp->f_bresvd = 0;
    349   1.1      jmmv 
    350  1.34        ad 	freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_cnt,
    351  1.46     rmind 	    avail * PAGE_SIZE / sizeof(struct tmpfs_node));
    352  1.31        ad 
    353  1.34        ad 	sbp->f_files = tmp->tm_nodes_cnt + freenodes;
    354   1.1      jmmv 	sbp->f_favail = sbp->f_ffree = freenodes;
    355   1.1      jmmv 	sbp->f_fresvd = 0;
    356  1.46     rmind 	mutex_exit(&tmp->tm_acc_lock);
    357   1.1      jmmv 
    358   1.1      jmmv 	copy_statvfs_info(sbp, mp);
    359   1.1      jmmv 
    360   1.1      jmmv 	return 0;
    361   1.1      jmmv }
    362   1.1      jmmv 
    363   1.1      jmmv /* --------------------------------------------------------------------- */
    364   1.1      jmmv 
    365   1.1      jmmv /* ARGSUSED0 */
    366   1.1      jmmv static int
    367  1.17  christos tmpfs_sync(struct mount *mp, int waitfor,
    368  1.32     pooka     kauth_cred_t uc)
    369   1.1      jmmv {
    370   1.1      jmmv 
    371   1.1      jmmv 	return 0;
    372   1.1      jmmv }
    373   1.1      jmmv 
    374   1.1      jmmv static int
    375  1.17  christos tmpfs_snapshot(struct mount *mp, struct vnode *vp,
    376  1.17  christos     struct timespec *ctime)
    377   1.1      jmmv {
    378   1.1      jmmv 
    379   1.1      jmmv 	return EOPNOTSUPP;
    380   1.1      jmmv }
    381   1.1      jmmv 
    382   1.1      jmmv /* --------------------------------------------------------------------- */
    383   1.1      jmmv 
    384   1.1      jmmv /*
    385   1.1      jmmv  * tmpfs vfs operations.
    386   1.1      jmmv  */
    387   1.1      jmmv 
    388   1.1      jmmv extern const struct vnodeopv_desc tmpfs_fifoop_opv_desc;
    389   1.1      jmmv extern const struct vnodeopv_desc tmpfs_specop_opv_desc;
    390   1.1      jmmv extern const struct vnodeopv_desc tmpfs_vnodeop_opv_desc;
    391   1.1      jmmv 
    392   1.1      jmmv const struct vnodeopv_desc * const tmpfs_vnodeopv_descs[] = {
    393   1.1      jmmv 	&tmpfs_fifoop_opv_desc,
    394   1.1      jmmv 	&tmpfs_specop_opv_desc,
    395   1.1      jmmv 	&tmpfs_vnodeop_opv_desc,
    396   1.1      jmmv 	NULL,
    397   1.1      jmmv };
    398   1.1      jmmv 
    399   1.1      jmmv struct vfsops tmpfs_vfsops = {
    400   1.1      jmmv 	MOUNT_TMPFS,			/* vfs_name */
    401  1.23       dsl 	sizeof (struct tmpfs_args),
    402   1.1      jmmv 	tmpfs_mount,			/* vfs_mount */
    403   1.1      jmmv 	tmpfs_start,			/* vfs_start */
    404   1.1      jmmv 	tmpfs_unmount,			/* vfs_unmount */
    405   1.1      jmmv 	tmpfs_root,			/* vfs_root */
    406  1.32     pooka 	(void *)eopnotsupp,		/* vfs_quotactl */
    407   1.1      jmmv 	tmpfs_statvfs,			/* vfs_statvfs */
    408   1.1      jmmv 	tmpfs_sync,			/* vfs_sync */
    409   1.1      jmmv 	tmpfs_vget,			/* vfs_vget */
    410   1.1      jmmv 	tmpfs_fhtovp,			/* vfs_fhtovp */
    411   1.1      jmmv 	tmpfs_vptofh,			/* vfs_vptofh */
    412   1.1      jmmv 	tmpfs_init,			/* vfs_init */
    413   1.1      jmmv 	NULL,				/* vfs_reinit */
    414   1.1      jmmv 	tmpfs_done,			/* vfs_done */
    415   1.1      jmmv 	NULL,				/* vfs_mountroot */
    416   1.1      jmmv 	tmpfs_snapshot,			/* vfs_snapshot */
    417   1.1      jmmv 	vfs_stdextattrctl,		/* vfs_extattrctl */
    418  1.25     pooka 	(void *)eopnotsupp,		/* vfs_suspendctl */
    419  1.36  dholland 	genfs_renamelock_enter,
    420  1.36  dholland 	genfs_renamelock_exit,
    421  1.40        ad 	(void *)eopnotsupp,
    422   1.1      jmmv 	tmpfs_vnodeopv_descs,
    423  1.14  christos 	0,				/* vfs_refcount */
    424  1.14  christos 	{ NULL, NULL },
    425   1.1      jmmv };
    426  1.41    rumble 
    427  1.41    rumble static int
    428  1.41    rumble tmpfs_modcmd(modcmd_t cmd, void *arg)
    429  1.41    rumble {
    430  1.41    rumble 
    431  1.41    rumble 	switch (cmd) {
    432  1.41    rumble 	case MODULE_CMD_INIT:
    433  1.41    rumble 		return vfs_attach(&tmpfs_vfsops);
    434  1.41    rumble 	case MODULE_CMD_FINI:
    435  1.41    rumble 		return vfs_detach(&tmpfs_vfsops);
    436  1.41    rumble 	default:
    437  1.41    rumble 		return ENOTTY;
    438  1.41    rumble 	}
    439  1.41    rumble }
    440