tmpfs_vfsops.c revision 1.2 1 1.2 jmmv /* $NetBSD: tmpfs_vfsops.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $ */
2 1.1 jmmv
3 1.1 jmmv /*
4 1.1 jmmv * Copyright (c) 2005 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.1 jmmv * by Julio M. Merino Vidal.
9 1.1 jmmv *
10 1.1 jmmv * Redistribution and use in source and binary forms, with or without
11 1.1 jmmv * modification, are permitted provided that the following conditions
12 1.1 jmmv * are met:
13 1.1 jmmv * 1. Redistributions of source code must retain the above copyright
14 1.1 jmmv * notice, this list of conditions and the following disclaimer.
15 1.1 jmmv * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 jmmv * notice, this list of conditions and the following disclaimer in the
17 1.1 jmmv * documentation and/or other materials provided with the distribution.
18 1.1 jmmv * 3. All advertising materials mentioning features or use of this software
19 1.1 jmmv * must display the following acknowledgement:
20 1.1 jmmv * This product includes software developed by the NetBSD
21 1.1 jmmv * Foundation, Inc. and its contributors.
22 1.1 jmmv * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 jmmv * contributors may be used to endorse or promote products derived
24 1.1 jmmv * from this software without specific prior written permission.
25 1.1 jmmv *
26 1.1 jmmv * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 jmmv * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 jmmv * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 jmmv * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 jmmv * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 jmmv * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 jmmv * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 jmmv * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 jmmv * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 jmmv * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 jmmv * POSSIBILITY OF SUCH DAMAGE.
37 1.1 jmmv */
38 1.1 jmmv
39 1.1 jmmv /*
40 1.2 jmmv * Efficient memory file system.
41 1.1 jmmv */
42 1.1 jmmv
43 1.1 jmmv #include <sys/cdefs.h>
44 1.2 jmmv __KERNEL_RCSID(0, "$NetBSD: tmpfs_vfsops.c,v 1.2 2005/09/10 22:28:57 jmmv Exp $");
45 1.1 jmmv
46 1.1 jmmv #include <sys/param.h>
47 1.1 jmmv #include <sys/types.h>
48 1.1 jmmv #include <sys/malloc.h>
49 1.1 jmmv #include <sys/mount.h>
50 1.1 jmmv #include <sys/systm.h>
51 1.1 jmmv #include <sys/vnode.h>
52 1.1 jmmv
53 1.1 jmmv #include <fs/tmpfs/tmpfs.h>
54 1.1 jmmv
55 1.1 jmmv MALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures");
56 1.1 jmmv
57 1.1 jmmv /* --------------------------------------------------------------------- */
58 1.1 jmmv
59 1.1 jmmv static int tmpfs_mount(struct mount *, const char *, void *,
60 1.1 jmmv struct nameidata *, struct proc *);
61 1.1 jmmv static int tmpfs_start(struct mount *, int, struct proc *);
62 1.1 jmmv static int tmpfs_unmount(struct mount *, int, struct proc *);
63 1.1 jmmv static int tmpfs_root(struct mount *, struct vnode **);
64 1.1 jmmv static int tmpfs_quotactl(struct mount *, int, uid_t, void *,
65 1.1 jmmv struct proc *);
66 1.1 jmmv static int tmpfs_vget(struct mount *, ino_t, struct vnode **);
67 1.1 jmmv static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **);
68 1.1 jmmv static int tmpfs_vptofh(struct vnode *, struct fid *);
69 1.1 jmmv static int tmpfs_statvfs(struct mount *, struct statvfs *, struct proc *);
70 1.1 jmmv static int tmpfs_sync(struct mount *, int, struct ucred *, struct proc *);
71 1.1 jmmv static void tmpfs_init(void);
72 1.1 jmmv static void tmpfs_done(void);
73 1.1 jmmv static int tmpfs_checkexp(struct mount *, struct mbuf *, int *,
74 1.1 jmmv struct ucred **);
75 1.1 jmmv static int tmpfs_snapshot(struct mount *, struct vnode *,
76 1.1 jmmv struct timespec *);
77 1.1 jmmv
78 1.1 jmmv /* --------------------------------------------------------------------- */
79 1.1 jmmv
80 1.1 jmmv static int
81 1.1 jmmv tmpfs_mount(struct mount *mp, const char *path, void *data,
82 1.1 jmmv struct nameidata *ndp, struct proc *p)
83 1.1 jmmv {
84 1.1 jmmv int error;
85 1.1 jmmv ino_t nodes;
86 1.1 jmmv size_t pages;
87 1.1 jmmv struct tmpfs_mount *tmp;
88 1.1 jmmv struct tmpfs_node *root;
89 1.1 jmmv struct tmpfs_args args;
90 1.1 jmmv
91 1.1 jmmv /* Handle retrieval of mount point arguments. */
92 1.1 jmmv if (mp->mnt_flag & MNT_GETARGS) {
93 1.1 jmmv if (mp->mnt_data == NULL)
94 1.1 jmmv return EIO;
95 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
96 1.1 jmmv
97 1.1 jmmv args.ta_version = TMPFS_ARGS_VERSION;
98 1.1 jmmv args.ta_fspec = NULL;
99 1.1 jmmv args.ta_nodes_max = tmp->tm_nodes_max;
100 1.1 jmmv args.ta_size_max = tmp->tm_pages_max * PAGE_SIZE;
101 1.1 jmmv
102 1.1 jmmv root = tmp->tm_root;
103 1.1 jmmv args.ta_root_uid = root->tn_uid;
104 1.1 jmmv args.ta_root_gid = root->tn_gid;
105 1.1 jmmv args.ta_root_mode = root->tn_mode;
106 1.1 jmmv
107 1.1 jmmv vfs_showexport(mp, &args, &tmp->tm_export);
108 1.1 jmmv
109 1.1 jmmv return copyout(&args, data, sizeof(args));
110 1.1 jmmv }
111 1.1 jmmv
112 1.1 jmmv /* Verify that we have parameters, as they are required. */
113 1.1 jmmv if (data == NULL)
114 1.1 jmmv return EINVAL;
115 1.1 jmmv
116 1.1 jmmv /* Get the mount parameters. */
117 1.1 jmmv error = copyin(data, &args, sizeof(args));
118 1.1 jmmv if (error != 0)
119 1.1 jmmv return error;
120 1.1 jmmv
121 1.1 jmmv if (mp->mnt_flag & MNT_UPDATE) {
122 1.1 jmmv if (mp->mnt_data == NULL)
123 1.1 jmmv return EIO;
124 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
125 1.1 jmmv
126 1.1 jmmv if (args.ta_fspec == NULL) {
127 1.1 jmmv /* Update NFS export information. */
128 1.1 jmmv return vfs_export(mp, &tmp->tm_export, &args.ta_export);
129 1.1 jmmv }
130 1.1 jmmv
131 1.2 jmmv /* XXX: There is no support yet to update file system
132 1.1 jmmv * settings. Should be added. */
133 1.1 jmmv
134 1.1 jmmv return EOPNOTSUPP;
135 1.1 jmmv }
136 1.1 jmmv
137 1.1 jmmv if (args.ta_version != TMPFS_ARGS_VERSION)
138 1.1 jmmv return EINVAL;
139 1.1 jmmv
140 1.1 jmmv /* Do not allow mounts if we do not have enough memory to preserve
141 1.1 jmmv * the minimum reserved pages. */
142 1.1 jmmv if (tmpfs_mem_info(TRUE) < TMPFS_PAGES_RESERVED)
143 1.1 jmmv return EINVAL;
144 1.1 jmmv
145 1.2 jmmv /* Get the maximum number of memory pages this file system is
146 1.1 jmmv * allowed to use, based on the maximum size the user passed in
147 1.1 jmmv * the mount structure. A value of zero is treated as if the
148 1.1 jmmv * maximum available space was requested. */
149 1.1 jmmv if (args.ta_size_max == 0)
150 1.1 jmmv pages = SIZE_MAX;
151 1.1 jmmv else
152 1.1 jmmv pages = args.ta_size_max / PAGE_SIZE +
153 1.1 jmmv (args.ta_size_max % PAGE_SIZE == 0 ? 0 : 1);
154 1.1 jmmv
155 1.1 jmmv if (args.ta_nodes_max == 0)
156 1.1 jmmv nodes = pages * PAGE_SIZE / 1024;
157 1.1 jmmv else
158 1.1 jmmv nodes = args.ta_nodes_max;
159 1.1 jmmv
160 1.1 jmmv /* Allocate the tmpfs mount structure and fill it. */
161 1.1 jmmv tmp = (struct tmpfs_mount *)malloc(sizeof(struct tmpfs_mount),
162 1.1 jmmv M_TMPFSMNT, M_WAITOK);
163 1.1 jmmv KASSERT(tmp != NULL);
164 1.1 jmmv
165 1.1 jmmv tmp->tm_nodes_max = nodes;
166 1.1 jmmv tmp->tm_nodes_last = 0;
167 1.1 jmmv LIST_INIT(&tmp->tm_nodes_used);
168 1.1 jmmv LIST_INIT(&tmp->tm_nodes_avail);
169 1.1 jmmv
170 1.1 jmmv tmp->tm_pages_max = pages;
171 1.1 jmmv tmp->tm_pages_used = 0;
172 1.1 jmmv tmpfs_pool_init(&tmp->tm_dirent_pool, sizeof(struct tmpfs_dirent),
173 1.1 jmmv "dirent", tmp);
174 1.1 jmmv tmpfs_pool_init(&tmp->tm_node_pool, sizeof(struct tmpfs_node),
175 1.1 jmmv "node", tmp);
176 1.1 jmmv tmpfs_str_pool_init(&tmp->tm_str_pool, tmp);
177 1.1 jmmv bzero(&tmp->tm_export, sizeof(struct netexport));
178 1.1 jmmv
179 1.1 jmmv /* Allocate the root node. */
180 1.1 jmmv error = tmpfs_alloc_node(tmp, VDIR, args.ta_root_uid,
181 1.1 jmmv args.ta_root_gid, args.ta_root_mode, NULL, NULL, VNOVAL, p,
182 1.1 jmmv &root);
183 1.1 jmmv KASSERT(error == 0 && root != NULL);
184 1.1 jmmv tmp->tm_root = root;
185 1.1 jmmv
186 1.1 jmmv mp->mnt_data = tmp;
187 1.1 jmmv mp->mnt_flag |= MNT_LOCAL;
188 1.1 jmmv mp->mnt_stat.f_namemax = MAXNAMLEN;
189 1.1 jmmv vfs_getnewfsid(mp);
190 1.1 jmmv
191 1.1 jmmv return set_statvfs_info(path, UIO_USERSPACE, "tmpfs", UIO_SYSSPACE,
192 1.1 jmmv mp, p);
193 1.1 jmmv }
194 1.1 jmmv
195 1.1 jmmv /* --------------------------------------------------------------------- */
196 1.1 jmmv
197 1.1 jmmv static int
198 1.1 jmmv tmpfs_start(struct mount *mp, int flags, struct proc *p)
199 1.1 jmmv {
200 1.1 jmmv
201 1.1 jmmv return 0;
202 1.1 jmmv }
203 1.1 jmmv
204 1.1 jmmv /* --------------------------------------------------------------------- */
205 1.1 jmmv
206 1.1 jmmv /* ARGSUSED2 */
207 1.1 jmmv static int
208 1.1 jmmv tmpfs_unmount(struct mount *mp, int mntflags, struct proc *p)
209 1.1 jmmv {
210 1.1 jmmv int error;
211 1.1 jmmv int flags = 0;
212 1.1 jmmv struct tmpfs_mount *tmp;
213 1.1 jmmv struct tmpfs_node *node;
214 1.1 jmmv
215 1.1 jmmv /* Handle forced unmounts. */
216 1.1 jmmv if (mntflags & MNT_FORCE)
217 1.1 jmmv flags |= FORCECLOSE;
218 1.1 jmmv
219 1.1 jmmv /* Finalize all pending I/O. */
220 1.1 jmmv error = vflush(mp, NULL, flags);
221 1.1 jmmv if (error != 0)
222 1.1 jmmv return error;
223 1.1 jmmv
224 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
225 1.1 jmmv
226 1.1 jmmv /* Free all associated data. The loop iterates over the linked list
227 1.1 jmmv * we have containing all used nodes. For each of them that is
228 1.1 jmmv * a directory, we free all its directory entries. Note that after
229 1.1 jmmv * freeing a node, it will automatically go to the available list,
230 1.1 jmmv * so we will later have to iterate over it to release its items. */
231 1.1 jmmv node = LIST_FIRST(&tmp->tm_nodes_used);
232 1.1 jmmv while (node != NULL) {
233 1.1 jmmv struct tmpfs_node *next;
234 1.1 jmmv
235 1.1 jmmv if (node->tn_type == VDIR) {
236 1.1 jmmv struct tmpfs_dirent *de;
237 1.1 jmmv
238 1.1 jmmv de = TAILQ_FIRST(&node->tn_dir);
239 1.1 jmmv while (de != NULL) {
240 1.1 jmmv struct tmpfs_dirent *nde;
241 1.1 jmmv
242 1.1 jmmv nde = TAILQ_NEXT(de, td_entries);
243 1.1 jmmv tmpfs_free_dirent(tmp, de, FALSE);
244 1.1 jmmv de = nde;
245 1.1 jmmv node->tn_size -= sizeof(struct tmpfs_dirent);
246 1.1 jmmv }
247 1.1 jmmv }
248 1.1 jmmv
249 1.1 jmmv next = LIST_NEXT(node, tn_entries);
250 1.1 jmmv tmpfs_free_node(tmp, node);
251 1.1 jmmv node = next;
252 1.1 jmmv }
253 1.1 jmmv node = LIST_FIRST(&tmp->tm_nodes_avail);
254 1.1 jmmv while (node != NULL) {
255 1.1 jmmv struct tmpfs_node *next;
256 1.1 jmmv
257 1.1 jmmv next = LIST_NEXT(node, tn_entries);
258 1.1 jmmv LIST_REMOVE(node, tn_entries);
259 1.1 jmmv TMPFS_POOL_PUT(&tmp->tm_node_pool, node);
260 1.1 jmmv node = next;
261 1.1 jmmv }
262 1.1 jmmv
263 1.1 jmmv tmpfs_pool_destroy(&tmp->tm_dirent_pool);
264 1.1 jmmv tmpfs_pool_destroy(&tmp->tm_node_pool);
265 1.1 jmmv tmpfs_str_pool_destroy(&tmp->tm_str_pool);
266 1.1 jmmv
267 1.1 jmmv KASSERT(tmp->tm_pages_used == 0);
268 1.1 jmmv
269 1.1 jmmv /* Throw away the tmpfs_mount structure. */
270 1.1 jmmv free(mp->mnt_data, M_TMPFSMNT);
271 1.1 jmmv mp->mnt_data = NULL;
272 1.1 jmmv
273 1.1 jmmv return 0;
274 1.1 jmmv }
275 1.1 jmmv
276 1.1 jmmv /* --------------------------------------------------------------------- */
277 1.1 jmmv
278 1.1 jmmv static int
279 1.1 jmmv tmpfs_root(struct mount *mp, struct vnode **vpp)
280 1.1 jmmv {
281 1.1 jmmv
282 1.1 jmmv return tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, vpp);
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_quotactl(struct mount *mp, int cmd, uid_t uid, void *arg,
289 1.1 jmmv struct proc *p)
290 1.1 jmmv {
291 1.1 jmmv
292 1.1 jmmv printf("tmpfs_quotactl called; need for it unknown yet\n");
293 1.1 jmmv return EOPNOTSUPP;
294 1.1 jmmv }
295 1.1 jmmv
296 1.1 jmmv /* --------------------------------------------------------------------- */
297 1.1 jmmv
298 1.1 jmmv static int
299 1.1 jmmv tmpfs_vget(struct mount *mp, ino_t ino, struct vnode **vpp)
300 1.1 jmmv {
301 1.1 jmmv
302 1.1 jmmv printf("tmpfs_vget called; need for it unknown yet\n");
303 1.1 jmmv return EOPNOTSUPP;
304 1.1 jmmv }
305 1.1 jmmv
306 1.1 jmmv /* --------------------------------------------------------------------- */
307 1.1 jmmv
308 1.1 jmmv static int
309 1.1 jmmv tmpfs_fhtovp(struct mount *mp, struct fid *fhp, struct vnode **vpp)
310 1.1 jmmv {
311 1.1 jmmv boolean_t found;
312 1.1 jmmv struct tmpfs_fid *tfhp;
313 1.1 jmmv struct tmpfs_mount *tmp;
314 1.1 jmmv struct tmpfs_node *node;
315 1.1 jmmv
316 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
317 1.1 jmmv
318 1.1 jmmv tfhp = (struct tmpfs_fid *)fhp;
319 1.1 jmmv if (tfhp->tf_len != sizeof(struct tmpfs_fid))
320 1.1 jmmv return EINVAL;
321 1.1 jmmv
322 1.1 jmmv if (tfhp->tf_id >= tmp->tm_nodes_max)
323 1.1 jmmv return EINVAL;
324 1.1 jmmv
325 1.1 jmmv found = FALSE;
326 1.1 jmmv LIST_FOREACH(node, &tmp->tm_nodes_used, tn_entries) {
327 1.1 jmmv if (node->tn_id == tfhp->tf_id &&
328 1.1 jmmv node->tn_gen == tfhp->tf_gen) {
329 1.1 jmmv found = TRUE;
330 1.1 jmmv break;
331 1.1 jmmv }
332 1.1 jmmv }
333 1.1 jmmv
334 1.1 jmmv return found ? tmpfs_alloc_vp(mp, node, vpp) : EINVAL;
335 1.1 jmmv }
336 1.1 jmmv
337 1.1 jmmv /* --------------------------------------------------------------------- */
338 1.1 jmmv
339 1.1 jmmv static int
340 1.1 jmmv tmpfs_vptofh(struct vnode *vp, struct fid *fhp)
341 1.1 jmmv {
342 1.1 jmmv struct tmpfs_fid *tfhp;
343 1.1 jmmv struct tmpfs_node *node;
344 1.1 jmmv
345 1.1 jmmv tfhp = (struct tmpfs_fid *)fhp;
346 1.1 jmmv node = VP_TO_TMPFS_NODE(vp);
347 1.1 jmmv
348 1.1 jmmv tfhp->tf_len = sizeof(struct tmpfs_fid);
349 1.1 jmmv tfhp->tf_id = node->tn_id;
350 1.1 jmmv tfhp->tf_gen = node->tn_gen;
351 1.1 jmmv
352 1.1 jmmv return 0;
353 1.1 jmmv }
354 1.1 jmmv
355 1.1 jmmv /* --------------------------------------------------------------------- */
356 1.1 jmmv
357 1.1 jmmv /* ARGSUSED2 */
358 1.1 jmmv static int
359 1.1 jmmv tmpfs_statvfs(struct mount *mp, struct statvfs *sbp, struct proc *p)
360 1.1 jmmv {
361 1.1 jmmv fsfilcnt_t freenodes, usednodes;
362 1.1 jmmv struct tmpfs_mount *tmp;
363 1.1 jmmv struct tmpfs_node *dummy;
364 1.1 jmmv
365 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
366 1.1 jmmv
367 1.1 jmmv sbp->f_iosize = sbp->f_frsize = sbp->f_bsize = PAGE_SIZE;
368 1.1 jmmv
369 1.1 jmmv sbp->f_blocks = TMPFS_PAGES_MAX(tmp);
370 1.1 jmmv sbp->f_bavail = sbp->f_bfree = TMPFS_PAGES_AVAIL(tmp);
371 1.1 jmmv sbp->f_bresvd = 0;
372 1.1 jmmv
373 1.1 jmmv freenodes = MIN(tmp->tm_nodes_max - tmp->tm_nodes_last,
374 1.1 jmmv TMPFS_PAGES_AVAIL(tmp) * PAGE_SIZE / sizeof(struct tmpfs_node));
375 1.1 jmmv LIST_FOREACH(dummy, &tmp->tm_nodes_avail, tn_entries)
376 1.1 jmmv freenodes++;
377 1.1 jmmv
378 1.1 jmmv usednodes = 0;
379 1.1 jmmv LIST_FOREACH(dummy, &tmp->tm_nodes_used, tn_entries)
380 1.1 jmmv usednodes++;
381 1.1 jmmv
382 1.1 jmmv sbp->f_files = freenodes + usednodes;
383 1.1 jmmv sbp->f_favail = sbp->f_ffree = freenodes;
384 1.1 jmmv sbp->f_fresvd = 0;
385 1.1 jmmv
386 1.1 jmmv copy_statvfs_info(sbp, mp);
387 1.1 jmmv
388 1.1 jmmv return 0;
389 1.1 jmmv }
390 1.1 jmmv
391 1.1 jmmv /* --------------------------------------------------------------------- */
392 1.1 jmmv
393 1.1 jmmv /* ARGSUSED0 */
394 1.1 jmmv static int
395 1.1 jmmv tmpfs_sync(struct mount *mp, int waitfor, struct ucred *uc, struct proc *p)
396 1.1 jmmv {
397 1.1 jmmv
398 1.1 jmmv return 0;
399 1.1 jmmv }
400 1.1 jmmv
401 1.1 jmmv /* --------------------------------------------------------------------- */
402 1.1 jmmv
403 1.1 jmmv static void
404 1.1 jmmv tmpfs_init(void)
405 1.1 jmmv {
406 1.1 jmmv
407 1.1 jmmv #ifdef _LKM
408 1.1 jmmv malloc_type_attach(M_TMPFSMNT);
409 1.1 jmmv #endif
410 1.1 jmmv }
411 1.1 jmmv
412 1.1 jmmv /* --------------------------------------------------------------------- */
413 1.1 jmmv
414 1.1 jmmv static void
415 1.1 jmmv tmpfs_done(void)
416 1.1 jmmv {
417 1.1 jmmv
418 1.1 jmmv #ifdef _LKM
419 1.1 jmmv malloc_type_detach(M_TMPFSMNT);
420 1.1 jmmv #endif
421 1.1 jmmv }
422 1.1 jmmv
423 1.1 jmmv /* --------------------------------------------------------------------- */
424 1.1 jmmv
425 1.1 jmmv static int
426 1.1 jmmv tmpfs_checkexp(struct mount *mp, struct mbuf *mb, int *wh,
427 1.1 jmmv struct ucred **anon)
428 1.1 jmmv {
429 1.1 jmmv struct netcred *np;
430 1.1 jmmv struct tmpfs_mount *tmp;
431 1.1 jmmv
432 1.1 jmmv tmp = VFS_TO_TMPFS(mp);
433 1.1 jmmv
434 1.1 jmmv np = vfs_export_lookup(mp, &tmp->tm_export, mb);
435 1.1 jmmv if (np != NULL) {
436 1.1 jmmv *wh = np->netc_exflags;
437 1.1 jmmv *anon = &np->netc_anon;
438 1.1 jmmv }
439 1.1 jmmv
440 1.1 jmmv return np == NULL ? EACCES : 0;
441 1.1 jmmv }
442 1.1 jmmv
443 1.1 jmmv /* --------------------------------------------------------------------- */
444 1.1 jmmv
445 1.1 jmmv static int
446 1.1 jmmv tmpfs_snapshot(struct mount *mp, struct vnode *vp, struct timespec *ctime)
447 1.1 jmmv {
448 1.1 jmmv
449 1.1 jmmv return EOPNOTSUPP;
450 1.1 jmmv }
451 1.1 jmmv
452 1.1 jmmv /* --------------------------------------------------------------------- */
453 1.1 jmmv
454 1.1 jmmv /*
455 1.1 jmmv * tmpfs vfs operations.
456 1.1 jmmv */
457 1.1 jmmv
458 1.1 jmmv extern const struct vnodeopv_desc tmpfs_fifoop_opv_desc;
459 1.1 jmmv extern const struct vnodeopv_desc tmpfs_specop_opv_desc;
460 1.1 jmmv extern const struct vnodeopv_desc tmpfs_vnodeop_opv_desc;
461 1.1 jmmv
462 1.1 jmmv const struct vnodeopv_desc * const tmpfs_vnodeopv_descs[] = {
463 1.1 jmmv &tmpfs_fifoop_opv_desc,
464 1.1 jmmv &tmpfs_specop_opv_desc,
465 1.1 jmmv &tmpfs_vnodeop_opv_desc,
466 1.1 jmmv NULL,
467 1.1 jmmv };
468 1.1 jmmv
469 1.1 jmmv struct vfsops tmpfs_vfsops = {
470 1.1 jmmv MOUNT_TMPFS, /* vfs_name */
471 1.1 jmmv tmpfs_mount, /* vfs_mount */
472 1.1 jmmv tmpfs_start, /* vfs_start */
473 1.1 jmmv tmpfs_unmount, /* vfs_unmount */
474 1.1 jmmv tmpfs_root, /* vfs_root */
475 1.1 jmmv tmpfs_quotactl, /* vfs_quotactl */
476 1.1 jmmv tmpfs_statvfs, /* vfs_statvfs */
477 1.1 jmmv tmpfs_sync, /* vfs_sync */
478 1.1 jmmv tmpfs_vget, /* vfs_vget */
479 1.1 jmmv tmpfs_fhtovp, /* vfs_fhtovp */
480 1.1 jmmv tmpfs_vptofh, /* vfs_vptofh */
481 1.1 jmmv tmpfs_init, /* vfs_init */
482 1.1 jmmv NULL, /* vfs_reinit */
483 1.1 jmmv tmpfs_done, /* vfs_done */
484 1.1 jmmv NULL, /* vfs_wassysctl: deprecated */
485 1.1 jmmv NULL, /* vfs_mountroot */
486 1.1 jmmv tmpfs_checkexp, /* vfs_checkexp */
487 1.1 jmmv tmpfs_snapshot, /* vfs_snapshot */
488 1.1 jmmv vfs_stdextattrctl, /* vfs_extattrctl */
489 1.1 jmmv tmpfs_vnodeopv_descs,
490 1.1 jmmv };
491 1.1 jmmv VFS_ATTACH(tmpfs_vfsops);
492