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