FreeBSD/Linux Kernel Cross Reference
sys/fs/unionfs/union.h
1 /*-
2 * Copyright (c) 1994 The Regents of the University of California.
3 * Copyright (c) 1994 Jan-Simon Pendry.
4 * All rights reserved.
5 *
6 * This code is derived from software donated to Berkeley by
7 * Jan-Simon Pendry.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
20 *
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * @(#)union.h 8.9 (Berkeley) 12/10/94
34 * $FreeBSD$
35 */
36
37 #define UNMNT_ABOVE 0x0001 /* Target appears above mount point */
38 #define UNMNT_BELOW 0x0002 /* Target appears below mount point */
39 #define UNMNT_REPLACE 0x0003 /* Target replaces mount point */
40
41 struct union_mount {
42 struct vnode *um_uppervp; /* UN_ULOCK holds locking state */
43 struct vnode *um_lowervp; /* Left unlocked */
44 struct ucred *um_cred; /* Credentials of user calling mount */
45 int um_cmode; /* cmask from mount process */
46 int um_op; /* Operation mode */
47 };
48
49 #ifdef _KERNEL
50
51 #ifndef DIAGNOSTIC
52 #define DIAGNOSTIC
53 #endif
54
55 /*
56 * DEFDIRMODE is the mode bits used to create a shadow directory.
57 */
58 #define VRWXMODE (VREAD|VWRITE|VEXEC)
59 #define VRWMODE (VREAD|VWRITE)
60 #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
61 #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
62
63 /*
64 * A cache of vnode references (hangs off v_data)
65 */
66 struct union_node {
67 LIST_ENTRY(union_node) un_cache; /* Hash chain */
68 struct vnode *un_vnode; /* Back pointer */
69 struct vnode *un_uppervp; /* overlaying object */
70 struct vnode *un_lowervp; /* underlying object */
71 struct vnode *un_dirvp; /* Parent dir of uppervp */
72 struct vnode *un_pvp; /* Parent vnode */
73 char *un_path; /* saved component name */
74 int un_openl; /* # of opens on lowervp */
75 int un_exclcnt; /* exclusive count */
76 unsigned int un_flags;
77 struct vnode **un_dircache; /* cached union stack */
78 off_t un_uppersz; /* size of upper object */
79 off_t un_lowersz; /* size of lower object */
80 #ifdef DIAGNOSTIC
81 pid_t un_pid;
82 #endif
83 };
84
85 /*
86 * XXX UN_ULOCK - indicates that the uppervp is locked
87 *
88 * UN_CACHED - node is in the union cache
89 */
90
91 /*#define UN_ULOCK 0x04*/ /* Upper node is locked */
92 #define UN_CACHED 0x10 /* In union cache */
93
94 /*
95 * Hash table locking flags
96 */
97
98 #define UNVP_WANT 0x01
99 #define UNVP_LOCKED 0x02
100
101 extern int union_allocvp(struct vnode **, struct mount *,
102 struct vnode *,
103 struct vnode *,
104 struct componentname *, struct vnode *,
105 struct vnode *, int);
106 extern int union_freevp(struct vnode *);
107 extern struct vnode *union_dircache_get(struct vnode *, struct thread *);
108 extern void union_dircache_free(struct union_node *);
109 extern int union_copyup(struct union_node *, int, struct ucred *,
110 struct thread *);
111 extern int union_dowhiteout(struct union_node *, struct ucred *,
112 struct thread *);
113 extern int union_mkshadow(struct union_mount *, struct vnode *,
114 struct componentname *, struct vnode **);
115 extern int union_mkwhiteout(struct union_mount *, struct vnode *,
116 struct componentname *, char *);
117 extern int union_cn_close(struct vnode *, int, struct ucred *,
118 struct thread *);
119 extern void union_removed_upper(struct union_node *un);
120 extern struct vnode *union_lowervp(struct vnode *);
121 extern void union_newsize(struct vnode *, off_t, off_t);
122
123 extern int (*union_dircheckp)(struct thread *, struct vnode **,
124 struct file *);
125
126 #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
127 #define VTOUNION(vp) ((struct union_node *)(vp)->v_data)
128 #define UNIONTOV(un) ((un)->un_vnode)
129 #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
130 #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
131 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
132
133 #define UDEBUG(x) if (uniondebug) printf x
134 #define UDEBUG_ENABLED 1
135
136 extern vop_t **union_vnodeop_p;
137 extern struct vfsops union_vfsops;
138 extern int uniondebug;
139
140 #endif /* _KERNEL */
Cache object: 125dd8837e4cef17834c651caf8ee28d
|