tmpfs_vfsops.c (182739) | tmpfs_vfsops.c (191990) |
---|---|
1/* $NetBSD: tmpfs_vfsops.c,v 1.10 2005/12/11 12:24:29 christos Exp $ */ 2 3/*- 4 * Copyright (c) 2005 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code --- 27 unchanged lines hidden (view full) --- 36 * tmpfs is a file system that uses NetBSD's virtual memory sub-system 37 * (the well-known UVM) to store file data and metadata in an efficient 38 * way. This means that it does not follow the structure of an on-disk 39 * file system because it simply does not need to. Instead, it uses 40 * memory-specific data structures and algorithms to automatically 41 * allocate and release resources. 42 */ 43#include <sys/cdefs.h> | 1/* $NetBSD: tmpfs_vfsops.c,v 1.10 2005/12/11 12:24:29 christos Exp $ */ 2 3/*- 4 * Copyright (c) 2005 The NetBSD Foundation, Inc. 5 * All rights reserved. 6 * 7 * This code is derived from software contributed to The NetBSD Foundation 8 * by Julio M. Merino Vidal, developed as part of Google's Summer of Code --- 27 unchanged lines hidden (view full) --- 36 * tmpfs is a file system that uses NetBSD's virtual memory sub-system 37 * (the well-known UVM) to store file data and metadata in an efficient 38 * way. This means that it does not follow the structure of an on-disk 39 * file system because it simply does not need to. Instead, it uses 40 * memory-specific data structures and algorithms to automatically 41 * allocate and release resources. 42 */ 43#include <sys/cdefs.h> |
44__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 182739 2008-09-03 18:53:48Z delphij $"); | 44__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 191990 2009-05-11 15:33:26Z attilio $"); |
45 46#include <sys/param.h> 47#include <sys/limits.h> 48#include <sys/lock.h> 49#include <sys/mutex.h> 50#include <sys/kernel.h> 51#include <sys/stat.h> 52#include <sys/systm.h> --- 10 unchanged lines hidden (view full) --- 63 */ 64#define TMPFS_DEFAULT_ROOT_MODE (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) 65 66MALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures"); 67MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names"); 68 69/* --------------------------------------------------------------------- */ 70 | 45 46#include <sys/param.h> 47#include <sys/limits.h> 48#include <sys/lock.h> 49#include <sys/mutex.h> 50#include <sys/kernel.h> 51#include <sys/stat.h> 52#include <sys/systm.h> --- 10 unchanged lines hidden (view full) --- 63 */ 64#define TMPFS_DEFAULT_ROOT_MODE (S_IRWXU|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) 65 66MALLOC_DEFINE(M_TMPFSMNT, "tmpfs mount", "tmpfs mount structures"); 67MALLOC_DEFINE(M_TMPFSNAME, "tmpfs name", "tmpfs file names"); 68 69/* --------------------------------------------------------------------- */ 70 |
71static int tmpfs_mount(struct mount *, struct thread *); 72static int tmpfs_unmount(struct mount *, int, struct thread *); 73static int tmpfs_root(struct mount *, int flags, struct vnode **, 74 struct thread *); | 71static int tmpfs_mount(struct mount *); 72static int tmpfs_unmount(struct mount *, int); 73static int tmpfs_root(struct mount *, int flags, struct vnode **); |
75static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **); | 74static int tmpfs_fhtovp(struct mount *, struct fid *, struct vnode **); |
76static int tmpfs_statfs(struct mount *, struct statfs *, struct thread *); | 75static int tmpfs_statfs(struct mount *, struct statfs *); |
77 78/* --------------------------------------------------------------------- */ 79 80static const char *tmpfs_opts[] = { 81 "from", "size", "inodes", "uid", "gid", "mode", "export", 82 NULL 83}; 84 --- 88 unchanged lines hidden (view full) --- 173tmpfs_node_fini(void *mem, int size) 174{ 175 struct tmpfs_node *node = (struct tmpfs_node *)mem; 176 177 mtx_destroy(&node->tn_interlock); 178} 179 180static int | 76 77/* --------------------------------------------------------------------- */ 78 79static const char *tmpfs_opts[] = { 80 "from", "size", "inodes", "uid", "gid", "mode", "export", 81 NULL 82}; 83 --- 88 unchanged lines hidden (view full) --- 172tmpfs_node_fini(void *mem, int size) 173{ 174 struct tmpfs_node *node = (struct tmpfs_node *)mem; 175 176 mtx_destroy(&node->tn_interlock); 177} 178 179static int |
181tmpfs_mount(struct mount *mp, struct thread *td) | 180tmpfs_mount(struct mount *mp) |
182{ 183 struct tmpfs_mount *tmp; 184 struct tmpfs_node *root; 185 size_t pages, mem_size; 186 ino_t nodes; 187 int error; 188 /* Size counters. */ 189 ino_t nodes_max; --- 83 unchanged lines hidden (view full) --- 273 sizeof(struct tmpfs_node), 274 tmpfs_node_ctor, tmpfs_node_dtor, 275 tmpfs_node_init, tmpfs_node_fini, 276 UMA_ALIGN_PTR, 0); 277 278 /* Allocate the root node. */ 279 error = tmpfs_alloc_node(tmp, VDIR, root_uid, 280 root_gid, root_mode & ALLPERMS, NULL, NULL, | 181{ 182 struct tmpfs_mount *tmp; 183 struct tmpfs_node *root; 184 size_t pages, mem_size; 185 ino_t nodes; 186 int error; 187 /* Size counters. */ 188 ino_t nodes_max; --- 83 unchanged lines hidden (view full) --- 272 sizeof(struct tmpfs_node), 273 tmpfs_node_ctor, tmpfs_node_dtor, 274 tmpfs_node_init, tmpfs_node_fini, 275 UMA_ALIGN_PTR, 0); 276 277 /* Allocate the root node. */ 278 error = tmpfs_alloc_node(tmp, VDIR, root_uid, 279 root_gid, root_mode & ALLPERMS, NULL, NULL, |
281 VNOVAL, td, &root); | 280 VNOVAL, &root); |
282 283 if (error != 0 || root == NULL) { 284 uma_zdestroy(tmp->tm_node_pool); 285 uma_zdestroy(tmp->tm_dirent_pool); 286 delete_unrhdr(tmp->tm_ino_unr); 287 free(tmp, M_TMPFSMNT); 288 return error; 289 } --- 12 unchanged lines hidden (view full) --- 302 303 return 0; 304} 305 306/* --------------------------------------------------------------------- */ 307 308/* ARGSUSED2 */ 309static int | 281 282 if (error != 0 || root == NULL) { 283 uma_zdestroy(tmp->tm_node_pool); 284 uma_zdestroy(tmp->tm_dirent_pool); 285 delete_unrhdr(tmp->tm_ino_unr); 286 free(tmp, M_TMPFSMNT); 287 return error; 288 } --- 12 unchanged lines hidden (view full) --- 301 302 return 0; 303} 304 305/* --------------------------------------------------------------------- */ 306 307/* ARGSUSED2 */ 308static int |
310tmpfs_unmount(struct mount *mp, int mntflags, struct thread *l) | 309tmpfs_unmount(struct mount *mp, int mntflags) |
311{ 312 int error; 313 int flags = 0; 314 struct tmpfs_mount *tmp; 315 struct tmpfs_node *node; 316 317 /* Handle forced unmounts. */ 318 if (mntflags & MNT_FORCE) 319 flags |= FORCECLOSE; 320 321 /* Finalize all pending I/O. */ | 310{ 311 int error; 312 int flags = 0; 313 struct tmpfs_mount *tmp; 314 struct tmpfs_node *node; 315 316 /* Handle forced unmounts. */ 317 if (mntflags & MNT_FORCE) 318 flags |= FORCECLOSE; 319 320 /* Finalize all pending I/O. */ |
322 error = vflush(mp, 0, flags, l); | 321 error = vflush(mp, 0, flags, curthread); |
323 if (error != 0) 324 return error; 325 326 tmp = VFS_TO_TMPFS(mp); 327 328 /* Free all associated data. The loop iterates over the linked list 329 * we have containing all used nodes. For each of them that is 330 * a directory, we free all its directory entries. Note that after --- 38 unchanged lines hidden (view full) --- 369 mp->mnt_flag &= ~MNT_LOCAL; 370 MNT_IUNLOCK(mp); 371 return 0; 372} 373 374/* --------------------------------------------------------------------- */ 375 376static int | 322 if (error != 0) 323 return error; 324 325 tmp = VFS_TO_TMPFS(mp); 326 327 /* Free all associated data. The loop iterates over the linked list 328 * we have containing all used nodes. For each of them that is 329 * a directory, we free all its directory entries. Note that after --- 38 unchanged lines hidden (view full) --- 368 mp->mnt_flag &= ~MNT_LOCAL; 369 MNT_IUNLOCK(mp); 370 return 0; 371} 372 373/* --------------------------------------------------------------------- */ 374 375static int |
377tmpfs_root(struct mount *mp, int flags, struct vnode **vpp, struct thread *td) | 376tmpfs_root(struct mount *mp, int flags, struct vnode **vpp) |
378{ 379 int error; | 377{ 378 int error; |
380 error = tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, flags, vpp, td); | 379 error = tmpfs_alloc_vp(mp, VFS_TO_TMPFS(mp)->tm_root, flags, vpp); |
381 382 if (!error) 383 (*vpp)->v_vflag |= VV_ROOT; 384 385 return error; 386} 387 388/* --------------------------------------------------------------------- */ --- 23 unchanged lines hidden (view full) --- 412 node->tn_gen == tfhp->tf_gen) { 413 found = TRUE; 414 break; 415 } 416 } 417 TMPFS_UNLOCK(tmp); 418 419 if (found) | 380 381 if (!error) 382 (*vpp)->v_vflag |= VV_ROOT; 383 384 return error; 385} 386 387/* --------------------------------------------------------------------- */ --- 23 unchanged lines hidden (view full) --- 411 node->tn_gen == tfhp->tf_gen) { 412 found = TRUE; 413 break; 414 } 415 } 416 TMPFS_UNLOCK(tmp); 417 418 if (found) |
420 return (tmpfs_alloc_vp(mp, node, LK_EXCLUSIVE, vpp, curthread)); | 419 return (tmpfs_alloc_vp(mp, node, LK_EXCLUSIVE, vpp)); |
421 422 return (EINVAL); 423} 424 425/* --------------------------------------------------------------------- */ 426 427/* ARGSUSED2 */ 428static int | 420 421 return (EINVAL); 422} 423 424/* --------------------------------------------------------------------- */ 425 426/* ARGSUSED2 */ 427static int |
429tmpfs_statfs(struct mount *mp, struct statfs *sbp, struct thread *l) | 428tmpfs_statfs(struct mount *mp, struct statfs *sbp) |
430{ 431 fsfilcnt_t freenodes; 432 struct tmpfs_mount *tmp; 433 434 tmp = VFS_TO_TMPFS(mp); 435 436 sbp->f_iosize = PAGE_SIZE; 437 sbp->f_bsize = PAGE_SIZE; --- 28 unchanged lines hidden --- | 429{ 430 fsfilcnt_t freenodes; 431 struct tmpfs_mount *tmp; 432 433 tmp = VFS_TO_TMPFS(mp); 434 435 sbp->f_iosize = PAGE_SIZE; 436 sbp->f_bsize = PAGE_SIZE; --- 28 unchanged lines hidden --- |