Deleted Added
full compact
tmpfs_vfsops.c (173570) tmpfs_vfsops.c (173724)
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

--- 34 unchanged lines hidden (view full) ---

43 * tmpfs is a file system that uses NetBSD's virtual memory sub-system
44 * (the well-known UVM) to store file data and metadata in an efficient
45 * way. This means that it does not follow the structure of an on-disk
46 * file system because it simply does not need to. Instead, it uses
47 * memory-specific data structures and algorithms to automatically
48 * allocate and release resources.
49 */
50#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

--- 34 unchanged lines hidden (view full) ---

43 * tmpfs is a file system that uses NetBSD's virtual memory sub-system
44 * (the well-known UVM) to store file data and metadata in an efficient
45 * way. This means that it does not follow the structure of an on-disk
46 * file system because it simply does not need to. Instead, it uses
47 * memory-specific data structures and algorithms to automatically
48 * allocate and release resources.
49 */
50#include <sys/cdefs.h>
51__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 173570 2007-11-12 18:57:33Z delphij $");
51__FBSDID("$FreeBSD: head/sys/fs/tmpfs/tmpfs_vfsops.c 173724 2007-11-18 04:40:42Z delphij $");
52
53#include <sys/param.h>
54#include <sys/limits.h>
55#include <sys/lock.h>
56#include <sys/mutex.h>
57#include <sys/kernel.h>
58#include <sys/stat.h>
59#include <sys/systm.h>

--- 151 unchanged lines hidden (view full) ---

211 if (mp->mnt_flag & MNT_UPDATE) {
212 /* XXX: There is no support yet to update file system
213 * settings. Should be added. */
214
215 return EOPNOTSUPP;
216 }
217
218 printf("WARNING: TMPFS is considered to be a highly experimental "
52
53#include <sys/param.h>
54#include <sys/limits.h>
55#include <sys/lock.h>
56#include <sys/mutex.h>
57#include <sys/kernel.h>
58#include <sys/stat.h>
59#include <sys/systm.h>

--- 151 unchanged lines hidden (view full) ---

211 if (mp->mnt_flag & MNT_UPDATE) {
212 /* XXX: There is no support yet to update file system
213 * settings. Should be added. */
214
215 return EOPNOTSUPP;
216 }
217
218 printf("WARNING: TMPFS is considered to be a highly experimental "
219 "feature in FreeBSD.\n");
219 "feature in FreeBSD.\n");
220
221 vn_lock(mp->mnt_vnodecovered, LK_SHARED | LK_RETRY, td);
222 error = VOP_GETATTR(mp->mnt_vnodecovered, &va, mp->mnt_cred, td);
223 VOP_UNLOCK(mp->mnt_vnodecovered, 0, td);
224 if (error)
225 return (error);
226
227 if (mp->mnt_cred->cr_ruid != 0 ||
228 vfs_scanopt(mp->mnt_optnew, "gid", "%d", &root_gid) != 1)
229 root_gid = va.va_gid;
230 if (mp->mnt_cred->cr_ruid != 0 ||
231 vfs_scanopt(mp->mnt_optnew, "uid", "%d", &root_uid) != 1)
232 root_uid = va.va_uid;
233 if (mp->mnt_cred->cr_ruid != 0 ||
234 vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1)
235 root_mode = va.va_mode;
220
221 vn_lock(mp->mnt_vnodecovered, LK_SHARED | LK_RETRY, td);
222 error = VOP_GETATTR(mp->mnt_vnodecovered, &va, mp->mnt_cred, td);
223 VOP_UNLOCK(mp->mnt_vnodecovered, 0, td);
224 if (error)
225 return (error);
226
227 if (mp->mnt_cred->cr_ruid != 0 ||
228 vfs_scanopt(mp->mnt_optnew, "gid", "%d", &root_gid) != 1)
229 root_gid = va.va_gid;
230 if (mp->mnt_cred->cr_ruid != 0 ||
231 vfs_scanopt(mp->mnt_optnew, "uid", "%d", &root_uid) != 1)
232 root_uid = va.va_uid;
233 if (mp->mnt_cred->cr_ruid != 0 ||
234 vfs_scanopt(mp->mnt_optnew, "mode", "%ho", &root_mode) != 1)
235 root_mode = va.va_mode;
236 if(vfs_scanopt(mp->mnt_optnew, "inodes", "%d", &nodes_max) != 1)
236 if (vfs_scanopt(mp->mnt_optnew, "inodes", "%d", &nodes_max) != 1)
237 nodes_max = 0;
237 nodes_max = 0;
238
239 if(vfs_scanopt(mp->mnt_optnew,
240 "size",
241 "%qu", &size_max) != 1)
238 if (vfs_scanopt(mp->mnt_optnew, "size", "%qu", &size_max) != 1)
242 size_max = 0;
243
244 /* Do not allow mounts if we do not have enough memory to preserve
245 * the minimum reserved pages. */
246 mem_size = cnt.v_free_count + cnt.v_inactive_count + get_swpgtotal();
247 mem_size -= mem_size > cnt.v_wire_count ? cnt.v_wire_count : mem_size;
248 if (mem_size < TMPFS_PAGES_RESERVED)
249 return ENOSPC;

