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