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