union.h (50477) | union.h (51688) |
---|---|
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 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)union.h 8.9 (Berkeley) 12/10/94 | 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 * --- 21 unchanged lines hidden (view full) --- 30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35 * SUCH DAMAGE. 36 * 37 * @(#)union.h 8.9 (Berkeley) 12/10/94 |
38 * $FreeBSD: head/sys/fs/unionfs/union.h 50477 1999-08-28 01:08:13Z peter $ | 38 * $FreeBSD: head/sys/fs/unionfs/union.h 51688 1999-09-26 20:52:41Z dillon $ |
39 */ 40 41struct union_args { 42 char *target; /* Target of loopback */ 43 int mntflags; /* Options on the mount */ 44}; 45 46#define UNMNT_ABOVE 0x0001 /* Target appears below mount point */ 47#define UNMNT_BELOW 0x0002 /* Target appears below mount point */ 48#define UNMNT_REPLACE 0x0003 /* Target replaces mount point */ 49#define UNMNT_OPMASK 0x0003 50 51struct union_mount { | 39 */ 40 41struct union_args { 42 char *target; /* Target of loopback */ 43 int mntflags; /* Options on the mount */ 44}; 45 46#define UNMNT_ABOVE 0x0001 /* Target appears below mount point */ 47#define UNMNT_BELOW 0x0002 /* Target appears below mount point */ 48#define UNMNT_REPLACE 0x0003 /* Target replaces mount point */ 49#define UNMNT_OPMASK 0x0003 50 51struct union_mount { |
52 struct vnode *um_uppervp; 53 struct vnode *um_lowervp; | 52 struct vnode *um_uppervp; /* UN_ULOCK holds locking state */ 53 struct vnode *um_lowervp; /* Left unlocked */ |
54 struct ucred *um_cred; /* Credentials of user calling mount */ 55 int um_cmode; /* cmask from mount process */ 56 int um_op; /* Operation mode */ 57}; 58 59#ifdef KERNEL 60 | 54 struct ucred *um_cred; /* Credentials of user calling mount */ 55 int um_cmode; /* cmask from mount process */ 56 int um_op; /* Operation mode */ 57}; 58 59#ifdef KERNEL 60 |
61#ifndef DIAGNOSTIC 62#define DIAGNOSTIC 63#endif 64 |
|
61/* 62 * DEFDIRMODE is the mode bits used to create a shadow directory. 63 */ 64#define VRWXMODE (VREAD|VWRITE|VEXEC) 65#define VRWMODE (VREAD|VWRITE) 66#define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6)) 67#define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6)) 68 69/* | 65/* 66 * DEFDIRMODE is the mode bits used to create a shadow directory. 67 */ 68#define VRWXMODE (VREAD|VWRITE|VEXEC) 69#define VRWMODE (VREAD|VWRITE) 70#define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6)) 71#define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6)) 72 73/* |
70 * A cache of vnode references | 74 * A cache of vnode references (hangs off v_data) 75 * 76 * Placing un_lock as the first elements theoretically allows us to 77 * use the vop_stdlock functions. However, we need to make sure of 78 * certain side effects so we will still punch in our own code. |
71 */ 72struct union_node { | 79 */ 80struct union_node { |
81 struct lock un_lock; |
|
73 LIST_ENTRY(union_node) un_cache; /* Hash chain */ 74 struct vnode *un_vnode; /* Back pointer */ 75 struct vnode *un_uppervp; /* overlaying object */ 76 struct vnode *un_lowervp; /* underlying object */ 77 struct vnode *un_dirvp; /* Parent dir of uppervp */ 78 struct vnode *un_pvp; /* Parent vnode */ 79 char *un_path; /* saved component name */ 80 int un_hash; /* saved un_path hash value */ 81 int un_openl; /* # of opens on lowervp */ | 82 LIST_ENTRY(union_node) un_cache; /* Hash chain */ 83 struct vnode *un_vnode; /* Back pointer */ 84 struct vnode *un_uppervp; /* overlaying object */ 85 struct vnode *un_lowervp; /* underlying object */ 86 struct vnode *un_dirvp; /* Parent dir of uppervp */ 87 struct vnode *un_pvp; /* Parent vnode */ 88 char *un_path; /* saved component name */ 89 int un_hash; /* saved un_path hash value */ 90 int un_openl; /* # of opens on lowervp */ |
91 int un_exclcnt; /* exclusive count */ |
|
82 unsigned int un_flags; 83 struct vnode **un_dircache; /* cached union stack */ 84 off_t un_uppersz; /* size of upper object */ 85 off_t un_lowersz; /* size of lower object */ 86#ifdef DIAGNOSTIC 87 pid_t un_pid; 88#endif 89}; 90 | 92 unsigned int un_flags; 93 struct vnode **un_dircache; /* cached union stack */ 94 off_t un_uppersz; /* size of upper object */ 95 off_t un_lowersz; /* size of lower object */ 96#ifdef DIAGNOSTIC 97 pid_t un_pid; 98#endif 99}; 100 |
91#define UN_WANT 0x01 92#define UN_LOCKED 0x02 93#define UN_ULOCK 0x04 /* Upper node is locked */ 94#define UN_KLOCK 0x08 /* Keep upper node locked on vput */ 95#define UN_CACHED 0x10 /* In union cache */ | 101/* 102 * XXX UN_ULOCK - indicates that the uppervp is locked 103 * 104 * UN_CACHED - node is in the union cache 105 */ |
96 | 106 |
107/*#define UN_ULOCK 0x04*/ /* Upper node is locked */ 108#define UN_CACHED 0x10 /* In union cache */ 109 110/* 111 * Hash table locking flags 112 */ 113 114#define UNVP_WANT 0x01 115#define UNVP_LOCKED 0x02 116 |
|
97extern int union_allocvp __P((struct vnode **, struct mount *, | 117extern int union_allocvp __P((struct vnode **, struct mount *, |
98 struct vnode *, struct vnode *, | 118 struct vnode *, 119 struct vnode *, |
99 struct componentname *, struct vnode *, 100 struct vnode *, int)); 101extern int union_freevp __P((struct vnode *)); 102extern struct vnode *union_dircache __P((struct vnode *, struct proc *)); 103extern int union_copyup __P((struct union_node *, int, struct ucred *, 104 struct proc *)); 105extern int union_dowhiteout __P((struct union_node *, struct ucred *, 106 struct proc *)); 107extern int union_mkshadow __P((struct union_mount *, struct vnode *, 108 struct componentname *, struct vnode **)); 109extern int union_mkwhiteout __P((struct union_mount *, struct vnode *, 110 struct componentname *, char *)); 111extern int union_cn_close __P((struct vnode *, int, struct ucred *, 112 struct proc *)); 113extern void union_removed_upper __P((struct union_node *un)); 114extern struct vnode *union_lowervp __P((struct vnode *)); 115extern void union_newsize __P((struct vnode *, off_t, off_t)); | 120 struct componentname *, struct vnode *, 121 struct vnode *, int)); 122extern int union_freevp __P((struct vnode *)); 123extern struct vnode *union_dircache __P((struct vnode *, struct proc *)); 124extern int union_copyup __P((struct union_node *, int, struct ucred *, 125 struct proc *)); 126extern int union_dowhiteout __P((struct union_node *, struct ucred *, 127 struct proc *)); 128extern int union_mkshadow __P((struct union_mount *, struct vnode *, 129 struct componentname *, struct vnode **)); 130extern int union_mkwhiteout __P((struct union_mount *, struct vnode *, 131 struct componentname *, char *)); 132extern int union_cn_close __P((struct vnode *, int, struct ucred *, 133 struct proc *)); 134extern void union_removed_upper __P((struct union_node *un)); 135extern struct vnode *union_lowervp __P((struct vnode *)); 136extern void union_newsize __P((struct vnode *, off_t, off_t)); |
137extern void union_vm_coherency __P((struct vnode *, struct uio *, int)); |
|
116 117extern int (*union_dircheckp) __P((struct proc *, struct vnode **, 118 struct file *)); 119 120#define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) 121#define VTOUNION(vp) ((struct union_node *)(vp)->v_data) 122#define UNIONTOV(un) ((un)->un_vnode) 123#define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) 124#define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) 125#define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) 126 | 138 139extern int (*union_dircheckp) __P((struct proc *, struct vnode **, 140 struct file *)); 141 142#define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) 143#define VTOUNION(vp) ((struct union_node *)(vp)->v_data) 144#define UNIONTOV(un) ((un)->un_vnode) 145#define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) 146#define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) 147#define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) 148 |
149#define UDEBUG(x) if (uniondebug) printf x 150#define UDEBUG_ENABLED 1 151 |
|
127extern vop_t **union_vnodeop_p; 128extern struct vfsops union_vfsops; | 152extern vop_t **union_vnodeop_p; 153extern struct vfsops union_vfsops; |
154extern int uniondebug; 155 |
|
129#endif /* KERNEL */ | 156#endif /* KERNEL */ |