2008-04-29 22:18:08 +04:00
|
|
|
/* $NetBSD: tmpfs_vfsops.c,v 1.40 2008/04/29 18:18:08 ad Exp $ */
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
/*
|
2008-01-02 14:48:20 +03:00
|
|
|
* Copyright (c) 2005, 2006, 2007 The NetBSD Foundation, Inc.
|
2005-09-10 23:20:48 +04:00
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* This code is derived from software contributed to The NetBSD Foundation
|
2005-09-23 19:36:15 +04:00
|
|
|
* by Julio M. Merino Vidal, developed as part of Google's Summer of Code
|
|
|
|
* 2005 program.
|
2005-09-10 23:20:48 +04:00
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
|
|
|
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
|
|
|
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
|
|
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
|
|
|
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
|
|
|
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
|
|
|
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
|
|
|
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
|
|
|
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
|
|
* POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/*
|
2005-09-11 02:28:57 +04:00
|
|
|
* Efficient memory file system.
|
2005-09-23 19:36:15 +04:00
|
|
|
*
|
|
|
|
* tmpfs is a file system that uses NetBSD's virtual memory sub-system
|
|
|
|
* (the well-known UVM) to store file data and metadata in an efficient
|
|
|
|
* way. This means that it does not follow the structure of an on-disk
|
|
|
|
* file system because it simply does not need to. Instead, it uses
|
|
|
|
* memory-specific data structures and algorithms to automatically
|
|
|
|
* allocate and release resources.
|
2005-09-10 23:20:48 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include <sys/cdefs.h>
|
2008-04-29 22:18:08 +04:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.40 2008/04/29 18:18:08 ad Exp $");
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
2008-01-02 14:48:20 +03:00
|
|
|
#include <sys/kmem.h>
|
2005-09-10 23:20:48 +04:00
|
|
|
#include <sys/mount.h>
|
2005-09-25 20:34:42 +04:00
|
|
|
#include <sys/stat.h>
|
2005-09-10 23:20:48 +04:00
|
|
|
#include <sys/systm.h>
|
|
|
|
#include <sys/vnode.h>
|
2007-07-10 00:51:58 +04:00
|
|
|
#include <sys/proc.h>
|
2005-09-10 23:20:48 +04:00
|
|
|
|
2008-01-28 17:31:15 +03:00
|
|
|
#include <miscfs/genfs/genfs.h>
|
2005-09-10 23:20:48 +04:00
|
|
|
#include <fs/tmpfs/tmpfs.h>
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
2007-11-26 22:01:26 +03:00
|
|
|
static int tmpfs_mount(struct mount *, const char *, void *, size_t *);
|
|
|
|
static int tmpfs_start(struct mount *, int);
|
|
|
|
static int tmpfs_unmount(struct mount *, int);
|
2005-09-10 23:20:48 +04:00
|
|
|
static int tmpfs_root(struct mount *, struct vnode **);
|
|
|
|
static int tmpfs_vget(struct mount *, ino_t, struct vnode **);
|
|
|
|
static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **);
|
2006-07-13 16:00:24 +04:00
|
|
|
static int tmpfs_vptofh(struct vnode *, struct fid *, size_t *);
|
2007-11-26 22:01:26 +03:00
|
|
|
static int tmpfs_statvfs(struct mount *, struct statvfs *);
|
|
|
|
static int tmpfs_sync(struct mount *, int, kauth_cred_t);
|
2005-09-10 23:20:48 +04:00
|
|
|
static void tmpfs_init(void);
|
|
|
|
static void tmpfs_done(void);
|
|
|
|
static int tmpfs_snapshot(struct mount *, struct vnode *,
|
|
|
|
struct timespec *);
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2007-11-26 22:01:26 +03:00
|
|
|
tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
2007-11-26 22:01:26 +03:00
|
|
|
struct lwp *l = curlwp;
|
2005-09-10 23:20:48 +04:00
|
|
|
int error;
|
|
|
|
ino_t nodes;
|
|
|
|
size_t pages;
|
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
struct tmpfs_node *root;
|
2007-07-12 23:35:32 +04:00
|
|
|
struct tmpfs_args *args = data;
|
|
|
|
|
|
|
|
if (*data_len < sizeof *args)
|
|
|
|
return EINVAL;
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
/* Handle retrieval of mount point arguments. */
|
|
|
|
if (mp->mnt_flag & MNT_GETARGS) {
|
|
|
|
if (mp->mnt_data == NULL)
|
|
|
|
return EIO;
|
|
|
|
tmp = VFS_TO_TMPFS(mp);
|
|
|
|
|
2007-07-12 23:35:32 +04:00
|
|
|
args->ta_version = TMPFS_ARGS_VERSION;
|
|
|
|
args->ta_nodes_max = tmp->tm_nodes_max;
|
|
|
|
args->ta_size_max = tmp->tm_pages_max * PAGE_SIZE;
|
2007-11-06 22:50:55 +03:00
|
|
|
|
2007-11-10 06:36:16 +03:00
|
|
|
root = tmp->tm_root;
|
2007-07-12 23:35:32 +04:00
|
|
|
args->ta_root_uid = root->tn_uid;
|
|
|
|
args->ta_root_gid = root->tn_gid;
|
|
|
|
args->ta_root_mode = root->tn_mode;
|
2005-09-10 23:20:48 +04:00
|
|
|
|
2007-07-12 23:35:32 +04:00
|
|
|
*data_len = sizeof *args;
|
|
|
|
return 0;
|
2005-09-10 23:20:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (mp->mnt_flag & MNT_UPDATE) {
|
2005-09-11 02:28:57 +04:00
|
|
|
/* XXX: There is no support yet to update file system
|
2005-09-10 23:20:48 +04:00
|
|
|
* settings. Should be added. */
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
2007-07-12 23:35:32 +04:00
|
|
|
if (args->ta_version != TMPFS_ARGS_VERSION)
|
2005-09-10 23:20:48 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/* Do not allow mounts if we do not have enough memory to preserve
|
|
|
|
* the minimum reserved pages. */
|
2007-02-22 09:34:42 +03:00
|
|
|
if (tmpfs_mem_info(true) < TMPFS_PAGES_RESERVED)
|
2005-09-10 23:20:48 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
2005-09-11 02:28:57 +04:00
|
|
|
/* Get the maximum number of memory pages this file system is
|
2005-09-10 23:20:48 +04:00
|
|
|
* allowed to use, based on the maximum size the user passed in
|
|
|
|
* the mount structure. A value of zero is treated as if the
|
|
|
|
* maximum available space was requested. */
|
2007-07-12 23:35:32 +04:00
|
|
|
if (args->ta_size_max < PAGE_SIZE || args->ta_size_max >= SIZE_MAX)
|
2005-09-10 23:20:48 +04:00
|
|
|
pages = SIZE_MAX;
|
|
|
|
else
|
2007-07-12 23:35:32 +04:00
|
|
|
pages = args->ta_size_max / PAGE_SIZE +
|
|
|
|
(args->ta_size_max % PAGE_SIZE == 0 ? 0 : 1);
|
2008-02-05 18:02:45 +03:00
|
|
|
if (pages > INT_MAX)
|
|
|
|
pages = INT_MAX;
|
2005-09-25 20:28:43 +04:00
|
|
|
KASSERT(pages > 0);
|
2005-09-10 23:20:48 +04:00
|
|
|
|
2007-07-12 23:35:32 +04:00
|
|
|
if (args->ta_nodes_max <= 3)
|
2005-09-25 20:28:43 +04:00
|
|
|
nodes = 3 + pages * PAGE_SIZE / 1024;
|
2005-09-10 23:20:48 +04:00
|
|
|
else
|
2007-07-12 23:35:32 +04:00
|
|
|
nodes = args->ta_nodes_max;
|
2008-02-05 18:02:45 +03:00
|
|
|
if (nodes > INT_MAX)
|
|
|
|
nodes = INT_MAX;
|
2005-09-25 20:28:43 +04:00
|
|
|
KASSERT(nodes >= 3);
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
/* Allocate the tmpfs mount structure and fill it. */
|
2008-01-02 14:48:20 +03:00
|
|
|
tmp = kmem_alloc(sizeof(struct tmpfs_mount), KM_SLEEP);
|
|
|
|
if (tmp == NULL)
|
|
|
|
return ENOMEM;
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
tmp->tm_nodes_max = nodes;
|
2008-01-02 14:48:20 +03:00
|
|
|
tmp->tm_nodes_cnt = 0;
|
|
|
|
LIST_INIT(&tmp->tm_nodes);
|
|
|
|
|
|
|
|
mutex_init(&tmp->tm_lock, MUTEX_DEFAULT, IPL_NONE);
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
tmp->tm_pages_max = pages;
|
|
|
|
tmp->tm_pages_used = 0;
|
|
|
|
tmpfs_pool_init(&tmp->tm_dirent_pool, sizeof(struct tmpfs_dirent),
|
|
|
|
"dirent", tmp);
|
|
|
|
tmpfs_pool_init(&tmp->tm_node_pool, sizeof(struct tmpfs_node),
|
|
|
|
"node", tmp);
|
|
|
|
tmpfs_str_pool_init(&tmp->tm_str_pool, tmp);
|
|
|
|
|
|
|
|
/* Allocate the root node. */
|
2007-07-12 23:35:32 +04:00
|
|
|
error = tmpfs_alloc_node(tmp, VDIR, args->ta_root_uid,
|
|
|
|
args->ta_root_gid, args->ta_root_mode & ALLPERMS, NULL, NULL,
|
2007-12-08 22:29:36 +03:00
|
|
|
VNOVAL, &root);
|
2005-09-10 23:20:48 +04:00
|
|
|
KASSERT(error == 0 && root != NULL);
|
2008-01-02 14:48:20 +03:00
|
|
|
root->tn_links++;
|
2005-09-10 23:20:48 +04:00
|
|
|
tmp->tm_root = root;
|
|
|
|
|
|
|
|
mp->mnt_data = tmp;
|
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
|
|
|
mp->mnt_stat.f_namemax = MAXNAMLEN;
|
2007-08-03 17:00:19 +04:00
|
|
|
mp->mnt_fs_bshift = PAGE_SHIFT;
|
|
|
|
mp->mnt_dev_bshift = DEV_BSHIFT;
|
2008-01-02 14:48:20 +03:00
|
|
|
mp->mnt_iflag |= IMNT_MPSAFE;
|
2005-09-10 23:20:48 +04:00
|
|
|
vfs_getnewfsid(mp);
|
|
|
|
|
|
|
|
return set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
|
2007-07-17 15:19:31 +04:00
|
|
|
mp->mnt_op->vfs_name, mp, l);
|
2005-09-10 23:20:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2007-11-26 22:01:26 +03:00
|
|
|
tmpfs_start(struct mount *mp, int flags)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ARGSUSED2 */
|
|
|
|
static int
|
2007-11-26 22:01:26 +03:00
|
|
|
tmpfs_unmount(struct mount *mp, int mntflags)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
int flags = 0;
|
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
struct tmpfs_node *node;
|
|
|
|
|
|
|
|
/* Handle forced unmounts. */
|
|
|
|
if (mntflags & MNT_FORCE)
|
|
|
|
flags |= FORCECLOSE;
|
|
|
|
|
|
|
|
/* Finalize all pending I/O. */
|
|
|
|
error = vflush(mp, NULL, flags);
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
tmp = VFS_TO_TMPFS(mp);
|
|
|
|
|
|
|
|
/* Free all associated data. The loop iterates over the linked list
|
|
|
|
* we have containing all used nodes. For each of them that is
|
|
|
|
* a directory, we free all its directory entries. Note that after
|
|
|
|
* freeing a node, it will automatically go to the available list,
|
|
|
|
* so we will later have to iterate over it to release its items. */
|
2008-01-02 14:48:20 +03:00
|
|
|
node = LIST_FIRST(&tmp->tm_nodes);
|
2007-11-10 06:36:16 +03:00
|
|
|
while (node != NULL) {
|
|
|
|
struct tmpfs_node *next;
|
|
|
|
|
2005-09-10 23:20:48 +04:00
|
|
|
if (node->tn_type == VDIR) {
|
|
|
|
struct tmpfs_dirent *de;
|
|
|
|
|
2006-02-16 17:57:50 +03:00
|
|
|
de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir);
|
2005-09-10 23:20:48 +04:00
|
|
|
while (de != NULL) {
|
|
|
|
struct tmpfs_dirent *nde;
|
|
|
|
|
|
|
|
nde = TAILQ_NEXT(de, td_entries);
|
2007-02-22 09:34:42 +03:00
|
|
|
tmpfs_free_dirent(tmp, de, false);
|
2005-09-10 23:20:48 +04:00
|
|
|
de = nde;
|
|
|
|
node->tn_size -= sizeof(struct tmpfs_dirent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-10 06:36:16 +03:00
|
|
|
next = LIST_NEXT(node, tn_entries);
|
2005-09-10 23:20:48 +04:00
|
|
|
tmpfs_free_node(tmp, node);
|
2007-11-10 06:36:16 +03:00
|
|
|
node = next;
|
|
|
|
}
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
tmpfs_pool_destroy(&tmp->tm_dirent_pool);
|
|
|
|
tmpfs_pool_destroy(&tmp->tm_node_pool);
|
|
|
|
tmpfs_str_pool_destroy(&tmp->tm_str_pool);
|
|
|
|
|
|
|
|
KASSERT(tmp->tm_pages_used == 0);
|
|
|
|
|
|
|
|
/* Throw away the tmpfs_mount structure. */
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_destroy(&tmp->tm_lock);
|
|
|
|
kmem_free(tmp, sizeof(*tmp));
|
2005-09-10 23:20:48 +04:00
|
|
|
mp->mnt_data = NULL;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tmpfs_root(struct mount *mp, struct vnode **vpp)
|
|
|
|
{
|
|
|
|
|
|
|
|
return tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, vpp);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
tmpfs_vget(struct mount *mp, ino_t ino,
|
2008-02-06 14:22:12 +03:00
|
|
|
struct vnode **vpp)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
printf("tmpfs_vget called; need for it unknown yet\n");
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
|
|
|
tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
|
|
|
|
{
|
2007-02-22 01:59:35 +03:00
|
|
|
bool found;
|
2006-07-13 16:00:24 +04:00
|
|
|
struct tmpfs_fid tfh;
|
2005-09-10 23:20:48 +04:00
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
struct tmpfs_node *node;
|
|
|
|
|
|
|
|
tmp = VFS_TO_TMPFS(mp);
|
|
|
|
|
2006-07-13 16:00:24 +04:00
|
|
|
if (fhp->fid_len != sizeof(struct tmpfs_fid))
|
2005-09-10 23:20:48 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
2006-07-13 16:00:24 +04:00
|
|
|
memcpy(&tfh, fhp, sizeof(struct tmpfs_fid));
|
|
|
|
|
2007-11-10 06:36:16 +03:00
|
|
|
if (tfh.tf_id >= tmp->tm_nodes_max)
|
2005-09-10 23:20:48 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
2007-02-22 09:34:42 +03:00
|
|
|
found = false;
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_enter(&tmp->tm_lock);
|
|
|
|
LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) {
|
2006-07-13 16:00:24 +04:00
|
|
|
if (node->tn_id == tfh.tf_id &&
|
|
|
|
node->tn_gen == tfh.tf_gen) {
|
2007-02-22 09:34:42 +03:00
|
|
|
found = true;
|
2005-09-10 23:20:48 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2008-01-02 14:48:20 +03:00
|
|
|
mutex_exit(&tmp->tm_lock);
|
2005-09-10 23:20:48 +04:00
|
|
|
|
2008-01-02 14:48:20 +03:00
|
|
|
/* XXXAD nothing to prevent 'node' from being removed. */
|
2005-09-10 23:20:48 +04:00
|
|
|
return found ? tmpfs_alloc_vp(mp, node, vpp) : EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-07-13 16:00:24 +04:00
|
|
|
tmpfs_vptofh(struct vnode *vp, struct fid *fhp, size_t *fh_size)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
2006-07-13 16:00:24 +04:00
|
|
|
struct tmpfs_fid tfh;
|
2005-09-10 23:20:48 +04:00
|
|
|
struct tmpfs_node *node;
|
|
|
|
|
2006-07-13 16:00:24 +04:00
|
|
|
if (*fh_size < sizeof(struct tmpfs_fid)) {
|
|
|
|
*fh_size = sizeof(struct tmpfs_fid);
|
|
|
|
return E2BIG;
|
|
|
|
}
|
|
|
|
*fh_size = sizeof(struct tmpfs_fid);
|
2005-09-10 23:20:48 +04:00
|
|
|
node = VP_TO_TMPFS_NODE(vp);
|
|
|
|
|
2006-07-13 16:00:24 +04:00
|
|
|
memset(&tfh, 0, sizeof(tfh));
|
|
|
|
tfh.tf_len = sizeof(struct tmpfs_fid);
|
|
|
|
tfh.tf_gen = node->tn_gen;
|
|
|
|
tfh.tf_id = node->tn_id;
|
|
|
|
memcpy(fhp, &tfh, sizeof(tfh));
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ARGSUSED2 */
|
|
|
|
static int
|
2007-11-26 22:01:26 +03:00
|
|
|
tmpfs_statvfs(struct mount *mp, struct statvfs *sbp)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
2008-01-02 14:48:20 +03:00
|
|
|
fsfilcnt_t freenodes;
|
2005-09-10 23:20:48 +04:00
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
|
|
|
|
tmp = VFS_TO_TMPFS(mp);
|
|
|
|
|
|
|
|
sbp->f_iosize = sbp->f_frsize = sbp->f_bsize = PAGE_SIZE;
|
|
|
|
|
|
|
|
sbp->f_blocks = TMPFS_PAGES_MAX(tmp);
|
|
|
|
sbp->f_bavail = sbp->f_bfree = TMPFS_PAGES_AVAIL(tmp);
|
|
|
|
sbp->f_bresvd = 0;
|
|
|
|
|
2008-01-02 14:48:20 +03:00
|
|
|
freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_cnt,
|
2005-09-10 23:20:48 +04:00
|
|
|
TMPFS_PAGES_AVAIL(tmp) * PAGE_SIZE / sizeof(struct tmpfs_node));
|
2007-11-10 06:36:16 +03:00
|
|
|
|
2008-01-02 14:48:20 +03:00
|
|
|
sbp->f_files = tmp->tm_nodes_cnt + freenodes;
|
2005-09-10 23:20:48 +04:00
|
|
|
sbp->f_favail = sbp->f_ffree = freenodes;
|
|
|
|
sbp->f_fresvd = 0;
|
|
|
|
|
|
|
|
copy_statvfs_info(sbp, mp);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ARGSUSED0 */
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
tmpfs_sync(struct mount *mp, int waitfor,
|
2007-11-26 22:01:26 +03:00
|
|
|
kauth_cred_t uc)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tmpfs_init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tmpfs_done(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-11-16 04:32:37 +03:00
|
|
|
tmpfs_snapshot(struct mount *mp, struct vnode *vp,
|
|
|
|
struct timespec *ctime)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
* tmpfs vfs operations.
|
|
|
|
*/
|
|
|
|
|
|
|
|
extern const struct vnodeopv_desc tmpfs_fifoop_opv_desc;
|
|
|
|
extern const struct vnodeopv_desc tmpfs_specop_opv_desc;
|
|
|
|
extern const struct vnodeopv_desc tmpfs_vnodeop_opv_desc;
|
|
|
|
|
|
|
|
const struct vnodeopv_desc * const tmpfs_vnodeopv_descs[] = {
|
|
|
|
&tmpfs_fifoop_opv_desc,
|
|
|
|
&tmpfs_specop_opv_desc,
|
|
|
|
&tmpfs_vnodeop_opv_desc,
|
|
|
|
NULL,
|
|
|
|
};
|
|
|
|
|
|
|
|
struct vfsops tmpfs_vfsops = {
|
|
|
|
MOUNT_TMPFS, /* vfs_name */
|
2007-07-12 23:35:32 +04:00
|
|
|
sizeof (struct tmpfs_args),
|
2005-09-10 23:20:48 +04:00
|
|
|
tmpfs_mount, /* vfs_mount */
|
|
|
|
tmpfs_start, /* vfs_start */
|
|
|
|
tmpfs_unmount, /* vfs_unmount */
|
|
|
|
tmpfs_root, /* vfs_root */
|
2007-11-26 22:01:26 +03:00
|
|
|
(void *)eopnotsupp, /* vfs_quotactl */
|
2005-09-10 23:20:48 +04:00
|
|
|
tmpfs_statvfs, /* vfs_statvfs */
|
|
|
|
tmpfs_sync, /* vfs_sync */
|
|
|
|
tmpfs_vget, /* vfs_vget */
|
|
|
|
tmpfs_fhtovp, /* vfs_fhtovp */
|
|
|
|
tmpfs_vptofh, /* vfs_vptofh */
|
|
|
|
tmpfs_init, /* vfs_init */
|
|
|
|
NULL, /* vfs_reinit */
|
|
|
|
tmpfs_done, /* vfs_done */
|
|
|
|
NULL, /* vfs_mountroot */
|
|
|
|
tmpfs_snapshot, /* vfs_snapshot */
|
|
|
|
vfs_stdextattrctl, /* vfs_extattrctl */
|
2007-07-27 02:57:36 +04:00
|
|
|
(void *)eopnotsupp, /* vfs_suspendctl */
|
2008-01-28 17:31:15 +03:00
|
|
|
genfs_renamelock_enter,
|
|
|
|
genfs_renamelock_exit,
|
2008-04-29 22:18:08 +04:00
|
|
|
(void *)eopnotsupp,
|
2005-09-10 23:20:48 +04:00
|
|
|
tmpfs_vnodeopv_descs,
|
2006-09-03 10:51:04 +04:00
|
|
|
0, /* vfs_refcount */
|
|
|
|
{ NULL, NULL },
|
2005-09-10 23:20:48 +04:00
|
|
|
};
|
|
|
|
VFS_ATTACH(tmpfs_vfsops);
|