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