2 * Copyright (c) 2012 Apple Inc. All rights reserved.
4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
6 * This file contains Original Code and/or Modifications of Original Code
7 * as defined in and that are subject to the Apple Public Source License
8 * Version 2.0 (the 'License'). You may not use this file except in
9 * compliance with the License. The rights granted to you under the License
10 * may not be used to create, or enable the creation or redistribution of,
11 * unlawful or unlicensed copies of an Apple operating system, or to
12 * circumvent, violate, or enable the circumvention or violation of, any
13 * terms of an Apple operating system software license agreement.
15 * Please obtain a copy of the License at
16 * http://www.opensource.apple.com/apsl/ and read it before using this file.
18 * The Original Code and all software distributed under the License are
19 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
22 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
23 * Please see the License for the specific language governing rights and
24 * limitations under the License.
26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
34 #include <kern/locks.h>
35 #include <miscfs/mockfs/mockfs_fsnode.h>
36 #include <sys/kernel_types.h>
39 * mockfs is effectively a "fake" filesystem; the primary motivation for it being that we may have cases
40 * where our userspace needs are extremely simple/consistent and can provided by a single binary. mockfs
41 * uses an in-memory tree to define the structure for an extremely simple filesystem, which makes the
42 * assumption that our root device is in fact a mach-o file, and provides a minimal filesystem to support
43 * this: the root directory, a mountpoint for devfs (given that very basic userspace code may assume the
44 * existance of /dev/), and an executable representing the root device.
46 * The functionality supported by mockfs is minimal: it is read-only, and does not support user initiated IO,
47 * but it supports lookup (so it should be possible for the user to access /dev/).
49 * mockfs is primarily targeted towards memory-backed devices, and will (when possible) attempt to inform the
50 * VM that we are using a memory-backed device, so that we can eschew IO to the backing device completely,
51 * and avoid having an extra copy of the data in the UBC (as well as the overhead associated with creating
54 * For the moment, mockfs is not marked in vfs_conf.c as being threadsafe.
58 lck_mtx_t mockfs_mnt_mtx
; /* Mount-wide (and tree-wide) mutex */
59 mockfs_fsnode_t mockfs_root
; /* Root of the node tree */
60 boolean_t mockfs_memory_backed
; /* Does the backing store reside in memory */
61 boolean_t mockfs_physical_memory
; /* (valid if memory backed) */
62 uint32_t mockfs_memdev_base
; /* Base page of the backing store (valid if memory backed) */
63 uint64_t mockfs_memdev_size
; /* Size of the backing store (valid if memory backed) */
66 typedef struct mockfs_mount
* mockfs_mount_t
;