1170808Sdelphij/*	$NetBSD: tmpfs_vfsops.c,v 1.10 2005/12/11 12:24:29 christos Exp $	*/
2170808Sdelphij
3182739Sdelphij/*-
4170808Sdelphij * Copyright (c) 2005 The NetBSD Foundation, Inc.
5170808Sdelphij * All rights reserved.
6170808Sdelphij *
7170808Sdelphij * This code is derived from software contributed to The NetBSD Foundation
8170808Sdelphij * by Julio M. Merino Vidal, developed as part of Google's Summer of Code
9170808Sdelphij * 2005 program.
10170808Sdelphij *
11170808Sdelphij * Redistribution and use in source and binary forms, with or without
12170808Sdelphij * modification, are permitted provided that the following conditions
13170808Sdelphij * are met:
14170808Sdelphij * 1. Redistributions of source code must retain the above copyright
15170808Sdelphij *    notice, this list of conditions and the following disclaimer.
16170808Sdelphij * 2. Redistributions in binary form must reproduce the above copyright
17170808Sdelphij *    notice, this list of conditions and the following disclaimer in the
18170808Sdelphij *    documentation and/or other materials provided with the distribution.
19170808Sdelphij *
20170808Sdelphij * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
21170808Sdelphij * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22170808Sdelphij * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23170808Sdelphij * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
24170808Sdelphij * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25170808Sdelphij * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26170808Sdelphij * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27170808Sdelphij * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28170808Sdelphij * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29170808Sdelphij * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30170808Sdelphij * POSSIBILITY OF SUCH DAMAGE.
31170808Sdelphij */
32170808Sdelphij
33170808Sdelphij/*
34170808Sdelphij * Efficient memory file system.
35170808Sdelphij *
36170808Sdelphij * tmpfs is a file system that uses NetBSD's virtual memory sub-system
37170808Sdelphij * (the well-known UVM) to store file data and metadata in an efficient
38170808Sdelphij * way.  This means that it does not follow the structure of an on-disk
39170808Sdelphij * file system because it simply does not need to.  Instead, it uses
40170808Sdelphij * memory-specific data structures and algorithms to automatically
41170808Sdelphij * allocate and release resources.
42170808Sdelphij */
43170808Sdelphij#include <sys/cdefs.h>
44170808Sdelphij__FBSDID("$FreeBSD$");
45170808Sdelphij
46170808Sdelphij#include <sys/param.h>
47171308Sdelphij#include <sys/limits.h>
48170808Sdelphij#include <sys/lock.h>
49170808Sdelphij#include <sys/mutex.h>
50254741Sdelphij#include <sys/proc.h>
51254741Sdelphij#include <sys/jail.h>
52170808Sdelphij#include <sys/kernel.h>
53170808Sdelphij#include <sys/stat.h>
54170808Sdelphij#include <sys/systm.h>
55170808Sdelphij#include <sys/sysctl.h>
56170808Sdelphij
57170808Sdelphij#include <vm/vm.h>
58170808Sdelphij#include <vm/vm_object.h>
59170808Sdelphij#include <vm/vm_param.h>
60170808Sdelphij
61170808Sdelphij#include <fs/tmpfs/tmpfs.h>
62170808Sdelphij
63170808Sdelphij/*
64171070Sdelphij * Default permission for root node
65170808Sdelphij */
66170808Sdelphij#define TMPFS_DEFAULT_ROOT_MODE	(S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH)
67170808Sdelphij
68170808SdelphijMALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures");
69171087SdelphijMALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names");
70170808Sdelphij
71191990Sattiliostatic int	tmpfs_mount(struct mount *);
72191990Sattiliostatic int	tmpfs_unmount(struct mount *, int);
73191990Sattiliostatic int	tmpfs_root(struct mount *, int flags, struct vnode **);
74222167Srmacklemstatic int	tmpfs_fhtovp(struct mount *, struct fid *, int,
75222167Srmacklem		    struct vnode **);
76191990Sattiliostatic int	tmpfs_statfs(struct mount *, struct statfs *);
77170808Sdelphij
78170808Sdelphijstatic const char *tmpfs_opts[] = {
79203164Sjh	"from", "size", "maxfilesize", "inodes", "uid", "gid", "mode", "export",
80253573Snwhitehorn	"union", NULL
81170808Sdelphij};
82170808Sdelphij
83234346Sjhstatic const char *tmpfs_updateopts[] = {
84234346Sjh	"from", "export", NULL
85234346Sjh};
86234346Sjh
87171029Sdelphijstatic int
88171029Sdelphijtmpfs_node_ctor(void *mem, int size, void *arg, int flags)
89171029Sdelphij{
90171029Sdelphij	struct tmpfs_node *node = (struct tmpfs_node *)mem;
91171070Sdelphij
92171362Sdelphij	node->tn_gen++;
93171029Sdelphij	node->tn_size = 0;
94171029Sdelphij	node->tn_status = 0;
95171029Sdelphij	node->tn_flags = 0;
96171029Sdelphij	node->tn_links = 0;
97171029Sdelphij	node->tn_vnode = NULL;
98171029Sdelphij	node->tn_vpstate = 0;
99170808Sdelphij
100171029Sdelphij	return (0);
101171029Sdelphij}
102171029Sdelphij
103171029Sdelphijstatic void
104171029Sdelphijtmpfs_node_dtor(void *mem, int size, void *arg)
105171029Sdelphij{
106171029Sdelphij	struct tmpfs_node *node = (struct tmpfs_node *)mem;
107171029Sdelphij	node->tn_type = VNON;
108171029Sdelphij}
109171029Sdelphij
110171070Sdelphijstatic int
111171029Sdelphijtmpfs_node_init(void *mem, int size, int flags)
112171029Sdelphij{
113171029Sdelphij	struct tmpfs_node *node = (struct tmpfs_node *)mem;
114171029Sdelphij	node->tn_id = 0;
115171029Sdelphij
116171029Sdelphij	mtx_init(&node->tn_interlock, "tmpfs node interlock", NULL, MTX_DEF);
117171362Sdelphij	node->tn_gen = arc4random();
118171070Sdelphij
119171029Sdelphij	return (0);
120171029Sdelphij}
121171029Sdelphij
122171029Sdelphijstatic void
123171029Sdelphijtmpfs_node_fini(void *mem, int size)
124171029Sdelphij{
125171029Sdelphij	struct tmpfs_node *node = (struct tmpfs_node *)mem;
126171070Sdelphij
127171029Sdelphij	mtx_destroy(&node->tn_interlock);
128171029Sdelphij}
129171029Sdelphij
130170808Sdelphijstatic int
131191990Sattiliotmpfs_mount(struct mount *mp)
132170808Sdelphij{
133234000Sgleb	const size_t nodes_per_page = howmany(PAGE_SIZE,
134234000Sgleb	    sizeof(struct tmpfs_dirent) + sizeof(struct tmpfs_node));
135170808Sdelphij	struct tmpfs_mount *tmp;
136170808Sdelphij	struct tmpfs_node *root;
137254741Sdelphij	struct thread *td = curthread;
138170808Sdelphij	int error;
139171308Sdelphij	/* Size counters. */
140233999Sgleb	u_quad_t pages;
141233999Sgleb	off_t nodes_max, size_max, maxfilesize;
142170808Sdelphij
143171308Sdelphij	/* Root node attributes. */
144202187Sjh	uid_t root_uid;
145202187Sjh	gid_t root_gid;
146202187Sjh	mode_t root_mode;
147171308Sdelphij
148202187Sjh	struct vattr va;
149171308Sdelphij
150254741Sdelphij	if (!prison_allow(td->td_ucred, PR_ALLOW_MOUNT_TMPFS))
151254741Sdelphij		return (EPERM);
152254741Sdelphij
153170808Sdelphij	if (vfs_filteropt(mp->mnt_optnew, tmpfs_opts))
154170808Sdelphij		return (EINVAL);
155170808Sdelphij
156170808Sdelphij	if (mp->mnt_flag & MNT_UPDATE) {
157234346Sjh		/* Only support update mounts for certain options. */
158234346Sjh		if (vfs_filteropt(mp->mnt_optnew, tmpfs_updateopts) != 0)
159234346Sjh			return (EOPNOTSUPP);
160234346Sjh		if (vfs_flagopt(mp->mnt_optnew, "ro", NULL, 0) !=
161234346Sjh		    ((struct tmpfs_mount *)mp->mnt_data)->tm_ronly)
162234346Sjh			return (EOPNOTSUPP);
163234346Sjh		return (0);
164170808Sdelphij	}
165170808Sdelphij
166175202Sattilio	vn_lock(mp->mnt_vnodecovered, LK_SHARED | LK_RETRY);
167182371Sattilio	error = VOP_GETATTR(mp->mnt_vnodecovered, &va, mp->mnt_cred);
168175294Sattilio	VOP_UNLOCK(mp->mnt_vnodecovered, 0);
169171308Sdelphij	if (error)
170171308Sdelphij		return (error);
171170808Sdelphij
172171308Sdelphij	if (mp->mnt_cred->cr_ruid != 0 ||
173171308Sdelphij	    vfs_scanopt(mp->mnt_optnew, "gid", "%d", &root_gid) != 1)
174171308Sdelphij		root_gid = va.va_gid;
175171308Sdelphij	if (mp->mnt_cred->cr_ruid != 0 ||
176171308Sdelphij	    vfs_scanopt(mp->mnt_optnew, "uid", "%d", &root_uid) != 1)
177171308Sdelphij		root_uid = va.va_uid;
178171308Sdelphij	if (mp->mnt_cred->cr_ruid != 0 ||
179173570Sdelphij	    vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1)
180171308Sdelphij		root_mode = va.va_mode;
181233999Sgleb	if (vfs_getopt_size(mp->mnt_optnew, "inodes", &nodes_max) != 0)
182171308Sdelphij		nodes_max = 0;
183233999Sgleb	if (vfs_getopt_size(mp->mnt_optnew, "size", &size_max) != 0)
184171308Sdelphij		size_max = 0;
185233999Sgleb	if (vfs_getopt_size(mp->mnt_optnew, "maxfilesize", &maxfilesize) != 0)
186203164Sjh		maxfilesize = 0;
187170808Sdelphij
188170808Sdelphij	/* Do not allow mounts if we do not have enough memory to preserve
189170808Sdelphij	 * the minimum reserved pages. */
190233998Sgleb	if (tmpfs_mem_avail() < TMPFS_PAGES_MINRESERVED)
191170808Sdelphij		return ENOSPC;
192170808Sdelphij
193170808Sdelphij	/* Get the maximum number of memory pages this file system is
194170808Sdelphij	 * allowed to use, based on the maximum size the user passed in
195170808Sdelphij	 * the mount structure.  A value of zero is treated as if the
196170808Sdelphij	 * maximum available space was requested. */
197263943Sbdrewery	if (size_max == 0 || size_max > OFF_MAX - PAGE_SIZE ||
198233999Sgleb	    (SIZE_MAX < OFF_MAX && size_max / PAGE_SIZE >= SIZE_MAX))
199170808Sdelphij		pages = SIZE_MAX;
200263943Sbdrewery	else {
201263943Sbdrewery		size_max = roundup(size_max, PAGE_SIZE);
202171308Sdelphij		pages = howmany(size_max, PAGE_SIZE);
203263943Sbdrewery	}
204170808Sdelphij	MPASS(pages > 0);
205170808Sdelphij
206202708Sjh	if (nodes_max <= 3) {
207234000Sgleb		if (pages < INT_MAX / nodes_per_page)
208234000Sgleb			nodes_max = pages * nodes_per_page;
209202708Sjh		else
210234000Sgleb			nodes_max = INT_MAX;
211233999Sgleb	}
212234000Sgleb	if (nodes_max > INT_MAX)
213234000Sgleb		nodes_max = INT_MAX;
214233999Sgleb	MPASS(nodes_max >= 3);
215170808Sdelphij
216170808Sdelphij	/* Allocate the tmpfs mount structure and fill it. */
217170808Sdelphij	tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount),
218170808Sdelphij	    M_TMPFSMNT, M_WAITOK | M_ZERO);
219171070Sdelphij
220170808Sdelphij	mtx_init(&tmp->allnode_lock, "tmpfs allnode lock", NULL, MTX_DEF);
221233999Sgleb	tmp->tm_nodes_max = nodes_max;
222170808Sdelphij	tmp->tm_nodes_inuse = 0;
223233999Sgleb	tmp->tm_maxfilesize = maxfilesize > 0 ? maxfilesize : OFF_MAX;
224170808Sdelphij	LIST_INIT(&tmp->tm_nodes_used);
225171070Sdelphij
226170808Sdelphij	tmp->tm_pages_max = pages;
227170808Sdelphij	tmp->tm_pages_used = 0;
228171362Sdelphij	tmp->tm_ino_unr = new_unrhdr(2, INT_MAX, &tmp->allnode_lock);
229173724Sdelphij	tmp->tm_dirent_pool = uma_zcreate("TMPFS dirent",
230173724Sdelphij	    sizeof(struct tmpfs_dirent),
231173724Sdelphij	    NULL, NULL, NULL, NULL,
232173724Sdelphij	    UMA_ALIGN_PTR, 0);
233173724Sdelphij	tmp->tm_node_pool = uma_zcreate("TMPFS node",
234173724Sdelphij	    sizeof(struct tmpfs_node),
235173724Sdelphij	    tmpfs_node_ctor, tmpfs_node_dtor,
236173724Sdelphij	    tmpfs_node_init, tmpfs_node_fini,
237173724Sdelphij	    UMA_ALIGN_PTR, 0);
238234346Sjh	tmp->tm_ronly = (mp->mnt_flag & MNT_RDONLY) != 0;
239170808Sdelphij
240170808Sdelphij	/* Allocate the root node. */
241269175Skib	error = tmpfs_alloc_node(mp, tmp, VDIR, root_uid,
242171308Sdelphij	    root_gid, root_mode & ALLPERMS, NULL, NULL,
243191990Sattilio	    VNOVAL, &root);
244170808Sdelphij
245170808Sdelphij	if (error != 0 || root == NULL) {
246171029Sdelphij	    uma_zdestroy(tmp->tm_node_pool);
247171029Sdelphij	    uma_zdestroy(tmp->tm_dirent_pool);
248171362Sdelphij	    delete_unrhdr(tmp->tm_ino_unr);
249170808Sdelphij	    free(tmp, M_TMPFSMNT);
250170808Sdelphij	    return error;
251170808Sdelphij	}
252241011Smdf	KASSERT(root->tn_id == 2,
253241011Smdf	    ("tmpfs root with invalid ino: %ju", (uintmax_t)root->tn_id));
254170808Sdelphij	tmp->tm_root = root;
255170808Sdelphij
256170808Sdelphij	MNT_ILOCK(mp);
257170808Sdelphij	mp->mnt_flag |= MNT_LOCAL;
258170808Sdelphij	MNT_IUNLOCK(mp);
259171070Sdelphij
260170808Sdelphij	mp->mnt_data = tmp;
261170808Sdelphij	mp->mnt_stat.f_namemax = MAXNAMLEN;
262170808Sdelphij	vfs_getnewfsid(mp);
263170808Sdelphij	vfs_mountedfrom(mp, "tmpfs");
264170808Sdelphij
265170808Sdelphij	return 0;
266170808Sdelphij}
267170808Sdelphij
268170808Sdelphij/* ARGSUSED2 */
269170808Sdelphijstatic int
270191990Sattiliotmpfs_unmount(struct mount *mp, int mntflags)
271170808Sdelphij{
272170808Sdelphij	struct tmpfs_mount *tmp;
273170808Sdelphij	struct tmpfs_node *node;
274269175Skib	int error, flags;
275170808Sdelphij
276269175Skib	flags = (mntflags & MNT_FORCE) != 0 ? FORCECLOSE : 0;
277269175Skib	tmp = VFS_TO_TMPFS(mp);
278170808Sdelphij
279269175Skib	/* Stop writers */
280269175Skib	error = vfs_write_suspend_umnt(mp);
281170808Sdelphij	if (error != 0)
282269175Skib		return (error);
283269175Skib	/*
284269175Skib	 * At this point, nodes cannot be destroyed by any other
285269175Skib	 * thread because write suspension is started.
286269175Skib	 */
287170808Sdelphij
288269175Skib	for (;;) {
289269175Skib		error = vflush(mp, 0, flags, curthread);
290269175Skib		if (error != 0) {
291269175Skib			vfs_write_resume(mp, VR_START_WRITE);
292269175Skib			return (error);
293269175Skib		}
294269175Skib		MNT_ILOCK(mp);
295269175Skib		if (mp->mnt_nvnodelistsize == 0) {
296269175Skib			MNT_IUNLOCK(mp);
297269175Skib			break;
298269175Skib		}
299269175Skib		MNT_IUNLOCK(mp);
300269175Skib		if ((mntflags & MNT_FORCE) == 0) {
301269175Skib			vfs_write_resume(mp, VR_START_WRITE);
302269175Skib			return (EBUSY);
303269175Skib		}
304269175Skib	}
305171070Sdelphij
306269175Skib	TMPFS_LOCK(tmp);
307269175Skib	while ((node = LIST_FIRST(&tmp->tm_nodes_used)) != NULL) {
308269175Skib		TMPFS_UNLOCK(tmp);
309245115Sgleb		if (node->tn_type == VDIR)
310245115Sgleb			tmpfs_dir_destroy(tmp, node);
311170808Sdelphij		tmpfs_free_node(tmp, node);
312269175Skib		TMPFS_LOCK(tmp);
313170808Sdelphij	}
314269175Skib	TMPFS_UNLOCK(tmp);
315170808Sdelphij
316171029Sdelphij	uma_zdestroy(tmp->tm_dirent_pool);
317171029Sdelphij	uma_zdestroy(tmp->tm_node_pool);
318171362Sdelphij	delete_unrhdr(tmp->tm_ino_unr);
319170808Sdelphij
320170808Sdelphij	mtx_destroy(&tmp->allnode_lock);
321170808Sdelphij	MPASS(tmp->tm_pages_used == 0);
322171308Sdelphij	MPASS(tmp->tm_nodes_inuse == 0);
323170808Sdelphij
324170808Sdelphij	/* Throw away the tmpfs_mount structure. */
325170808Sdelphij	free(mp->mnt_data, M_TMPFSMNT);
326170808Sdelphij	mp->mnt_data = NULL;
327269175Skib	vfs_write_resume(mp, VR_START_WRITE);
328171070Sdelphij
329170808Sdelphij	MNT_ILOCK(mp);
330170808Sdelphij	mp->mnt_flag &= ~MNT_LOCAL;
331170808Sdelphij	MNT_IUNLOCK(mp);
332269175Skib
333269175Skib	return (0);
334170808Sdelphij}
335170808Sdelphij
336170808Sdelphijstatic int
337191990Sattiliotmpfs_root(struct mount *mp, int flags, struct vnode **vpp)
338170808Sdelphij{
339170808Sdelphij	int error;
340191990Sattilio	error = tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, flags, vpp);
341170808Sdelphij
342170808Sdelphij	if (!error)
343171029Sdelphij		(*vpp)->v_vflag |= VV_ROOT;
344170808Sdelphij
345170808Sdelphij	return error;
346170808Sdelphij}
347170808Sdelphij
348170808Sdelphijstatic int
349222167Srmacklemtmpfs_fhtovp(struct mount *mp, struct fid *fhp, int flags,
350222167Srmacklem    struct vnode **vpp)
351170808Sdelphij{
352170808Sdelphij	boolean_t found;
353170808Sdelphij	struct tmpfs_fid *tfhp;
354170808Sdelphij	struct tmpfs_mount *tmp;
355170808Sdelphij	struct tmpfs_node *node;
356170808Sdelphij
357170808Sdelphij	tmp = VFS_TO_TMPFS(mp);
358170808Sdelphij
359170808Sdelphij	tfhp = (struct tmpfs_fid *)fhp;
360170808Sdelphij	if (tfhp->tf_len != sizeof(struct tmpfs_fid))
361170808Sdelphij		return EINVAL;
362170808Sdelphij
363170808Sdelphij	if (tfhp->tf_id >= tmp->tm_nodes_max)
364170808Sdelphij		return EINVAL;
365170808Sdelphij
366170808Sdelphij	found = FALSE;
367170808Sdelphij
368170808Sdelphij	TMPFS_LOCK(tmp);
369170808Sdelphij	LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) {
370170808Sdelphij		if (node->tn_id == tfhp->tf_id &&
371170808Sdelphij		    node->tn_gen == tfhp->tf_gen) {
372170808Sdelphij			found = TRUE;
373170808Sdelphij			break;
374170808Sdelphij		}
375170808Sdelphij	}
376170808Sdelphij	TMPFS_UNLOCK(tmp);
377170808Sdelphij
378171799Sdelphij	if (found)
379191990Sattilio		return (tmpfs_alloc_vp(mp, node, LK_EXCLUSIVE, vpp));
380171799Sdelphij
381171799Sdelphij	return (EINVAL);
382170808Sdelphij}
383170808Sdelphij
384170808Sdelphij/* ARGSUSED2 */
385170808Sdelphijstatic int
386191990Sattiliotmpfs_statfs(struct mount *mp, struct statfs *sbp)
387170808Sdelphij{
388170808Sdelphij	struct tmpfs_mount *tmp;
389233998Sgleb	size_t used;
390170808Sdelphij
391170808Sdelphij	tmp = VFS_TO_TMPFS(mp);
392170808Sdelphij
393171070Sdelphij	sbp->f_iosize = PAGE_SIZE;
394170808Sdelphij	sbp->f_bsize = PAGE_SIZE;
395170808Sdelphij
396233998Sgleb	used = tmpfs_pages_used(tmp);
397233998Sgleb	if (tmp->tm_pages_max != SIZE_MAX)
398233998Sgleb		 sbp->f_blocks = tmp->tm_pages_max;
399233998Sgleb	else
400233998Sgleb		 sbp->f_blocks = used + tmpfs_mem_avail();
401233998Sgleb	if (sbp->f_blocks <= used)
402233998Sgleb		sbp->f_bavail = 0;
403233998Sgleb	else
404233998Sgleb		sbp->f_bavail = sbp->f_blocks - used;
405233998Sgleb	sbp->f_bfree = sbp->f_bavail;
406233998Sgleb	used = tmp->tm_nodes_inuse;
407233998Sgleb	sbp->f_files = tmp->tm_nodes_max;
408233998Sgleb	if (sbp->f_files <= used)
409233998Sgleb		sbp->f_ffree = 0;
410233998Sgleb	else
411233998Sgleb		sbp->f_ffree = sbp->f_files - used;
412170808Sdelphij	/* sbp->f_owner = tmp->tn_uid; */
413170808Sdelphij
414170808Sdelphij	return 0;
415170808Sdelphij}
416170808Sdelphij
417269175Skibstatic int
418269175Skibtmpfs_sync(struct mount *mp, int waitfor)
419269175Skib{
420269175Skib
421269175Skib	if (waitfor == MNT_SUSPEND) {
422269175Skib		MNT_ILOCK(mp);
423269175Skib		mp->mnt_kern_flag |= MNTK_SUSPEND2 | MNTK_SUSPENDED;
424269175Skib		MNT_IUNLOCK(mp);
425269175Skib	}
426269175Skib	return (0);
427269175Skib}
428269175Skib
429170808Sdelphij/*
430170808Sdelphij * tmpfs vfs operations.
431170808Sdelphij */
432170808Sdelphij
433170808Sdelphijstruct vfsops tmpfs_vfsops = {
434170808Sdelphij	.vfs_mount =			tmpfs_mount,
435170808Sdelphij	.vfs_unmount =			tmpfs_unmount,
436170808Sdelphij	.vfs_root =			tmpfs_root,
437170808Sdelphij	.vfs_statfs =			tmpfs_statfs,
438170808Sdelphij	.vfs_fhtovp =			tmpfs_fhtovp,
439269175Skib	.vfs_sync =			tmpfs_sync,
440170808Sdelphij};
441254741SdelphijVFS_SET(tmpfs_vfsops, tmpfs, VFCF_JAIL);
442