tmpfs_vfsops.c revision 1.63 1 1.63 martin /* $NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin 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.63 martin __KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.63 2014/06/10 16:10:59 martin 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.41 rumble #include <sys/module.h>
55 1.1 jmmv
56 1.36 dholland #include <miscfs/genfs/genfs.h>
57 1.1 jmmv #include <fs/tmpfs/tmpfs.h>
58 1.44 pooka #include <fs/tmpfs/tmpfs_args.h>
59 1.1 jmmv
60 1.41 rumble MODULE(MODULE_CLASS_VFS, tmpfs, NULL);
61 1.41 rumble
62 1.48 rmind struct pool tmpfs_dirent_pool;
63 1.48 rmind struct pool tmpfs_node_pool;
64 1.1 jmmv
65 1.32 pooka static int tmpfs_mount(struct mount *, const char *, void *, size_t *);
66 1.32 pooka static int tmpfs_start(struct mount *, int);
67 1.32 pooka static int tmpfs_unmount(struct mount *, int);
68 1.50 rmind static int tmpfs_root(struct mount *, vnode_t **);
69 1.50 rmind static int tmpfs_vget(struct mount *, ino_t, vnode_t **);
70 1.50 rmind static int tmpfs_fhtovp(struct mount *, struct fid *, vnode_t **);
71 1.13 martin static int tmpfs_vptofh(struct vnode *, struct fid *, size_t *);
72 1.32 pooka static int tmpfs_statvfs(struct mount *, struct statvfs *);
73 1.32 pooka static int tmpfs_sync(struct mount *, int, kauth_cred_t);
74 1.1 jmmv static void tmpfs_init(void);
75 1.1 jmmv static void tmpfs_done(void);
76 1.50 rmind static int tmpfs_snapshot(struct mount *, vnode_t *, struct timespec *);
77 1.1 jmmv
78 1.48 rmind static void
79 1.48 rmind tmpfs_init(void)
80 1.48 rmind {
81 1.48 rmind
82 1.50 rmind pool_init(&tmpfs_dirent_pool, sizeof(tmpfs_dirent_t), 0, 0, 0,
83 1.48 rmind "tmpfs_dirent", &pool_allocator_nointr, IPL_NONE);
84 1.50 rmind pool_init(&tmpfs_node_pool, sizeof(tmpfs_node_t), 0, 0, 0,
85 1.48 rmind "tmpfs_node", &pool_allocator_nointr, IPL_NONE);
86 1.48 rmind }
87 1.48 rmind
88 1.48 rmind static void
89 1.48 rmind tmpfs_done(void)
90 1.48 rmind {
91 1.48 rmind
92 1.48 rmind pool_destroy(&tmpfs_dirent_pool);
93 1.48 rmind pool_destroy(&tmpfs_node_pool);
94 1.48 rmind }
95 1.1 jmmv
96 1.1 jmmv static int
97 1.32 pooka tmpfs_mount(struct mount *mp, const char *path, void *data, size_t *data_len)
98 1.1 jmmv {
99 1.23 dsl struct tmpfs_args *args = data;
100 1.50 rmind tmpfs_mount_t *tmp;
101 1.50 rmind tmpfs_node_t *root;
102 1.45 rmind uint64_t memlimit;
103 1.45 rmind ino_t nodes;
104 1.45 rmind int error;
105 1.23 dsl
106 1.59 maxv if (args == NULL)
107 1.59 maxv return EINVAL;
108 1.59 maxv
109 1.49 rmind /* Validate the version. */
110 1.49 rmind if (*data_len < sizeof(*args) ||
111 1.49 rmind args->ta_version != TMPFS_ARGS_VERSION)
112 1.23 dsl return EINVAL;
113 1.1 jmmv
114 1.1 jmmv /* Handle retrieval of mount point arguments. */
115 1.1 jmmv if (mp->mnt_flag & MNT_GETARGS) {
116 1.1 jmmv if (mp->mnt_data == NULL)
117 1.1 jmmv return EIO;
118 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
119 1.1 jmmv
120 1.23 dsl args->ta_version = TMPFS_ARGS_VERSION;
121 1.23 dsl args->ta_nodes_max = tmp->tm_nodes_max;
122 1.45 rmind args->ta_size_max = tmp->tm_mem_limit;
123 1.31 ad
124 1.30 ad root = tmp->tm_root;
125 1.23 dsl args->ta_root_uid = root->tn_uid;
126 1.23 dsl args->ta_root_gid = root->tn_gid;
127 1.23 dsl args->ta_root_mode = root->tn_mode;
128 1.1 jmmv
129 1.45 rmind *data_len = sizeof(*args);
130 1.23 dsl return 0;
131 1.1 jmmv }
132 1.1 jmmv
133 1.1 jmmv
134 1.49 rmind /* Prohibit mounts if there is not enough memory. */
135 1.62 martin if (tmpfs_mem_info(true) < uvmexp.freetarg)
136 1.1 jmmv return EINVAL;
137 1.1 jmmv
138 1.63 martin /* Check for invalid uid and gid arguments */
139 1.63 martin if (args->ta_root_uid == VNOVAL || args->ta_root_gid == VNOVAL)
140 1.63 martin return EINVAL;
141 1.63 martin
142 1.63 martin /* This can never happen? */
143 1.63 martin if ((args->ta_root_mode & ALLPERMS) == VNOVAL)
144 1.63 martin return EINVAL;
145 1.63 martin
146 1.45 rmind /* Get the memory usage limit for this file-system. */
147 1.45 rmind if (args->ta_size_max < PAGE_SIZE) {
148 1.45 rmind memlimit = UINT64_MAX;
149 1.45 rmind } else {
150 1.45 rmind memlimit = args->ta_size_max;
151 1.45 rmind }
152 1.45 rmind KASSERT(memlimit > 0);
153 1.45 rmind
154 1.45 rmind if (args->ta_nodes_max <= 3) {
155 1.45 rmind nodes = 3 + (memlimit / 1024);
156 1.45 rmind } else {
157 1.23 dsl nodes = args->ta_nodes_max;
158 1.45 rmind }
159 1.45 rmind nodes = MIN(nodes, INT_MAX);
160 1.7 jmmv KASSERT(nodes >= 3);
161 1.1 jmmv
162 1.60 christos if (mp->mnt_flag & MNT_UPDATE) {
163 1.60 christos tmp = VFS_TO_TMPFS(mp);
164 1.60 christos if (nodes < tmp->tm_nodes_cnt)
165 1.60 christos return EBUSY;
166 1.60 christos if ((error = tmpfs_mntmem_set(tmp, memlimit)) != 0)
167 1.60 christos return error;
168 1.60 christos tmp->tm_nodes_max = nodes;
169 1.61 christos root = tmp->tm_root;
170 1.60 christos root->tn_uid = args->ta_root_uid;
171 1.60 christos root->tn_gid = args->ta_root_gid;
172 1.60 christos root->tn_mode = args->ta_root_mode;
173 1.60 christos return 0;
174 1.60 christos }
175 1.60 christos
176 1.1 jmmv /* Allocate the tmpfs mount structure and fill it. */
177 1.50 rmind tmp = kmem_zalloc(sizeof(tmpfs_mount_t), KM_SLEEP);
178 1.34 ad if (tmp == NULL)
179 1.34 ad return ENOMEM;
180 1.1 jmmv
181 1.1 jmmv tmp->tm_nodes_max = nodes;
182 1.34 ad tmp->tm_nodes_cnt = 0;
183 1.34 ad LIST_INIT(&tmp->tm_nodes);
184 1.34 ad
185 1.34 ad mutex_init(&tmp->tm_lock, MUTEX_DEFAULT, IPL_NONE);
186 1.45 rmind tmpfs_mntmem_init(tmp, memlimit);
187 1.1 jmmv
188 1.1 jmmv /* Allocate the root node. */
189 1.23 dsl error = tmpfs_alloc_node(tmp, VDIR, args->ta_root_uid,
190 1.51 rmind args->ta_root_gid, args->ta_root_mode & ALLPERMS, NULL,
191 1.33 pooka VNOVAL, &root);
192 1.1 jmmv KASSERT(error == 0 && root != NULL);
193 1.51 rmind
194 1.51 rmind /*
195 1.51 rmind * Parent of the root inode is itself. Also, root inode has no
196 1.51 rmind * directory entry (i.e. is never attached), thus hold an extra
197 1.51 rmind * reference (link) for it.
198 1.51 rmind */
199 1.34 ad root->tn_links++;
200 1.51 rmind root->tn_spec.tn_dir.tn_parent = root;
201 1.1 jmmv tmp->tm_root = root;
202 1.1 jmmv
203 1.1 jmmv mp->mnt_data = tmp;
204 1.1 jmmv mp->mnt_flag |= MNT_LOCAL;
205 1.52 christos mp->mnt_stat.f_namemax = TMPFS_MAXNAMLEN;
206 1.27 pooka mp->mnt_fs_bshift = PAGE_SHIFT;
207 1.27 pooka mp->mnt_dev_bshift = DEV_BSHIFT;
208 1.34 ad mp->mnt_iflag |= IMNT_MPSAFE;
209 1.1 jmmv vfs_getnewfsid(mp);
210 1.1 jmmv
211 1.48 rmind error = set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
212 1.45 rmind mp->mnt_op->vfs_name, mp, curlwp);
213 1.48 rmind if (error) {
214 1.48 rmind (void)tmpfs_unmount(mp, MNT_FORCE);
215 1.48 rmind }
216 1.48 rmind return error;
217 1.1 jmmv }
218 1.1 jmmv
219 1.1 jmmv static int
220 1.32 pooka tmpfs_start(struct mount *mp, int flags)
221 1.1 jmmv {
222 1.1 jmmv
223 1.1 jmmv return 0;
224 1.1 jmmv }
225 1.1 jmmv
226 1.1 jmmv static int
227 1.32 pooka tmpfs_unmount(struct mount *mp, int mntflags)
228 1.1 jmmv {
229 1.53 rmind tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp);
230 1.53 rmind tmpfs_node_t *node, *cnode;
231 1.48 rmind int error, flags = 0;
232 1.1 jmmv
233 1.1 jmmv /* Handle forced unmounts. */
234 1.1 jmmv if (mntflags & MNT_FORCE)
235 1.1 jmmv flags |= FORCECLOSE;
236 1.1 jmmv
237 1.1 jmmv /* Finalize all pending I/O. */
238 1.1 jmmv error = vflush(mp, NULL, flags);
239 1.1 jmmv if (error != 0)
240 1.1 jmmv return error;
241 1.1 jmmv
242 1.53 rmind /*
243 1.53 rmind * First round, detach and destroy all directory entries.
244 1.53 rmind * Also, clear the pointers to the vnodes - they are gone.
245 1.53 rmind */
246 1.53 rmind LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) {
247 1.53 rmind tmpfs_dirent_t *de;
248 1.1 jmmv
249 1.53 rmind node->tn_vnode = NULL;
250 1.53 rmind if (node->tn_type != VDIR) {
251 1.53 rmind continue;
252 1.53 rmind }
253 1.53 rmind while ((de = TAILQ_FIRST(&node->tn_spec.tn_dir.tn_dir)) != NULL) {
254 1.54 rmind cnode = de->td_node;
255 1.54 rmind if (cnode && cnode != TMPFS_NODE_WHITEOUT) {
256 1.53 rmind cnode->tn_vnode = NULL;
257 1.1 jmmv }
258 1.53 rmind tmpfs_dir_detach(node, de);
259 1.53 rmind tmpfs_free_dirent(tmp, de);
260 1.1 jmmv }
261 1.55 rmind /* Extra virtual entry (itself for the root). */
262 1.55 rmind node->tn_links--;
263 1.53 rmind }
264 1.53 rmind
265 1.55 rmind /* Release the reference on root (diagnostic). */
266 1.55 rmind node = tmp->tm_root;
267 1.55 rmind node->tn_links--;
268 1.55 rmind
269 1.53 rmind /* Second round, destroy all inodes. */
270 1.53 rmind while ((node = LIST_FIRST(&tmp->tm_nodes)) != NULL) {
271 1.1 jmmv tmpfs_free_node(tmp, node);
272 1.31 ad }
273 1.1 jmmv
274 1.1 jmmv /* Throw away the tmpfs_mount structure. */
275 1.45 rmind tmpfs_mntmem_destroy(tmp);
276 1.34 ad mutex_destroy(&tmp->tm_lock);
277 1.34 ad kmem_free(tmp, sizeof(*tmp));
278 1.1 jmmv mp->mnt_data = NULL;
279 1.1 jmmv
280 1.1 jmmv return 0;
281 1.1 jmmv }
282 1.1 jmmv
283 1.1 jmmv static int
284 1.50 rmind tmpfs_root(struct mount *mp, vnode_t **vpp)
285 1.1 jmmv {
286 1.51 rmind tmpfs_node_t *node = VFS_TO_TMPFS(mp)->tm_root;
287 1.1 jmmv
288 1.51 rmind mutex_enter(&node->tn_vlock);
289 1.51 rmind return tmpfs_vnode_get(mp, node, vpp);
290 1.1 jmmv }
291 1.1 jmmv
292 1.1 jmmv static int
293 1.50 rmind tmpfs_vget(struct mount *mp, ino_t ino, vnode_t **vpp)
294 1.1 jmmv {
295 1.1 jmmv
296 1.1 jmmv return EOPNOTSUPP;
297 1.1 jmmv }
298 1.1 jmmv
299 1.1 jmmv static int
300 1.50 rmind tmpfs_fhtovp(struct mount *mp, struct fid *fhp, vnode_t **vpp)
301 1.1 jmmv {
302 1.51 rmind tmpfs_mount_t *tmp = VFS_TO_TMPFS(mp);
303 1.50 rmind tmpfs_node_t *node;
304 1.50 rmind tmpfs_fid_t tfh;
305 1.56 hannken int error;
306 1.1 jmmv
307 1.51 rmind if (fhp->fid_len != sizeof(tmpfs_fid_t)) {
308 1.1 jmmv return EINVAL;
309 1.51 rmind }
310 1.50 rmind memcpy(&tfh, fhp, sizeof(tmpfs_fid_t));
311 1.13 martin
312 1.34 ad mutex_enter(&tmp->tm_lock);
313 1.34 ad LIST_FOREACH(node, &tmp->tm_nodes, tn_entries) {
314 1.56 hannken if (node->tn_id == tfh.tf_id) {
315 1.56 hannken mutex_enter(&node->tn_vlock);
316 1.56 hannken break;
317 1.1 jmmv }
318 1.1 jmmv }
319 1.34 ad mutex_exit(&tmp->tm_lock);
320 1.1 jmmv
321 1.56 hannken if (node == NULL)
322 1.56 hannken return ESTALE;
323 1.51 rmind /* Will release the tn_vlock. */
324 1.56 hannken if ((error = tmpfs_vnode_get(mp, node, vpp)) != 0)
325 1.56 hannken return error;
326 1.56 hannken if (TMPFS_NODE_GEN(node) != tfh.tf_gen) {
327 1.56 hannken vput(*vpp);
328 1.56 hannken *vpp = NULL;
329 1.56 hannken return ESTALE;
330 1.56 hannken }
331 1.56 hannken
332 1.56 hannken return 0;
333 1.1 jmmv }
334 1.1 jmmv
335 1.1 jmmv static int
336 1.50 rmind tmpfs_vptofh(vnode_t *vp, struct fid *fhp, size_t *fh_size)
337 1.1 jmmv {
338 1.50 rmind tmpfs_fid_t tfh;
339 1.50 rmind tmpfs_node_t *node;
340 1.1 jmmv
341 1.50 rmind if (*fh_size < sizeof(tmpfs_fid_t)) {
342 1.50 rmind *fh_size = sizeof(tmpfs_fid_t);
343 1.13 martin return E2BIG;
344 1.13 martin }
345 1.50 rmind *fh_size = sizeof(tmpfs_fid_t);
346 1.1 jmmv node = VP_TO_TMPFS_NODE(vp);
347 1.1 jmmv
348 1.13 martin memset(&tfh, 0, sizeof(tfh));
349 1.50 rmind tfh.tf_len = sizeof(tmpfs_fid_t);
350 1.51 rmind tfh.tf_gen = TMPFS_NODE_GEN(node);
351 1.13 martin tfh.tf_id = node->tn_id;
352 1.13 martin memcpy(fhp, &tfh, sizeof(tfh));
353 1.1 jmmv
354 1.1 jmmv return 0;
355 1.1 jmmv }
356 1.1 jmmv
357 1.1 jmmv static int
358 1.32 pooka tmpfs_statvfs(struct mount *mp, struct statvfs *sbp)
359 1.1 jmmv {
360 1.50 rmind tmpfs_mount_t *tmp;
361 1.34 ad fsfilcnt_t freenodes;
362 1.46 rmind size_t avail;
363 1.1 jmmv
364 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
365 1.1 jmmv
366 1.1 jmmv sbp->f_iosize = sbp->f_frsize = sbp->f_bsize = PAGE_SIZE;
367 1.1 jmmv
368 1.46 rmind mutex_enter(&tmp->tm_acc_lock);
369 1.46 rmind avail = tmpfs_pages_avail(tmp);
370 1.45 rmind sbp->f_blocks = (tmpfs_bytes_max(tmp) >> PAGE_SHIFT);
371 1.46 rmind sbp->f_bavail = sbp->f_bfree = avail;
372 1.1 jmmv sbp->f_bresvd = 0;
373 1.1 jmmv
374 1.34 ad freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_cnt,
375 1.50 rmind avail * PAGE_SIZE / sizeof(tmpfs_node_t));
376 1.31 ad
377 1.34 ad sbp->f_files = tmp->tm_nodes_cnt + freenodes;
378 1.1 jmmv sbp->f_favail = sbp->f_ffree = freenodes;
379 1.1 jmmv sbp->f_fresvd = 0;
380 1.46 rmind mutex_exit(&tmp->tm_acc_lock);
381 1.1 jmmv
382 1.1 jmmv copy_statvfs_info(sbp, mp);
383 1.1 jmmv
384 1.1 jmmv return 0;
385 1.1 jmmv }
386 1.1 jmmv
387 1.1 jmmv static int
388 1.50 rmind tmpfs_sync(struct mount *mp, int waitfor, kauth_cred_t uc)
389 1.1 jmmv {
390 1.1 jmmv
391 1.1 jmmv return 0;
392 1.1 jmmv }
393 1.1 jmmv
394 1.1 jmmv static int
395 1.50 rmind tmpfs_snapshot(struct mount *mp, vnode_t *vp, struct timespec *ctime)
396 1.1 jmmv {
397 1.1 jmmv
398 1.1 jmmv return EOPNOTSUPP;
399 1.1 jmmv }
400 1.1 jmmv
401 1.1 jmmv /*
402 1.1 jmmv * tmpfs vfs operations.
403 1.1 jmmv */
404 1.1 jmmv
405 1.1 jmmv extern const struct vnodeopv_desc tmpfs_fifoop_opv_desc;
406 1.1 jmmv extern const struct vnodeopv_desc tmpfs_specop_opv_desc;
407 1.1 jmmv extern const struct vnodeopv_desc tmpfs_vnodeop_opv_desc;
408 1.1 jmmv
409 1.1 jmmv const struct vnodeopv_desc * const tmpfs_vnodeopv_descs[] = {
410 1.1 jmmv &tmpfs_fifoop_opv_desc,
411 1.1 jmmv &tmpfs_specop_opv_desc,
412 1.1 jmmv &tmpfs_vnodeop_opv_desc,
413 1.1 jmmv NULL,
414 1.1 jmmv };
415 1.1 jmmv
416 1.1 jmmv struct vfsops tmpfs_vfsops = {
417 1.58 hannken .vfs_name = MOUNT_TMPFS,
418 1.58 hannken .vfs_min_mount_data = sizeof (struct tmpfs_args),
419 1.58 hannken .vfs_mount = tmpfs_mount,
420 1.58 hannken .vfs_start = tmpfs_start,
421 1.58 hannken .vfs_unmount = tmpfs_unmount,
422 1.58 hannken .vfs_root = tmpfs_root,
423 1.58 hannken .vfs_quotactl = (void *)eopnotsupp,
424 1.58 hannken .vfs_statvfs = tmpfs_statvfs,
425 1.58 hannken .vfs_sync = tmpfs_sync,
426 1.58 hannken .vfs_vget = tmpfs_vget,
427 1.58 hannken .vfs_fhtovp = tmpfs_fhtovp,
428 1.58 hannken .vfs_vptofh = tmpfs_vptofh,
429 1.58 hannken .vfs_init = tmpfs_init,
430 1.58 hannken .vfs_done = tmpfs_done,
431 1.58 hannken .vfs_snapshot = tmpfs_snapshot,
432 1.58 hannken .vfs_extattrctl = vfs_stdextattrctl,
433 1.58 hannken .vfs_suspendctl = (void *)eopnotsupp,
434 1.58 hannken .vfs_renamelock_enter = genfs_renamelock_enter,
435 1.58 hannken .vfs_renamelock_exit = genfs_renamelock_exit,
436 1.58 hannken .vfs_fsync = (void *)eopnotsupp,
437 1.58 hannken .vfs_opv_descs = tmpfs_vnodeopv_descs
438 1.1 jmmv };
439 1.41 rumble
440 1.41 rumble static int
441 1.41 rumble tmpfs_modcmd(modcmd_t cmd, void *arg)
442 1.41 rumble {
443 1.41 rumble
444 1.41 rumble switch (cmd) {
445 1.41 rumble case MODULE_CMD_INIT:
446 1.41 rumble return vfs_attach(&tmpfs_vfsops);
447 1.41 rumble case MODULE_CMD_FINI:
448 1.41 rumble return vfs_detach(&tmpfs_vfsops);
449 1.41 rumble default:
450 1.41 rumble return ENOTTY;
451 1.41 rumble }
452 1.41 rumble }
453