2006-11-09 18:06:03 +03:00
|
|
|
/* $NetBSD: tmpfs_vfsops.c,v 1.16 2006/11/09 15:06:03 jmmv Exp $ */
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
/*
|
2006-02-16 17:57:50 +03:00
|
|
|
* Copyright (c) 2005, 2006 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.
|
|
|
|
* 3. All advertising materials mentioning features or use of this software
|
|
|
|
* must display the following acknowledgement:
|
|
|
|
* This product includes software developed by the NetBSD
|
|
|
|
* Foundation, Inc. and its contributors.
|
|
|
|
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
|
|
|
* contributors may be used to endorse or promote products derived
|
|
|
|
* from this software without specific prior written permission.
|
|
|
|
*
|
|
|
|
* 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>
|
2006-11-09 18:06:03 +03:00
|
|
|
__KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.16 2006/11/09 15:06:03 jmmv Exp $");
|
2005-09-10 23:20:48 +04:00
|
|
|
|
|
|
|
#include <sys/param.h>
|
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/malloc.h>
|
|
|
|
#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>
|
|
|
|
|
|
|
|
#include <fs/tmpfs/tmpfs.h>
|
|
|
|
|
|
|
|
MALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures");
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int tmpfs_mount(struct mount *, const char *, void *,
|
2005-12-11 15:16:03 +03:00
|
|
|
struct nameidata *, struct lwp *);
|
|
|
|
static int tmpfs_start(struct mount *, int, struct lwp *);
|
|
|
|
static int tmpfs_unmount(struct mount *, int, struct lwp *);
|
2005-09-10 23:20:48 +04:00
|
|
|
static int tmpfs_root(struct mount *, struct vnode **);
|
|
|
|
static int tmpfs_quotactl(struct mount *, int, uid_t, void *,
|
2005-12-11 15:16:03 +03:00
|
|
|
struct lwp *);
|
2005-09-10 23:20:48 +04:00
|
|
|
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 *);
|
2005-12-11 15:16:03 +03:00
|
|
|
static int tmpfs_statvfs(struct mount *, struct statvfs *, struct lwp *);
|
2006-05-15 01:31:52 +04:00
|
|
|
static int tmpfs_sync(struct mount *, int, kauth_cred_t, struct lwp *);
|
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
|
|
|
|
tmpfs_mount(struct mount *mp, const char *path, void *data,
|
2006-10-12 05:30:41 +04:00
|
|
|
struct nameidata *ndp __unused, struct lwp *l)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
int error;
|
|
|
|
ino_t nodes;
|
|
|
|
size_t pages;
|
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
struct tmpfs_node *root;
|
|
|
|
struct tmpfs_args args;
|
|
|
|
|
|
|
|
/* Handle retrieval of mount point arguments. */
|
|
|
|
if (mp->mnt_flag & MNT_GETARGS) {
|
|
|
|
if (mp->mnt_data == NULL)
|
|
|
|
return EIO;
|
|
|
|
tmp = VFS_TO_TMPFS(mp);
|
|
|
|
|
|
|
|
args.ta_version = TMPFS_ARGS_VERSION;
|
|
|
|
args.ta_nodes_max = tmp->tm_nodes_max;
|
|
|
|
args.ta_size_max = tmp->tm_pages_max * PAGE_SIZE;
|
|
|
|
|
|
|
|
root = tmp->tm_root;
|
|
|
|
args.ta_root_uid = root->tn_uid;
|
|
|
|
args.ta_root_gid = root->tn_gid;
|
|
|
|
args.ta_root_mode = root->tn_mode;
|
|
|
|
|
|
|
|
return copyout(&args, data, sizeof(args));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Verify that we have parameters, as they are required. */
|
|
|
|
if (data == NULL)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/* Get the mount parameters. */
|
|
|
|
error = copyin(data, &args, sizeof(args));
|
|
|
|
if (error != 0)
|
|
|
|
return error;
|
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (args.ta_version != TMPFS_ARGS_VERSION)
|
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
/* Do not allow mounts if we do not have enough memory to preserve
|
|
|
|
* the minimum reserved pages. */
|
|
|
|
if (tmpfs_mem_info(TRUE) < TMPFS_PAGES_RESERVED)
|
|
|
|
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. */
|
2005-09-26 13:50:08 +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
|
|
|
|
pages = args.ta_size_max / PAGE_SIZE +
|
|
|
|
(args.ta_size_max % PAGE_SIZE == 0 ? 0 : 1);
|
2005-09-25 20:28:43 +04:00
|
|
|
KASSERT(pages > 0);
|
2005-09-10 23:20:48 +04:00
|
|
|
|
2005-09-25 20:28:43 +04:00
|
|
|
if (args.ta_nodes_max <= 3)
|
|
|
|
nodes = 3 + pages * PAGE_SIZE / 1024;
|
2005-09-10 23:20:48 +04:00
|
|
|
else
|
|
|
|
nodes = args.ta_nodes_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. */
|
|
|
|
tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount),
|
|
|
|
M_TMPFSMNT, M_WAITOK);
|
|
|
|
KASSERT(tmp != NULL);
|
|
|
|
|
|
|
|
tmp->tm_nodes_max = nodes;
|
2005-09-23 17:59:16 +04:00
|
|
|
tmp->tm_nodes_last = 2;
|
2005-09-10 23:20:48 +04:00
|
|
|
LIST_INIT(&tmp->tm_nodes_used);
|
|
|
|
LIST_INIT(&tmp->tm_nodes_avail);
|
|
|
|
|
|
|
|
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. */
|
|
|
|
error = tmpfs_alloc_node(tmp, VDIR, args.ta_root_uid,
|
2005-09-25 20:34:42 +04:00
|
|
|
args.ta_root_gid, args.ta_root_mode & ALLPERMS, NULL, NULL,
|
2005-12-11 15:16:03 +03:00
|
|
|
VNOVAL, l->l_proc, &root);
|
2005-09-10 23:20:48 +04:00
|
|
|
KASSERT(error == 0 && root != NULL);
|
|
|
|
tmp->tm_root = root;
|
|
|
|
|
|
|
|
mp->mnt_data = tmp;
|
|
|
|
mp->mnt_flag |= MNT_LOCAL;
|
|
|
|
mp->mnt_stat.f_namemax = MAXNAMLEN;
|
|
|
|
vfs_getnewfsid(mp);
|
|
|
|
|
|
|
|
return set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
|
2005-12-11 15:16:03 +03:00
|
|
|
mp, l);
|
2005-09-10 23:20:48 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_start(struct mount *mp __unused, int flags __unused,
|
|
|
|
struct lwp *l __unused)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ARGSUSED2 */
|
|
|
|
static int
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_unmount(struct mount *mp, int mntflags, struct lwp *l __unused)
|
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. */
|
|
|
|
node = LIST_FIRST(&tmp->tm_nodes_used);
|
|
|
|
while (node != NULL) {
|
|
|
|
struct tmpfs_node *next;
|
|
|
|
|
|
|
|
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);
|
2006-11-09 18:06:03 +03:00
|
|
|
KASSERT(de->td_node->tn_vnode == NULL);
|
2005-09-10 23:20:48 +04:00
|
|
|
tmpfs_free_dirent(tmp, de, FALSE);
|
|
|
|
de = nde;
|
|
|
|
node->tn_size -= sizeof(struct tmpfs_dirent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
next = LIST_NEXT(node, tn_entries);
|
|
|
|
tmpfs_free_node(tmp, node);
|
|
|
|
node = next;
|
|
|
|
}
|
|
|
|
node = LIST_FIRST(&tmp->tm_nodes_avail);
|
|
|
|
while (node != NULL) {
|
|
|
|
struct tmpfs_node *next;
|
|
|
|
|
|
|
|
next = LIST_NEXT(node, tn_entries);
|
|
|
|
LIST_REMOVE(node, tn_entries);
|
|
|
|
TMPFS_POOL_PUT(&tmp->tm_node_pool, node);
|
|
|
|
node = next;
|
|
|
|
}
|
|
|
|
|
|
|
|
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. */
|
|
|
|
free(mp->mnt_data, M_TMPFSMNT);
|
|
|
|
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-10-12 05:30:41 +04:00
|
|
|
tmpfs_quotactl(struct mount *mp __unused, int cmd __unused, uid_t uid __unused,
|
|
|
|
void *arg __unused, struct lwp *l __unused)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
printf("tmpfs_quotactl called; need for it unknown yet\n");
|
|
|
|
return EOPNOTSUPP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_vget(struct mount *mp __unused, ino_t ino __unused,
|
|
|
|
struct vnode **vpp __unused)
|
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)
|
|
|
|
{
|
|
|
|
boolean_t 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));
|
|
|
|
|
|
|
|
if (tfh.tf_id >= tmp->tm_nodes_max)
|
2005-09-10 23:20:48 +04:00
|
|
|
return EINVAL;
|
|
|
|
|
|
|
|
found = FALSE;
|
|
|
|
LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) {
|
2006-07-13 16:00:24 +04:00
|
|
|
if (node->tn_id == tfh.tf_id &&
|
|
|
|
node->tn_gen == tfh.tf_gen) {
|
2005-09-10 23:20:48 +04:00
|
|
|
found = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_statvfs(struct mount *mp, struct statvfs *sbp, struct lwp *l __unused)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
fsfilcnt_t freenodes, usednodes;
|
|
|
|
struct tmpfs_mount *tmp;
|
|
|
|
struct tmpfs_node *dummy;
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_last,
|
|
|
|
TMPFS_PAGES_AVAIL(tmp) * PAGE_SIZE / sizeof(struct tmpfs_node));
|
|
|
|
LIST_FOREACH(dummy, &tmp->tm_nodes_avail, tn_entries)
|
|
|
|
freenodes++;
|
|
|
|
|
|
|
|
usednodes = 0;
|
|
|
|
LIST_FOREACH(dummy, &tmp->tm_nodes_used, tn_entries)
|
|
|
|
usednodes++;
|
|
|
|
|
|
|
|
sbp->f_files = freenodes + usednodes;
|
|
|
|
sbp->f_favail = sbp->f_ffree = freenodes;
|
|
|
|
sbp->f_fresvd = 0;
|
|
|
|
|
|
|
|
copy_statvfs_info(sbp, mp);
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
/* ARGSUSED0 */
|
|
|
|
static int
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_sync(struct mount *mp __unused, int waitfor __unused,
|
|
|
|
kauth_cred_t uc __unused, struct lwp *l __unused)
|
2005-09-10 23:20:48 +04:00
|
|
|
{
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tmpfs_init(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef _LKM
|
|
|
|
malloc_type_attach(M_TMPFSMNT);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static void
|
|
|
|
tmpfs_done(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef _LKM
|
|
|
|
malloc_type_detach(M_TMPFSMNT);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
|
|
|
|
static int
|
2006-10-12 05:30:41 +04:00
|
|
|
tmpfs_snapshot(struct mount *mp __unused, struct vnode *vp __unused,
|
|
|
|
struct timespec *ctime __unused)
|
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 */
|
|
|
|
tmpfs_mount, /* vfs_mount */
|
|
|
|
tmpfs_start, /* vfs_start */
|
|
|
|
tmpfs_unmount, /* vfs_unmount */
|
|
|
|
tmpfs_root, /* vfs_root */
|
|
|
|
tmpfs_quotactl, /* vfs_quotactl */
|
|
|
|
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 */
|
|
|
|
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);
|