1 /* $NetBSD: union.h,v 1.17 2008/01/02 11:48:47 ad Exp $ */
4 * Copyright (c) 1994 The Regents of the University of California.
7 * This code is derived from software donated to Berkeley by
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. Neither the name of the University nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * @(#)union.h 8.9 (Berkeley) 12/10/94
38 * Copyright (c) 1994 Jan-Simon Pendry.
39 * All rights reserved.
41 * This code is derived from software donated to Berkeley by
44 * Redistribution and use in source and binary forms, with or without
45 * modification, are permitted provided that the following conditions
47 * 1. Redistributions of source code must retain the above copyright
48 * notice, this list of conditions and the following disclaimer.
49 * 2. Redistributions in binary form must reproduce the above copyright
50 * notice, this list of conditions and the following disclaimer in the
51 * documentation and/or other materials provided with the distribution.
52 * 3. All advertising materials mentioning features or use of this software
53 * must display the following acknowledgement:
54 * This product includes software developed by the University of
55 * California, Berkeley and its contributors.
56 * 4. Neither the name of the University nor the names of its contributors
57 * may be used to endorse or promote products derived from this software
58 * without specific prior written permission.
60 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
61 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
62 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
63 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
64 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
65 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
66 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
67 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
68 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
69 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
72 * @(#)union.h 8.9 (Berkeley) 12/10/94
75 #ifndef _MISCFS_UNION_H_
76 #define _MISCFS_UNION_H_
79 char *target
; /* Target of loopback */
80 int mntflags
; /* Options on the mount */
83 #define UNMNT_ABOVE 0x0001 /* Target appears below mount point */
84 #define UNMNT_BELOW 0x0002 /* Target appears below mount point */
85 #define UNMNT_REPLACE 0x0003 /* Target replaces mount point */
86 #define UNMNT_OPMASK 0x0003
88 #define UNMNT_BITS "\177\20" \
89 "b\00above\0b\01below\0b\02replace\0"
94 struct vnode
*um_uppervp
;
95 struct vnode
*um_lowervp
;
96 kauth_cred_t um_cred
; /* Credentials of user calling mount */
97 int um_cmode
; /* cmask from mount process */
98 int um_op
; /* Operation mode */
102 * DEFDIRMODE is the mode bits used to create a shadow directory.
104 #define UN_DIRMODE (S_IRWXU|S_IRWXG|S_IRWXO)
105 #define UN_FILEMODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP|S_IROTH|S_IWOTH)
108 * A cache of vnode references
111 LIST_ENTRY(union_node
) un_cache
; /* Hash chain */
112 struct vnode
*un_vnode
; /* Back pointer */
113 struct vnode
*un_uppervp
; /* overlaying object */
114 struct vnode
*un_lowervp
; /* underlying object */
115 struct vnode
*un_dirvp
; /* Parent dir of uppervp */
116 struct vnode
*un_pvp
; /* Parent vnode */
117 char *un_path
; /* saved component name */
118 int un_hash
; /* saved un_path hash value */
119 int un_openl
; /* # of opens on lowervp */
120 unsigned int un_flags
;
121 struct vnode
**un_dircache
; /* cached union stack */
122 off_t un_uppersz
; /* size of upper object */
123 off_t un_lowersz
; /* size of lower object */
124 pid_t un_pid
; /* DIAGNOSTIC only */
127 #define UN_WANTED 0x01
128 #define UN_LOCKED 0x02
129 #define UN_ULOCK 0x04 /* Upper node is locked */
130 #define UN_KLOCK 0x08 /* Keep upper node locked on vput */
131 #define UN_CACHED 0x10 /* In union cache */
133 extern int union_allocvp(struct vnode
**, struct mount
*,
134 struct vnode
*, struct vnode
*,
135 struct componentname
*, struct vnode
*,
136 struct vnode
*, int);
137 extern int union_copyfile(struct vnode
*, struct vnode
*, kauth_cred_t
,
139 extern int union_copyup(struct union_node
*, int, kauth_cred_t
,
141 extern void union_diruncache(struct union_node
*);
142 extern int union_dowhiteout(struct union_node
*, kauth_cred_t
);
143 extern int union_mkshadow(struct union_mount
*, struct vnode
*,
144 struct componentname
*, struct vnode
**);
145 extern int union_mkwhiteout(struct union_mount
*, struct vnode
*,
146 struct componentname
*, char *);
147 extern int union_vn_create(struct vnode
**, struct union_node
*,
149 extern int union_cn_close(struct vnode
*, int, kauth_cred_t
,
151 extern void union_removed_upper(struct union_node
*un
);
152 extern struct vnode
*union_lowervp(struct vnode
*);
153 extern void union_newlower(struct union_node
*, struct vnode
*);
154 extern void union_newupper(struct union_node
*, struct vnode
*);
155 extern void union_newsize(struct vnode
*, off_t
, off_t
);
156 int union_readdirhook(struct vnode
**, struct file
*, struct lwp
*);
158 #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
159 #define VTOUNION(vp) ((struct union_node *)(vp)->v_data)
160 #define UNIONTOV(un) ((un)->un_vnode)
161 #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
162 #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
163 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
165 extern int (**union_vnodeop_p
)(void *);
167 void union_init(void);
168 void union_done(void);
169 int union_freevp(struct vnode
*);
172 #endif /* _MISCFS_UNION_H_ */