--- 22 unchanged lines hidden (view full) ---

272 tmp->tm_nodes_max = nodes;
273 tmp->tm_nodes_inuse = 0;
274 tmp->tm_maxfilesize = (u_int64_t)(cnt.v_page_count + get_swpgtotal()) * PAGE_SIZE;
275 LIST_INIT(&tmp->tm_nodes_used);
276
277 tmp->tm_pages_max = pages;
278 tmp->tm_pages_used = 0;
279 tmp->tm_ino_unr = new_unrhdr(2, INT_MAX, &tmp->allnode_lock);
239 size_max = 0;
240
241 /* Do not allow mounts if we do not have enough memory to preserve
242 * the minimum reserved pages. */
243 mem_size = cnt.v_free_count + cnt.v_inactive_count + get_swpgtotal();
244 mem_size -= mem_size > cnt.v_wire_count ? cnt.v_wire_count : mem_size;
245 if (mem_size < TMPFS_PAGES_RESERVED)
246 return ENOSPC;

--- 22 unchanged lines hidden (view full) ---

269 tmp->tm_nodes_max = nodes;
270 tmp->tm_nodes_inuse = 0;
271 tmp->tm_maxfilesize = (u_int64_t)(cnt.v_page_count + get_swpgtotal()) * PAGE_SIZE;
272 LIST_INIT(&tmp->tm_nodes_used);
273
274 tmp->tm_pages_max = pages;
275 tmp->tm_pages_used = 0;
276 tmp->tm_ino_unr = new_unrhdr(2, INT_MAX, &tmp->allnode_lock);
280 tmp->tm_dirent_pool = uma_zcreate(
281 "TMPFS dirent",
282 sizeof(struct tmpfs_dirent),
283 NULL, NULL, NULL, NULL,
284 UMA_ALIGN_PTR,
285 0);
286 tmp->tm_node_pool = uma_zcreate(
287 "TMPFS node",
288 sizeof(struct tmpfs_node),
289 tmpfs_node_ctor, tmpfs_node_dtor,
290 tmpfs_node_init, tmpfs_node_fini,
291 UMA_ALIGN_PTR,
292 0);
277 tmp->tm_dirent_pool = uma_zcreate("TMPFS dirent",
278 sizeof(struct tmpfs_dirent),
279 NULL, NULL, NULL, NULL,
280 UMA_ALIGN_PTR, 0);
281 tmp->tm_node_pool = uma_zcreate("TMPFS node",
282 sizeof(struct tmpfs_node),
283 tmpfs_node_ctor, tmpfs_node_dtor,
284 tmpfs_node_init, tmpfs_node_fini,
285 UMA_ALIGN_PTR, 0);
293
294 /* Allocate the root node. */
295 error = tmpfs_alloc_node(tmp, VDIR, root_uid,
296 root_gid, root_mode & ALLPERMS, NULL, NULL,
297 VNOVAL, td, &root);
298
299 if (error != 0 || root == NULL) {
300 uma_zdestroy(tmp->tm_node_pool);

--- 181 unchanged lines hidden ---
286
287 /* Allocate the root node. */
288 error = tmpfs_alloc_node(tmp, VDIR, root_uid,
289 root_gid, root_mode & ALLPERMS, NULL, NULL,
290 VNOVAL, td, &root);
291
292 if (error != 0 || root == NULL) {
293 uma_zdestroy(tmp->tm_node_pool);

--- 181 unchanged lines hidden ---