]>
git.saurik.com Git - apple/xnu.git/blob - bsd/miscfs/union/union.h
b603cd14cd5591f9a91d1a8d1c1561fce2d0c7e7
2 * Copyright (c) 2006 Apple Computer, Inc. All Rights Reserved.
4 * @APPLE_LICENSE_OSREFERENCE_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
10 * License may not be used to create, or enable the creation or
11 * redistribution of, unlawful or unlicensed copies of an Apple operating
12 * system, or to circumvent, violate, or enable the circumvention or
13 * violation of, any terms of an Apple operating system software license
16 * Please obtain a copy of the License at
17 * http://www.opensource.apple.com/apsl/ and read it before using this
20 * The Original Code and all software distributed under the License are
21 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
22 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
23 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
24 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
25 * Please see the License for the specific language governing rights and
26 * limitations under the License.
28 * @APPLE_LICENSE_OSREFERENCE_HEADER_END@
30 /* Copyright (c) 1995 NeXT Computer, Inc. All Rights Reserved */
32 * Copyright (c) 1994 The Regents of the University of California.
33 * Copyright (c) 1994 Jan-Simon Pendry.
34 * All rights reserved.
36 * This code is derived from software donated to Berkeley by
39 * Redistribution and use in source and binary forms, with or without
40 * modification, are permitted provided that the following conditions
42 * 1. Redistributions of source code must retain the above copyright
43 * notice, this list of conditions and the following disclaimer.
44 * 2. Redistributions in binary form must reproduce the above copyright
45 * notice, this list of conditions and the following disclaimer in the
46 * documentation and/or other materials provided with the distribution.
47 * 3. All advertising materials mentioning features or use of this software
48 * must display the following acknowledgement:
49 * This product includes software developed by the University of
50 * California, Berkeley and its contributors.
51 * 4. Neither the name of the University nor the names of its contributors
52 * may be used to endorse or promote products derived from this software
53 * without specific prior written permission.
55 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
56 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
57 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
58 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
59 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
60 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
61 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
62 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
63 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
64 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
67 * @(#)union.h 8.9 (Berkeley) 12/10/94
69 #ifndef __UNION_UNION_H__
70 #define __UNION_UNION_H__
72 #include <sys/appleapiopts.h>
73 #include <sys/cdefs.h>
75 #ifdef __APPLE_API_PRIVATE
77 char *target
; /* Target of loopback */
78 int mntflags
; /* Options on the mount */
81 #define UNMNT_ABOVE 0x0001 /* Target appears below mount point */
82 #define UNMNT_BELOW 0x0002 /* Target appears below mount point */
83 #define UNMNT_REPLACE 0x0003 /* Target replaces mount point */
84 #define UNMNT_OPMASK 0x0003
87 struct vnode
*um_uppervp
;
88 struct vnode
*um_lowervp
;
89 struct ucred
*um_cred
; /* Credentials of user calling mount */
90 int um_cmode
; /* cmask from mount process */
91 int um_op
; /* Operation mode */
95 /* LP64 version of union_args. all pointers
96 * grow when we're dealing with a 64-bit process.
97 * WARNING - keep in sync with union_args
99 /* LP64todo - should this move? */
101 #if __DARWIN_ALIGN_NATURAL
102 #pragma options align=natural
105 struct user_union_args
{
106 user_addr_t target
; /* Target of loopback */
107 int mntflags
; /* Options on the mount */
110 #if __DARWIN_ALIGN_NATURAL
111 #pragma options align=reset
115 * DEFDIRMODE is the mode bits used to create a shadow directory.
117 #define VRWXMODE (VREAD|VWRITE|VEXEC)
118 #define VRWMODE (VREAD|VWRITE)
119 #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
120 #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
123 * A cache of vnode references
126 LIST_ENTRY(union_node
) un_cache
; /* Hash chain */
127 struct vnode
*un_vnode
; /* Back pointer */
128 struct vnode
*un_uppervp
; /* overlaying object */
129 struct vnode
*un_lowervp
; /* underlying object */
130 struct vnode
*un_dirvp
; /* Parent dir of uppervp */
131 struct vnode
*un_pvp
; /* Parent vnode */
132 char *un_path
; /* saved component name */
133 int un_hash
; /* saved un_path hash value */
134 int un_openl
; /* # of opens on lowervp */
135 unsigned int un_flags
;
136 struct vnode
**un_dircache
; /* cached union stack */
137 off_t un_uppersz
; /* size of upper object */
138 off_t un_lowersz
; /* size of lower object */
145 #define UN_LOCKED 0x02
146 #define UN_ULOCK 0x04 /* Upper node is locked */
147 #define UN_KLOCK 0x08 /* Keep upper node locked on vput */
148 #define UN_CACHED 0x10 /* In union cache */
150 extern int union_allocvp(struct vnode
**, struct mount
*,
151 struct vnode
*, struct vnode
*,
152 struct componentname
*, struct vnode
*,
153 struct vnode
*, int);
154 extern int union_copyfile(struct vnode
*, struct vnode
*,
155 struct ucred
*, struct proc
*);
156 extern int union_copyup(struct union_node
*, int, struct ucred
*,
158 extern int union_dowhiteout(struct union_node
*, vfs_context_t
);
159 extern int union_mkshadow(struct union_mount
*, struct vnode
*,
160 struct componentname
*, struct vnode
**);
161 extern int union_mkwhiteout(struct union_mount
*, struct vnode
*,
162 struct componentname
*, char *);
163 extern int union_vn_create(struct vnode
**, struct union_node
*, struct proc
*);
164 extern int union_cn_close(struct vnode
*, int, struct ucred
*, struct proc
*);
165 extern void union_removed_upper(struct union_node
*un
);
166 extern struct vnode
*union_lowervp(struct vnode
*);
167 extern void union_newlower(struct union_node
*, struct vnode
*);
168 extern void union_newupper(struct union_node
*, struct vnode
*);
169 extern void union_newsize(struct vnode
*, off_t
, off_t
);
171 #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
172 #define VTOUNION(vp) ((struct union_node *)(vp)->v_data)
173 #define UNIONTOV(un) ((un)->un_vnode)
174 #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
175 #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
176 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
178 extern int (**union_vnodeop_p
)(void *);
179 extern struct vfsops union_vfsops
;
182 #endif /* __APPLE_API_PRIVATE */
183 #endif /* __UNION_UNION_H__ */