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 * %sccs.include.redist.c% 10 * 11 * @(#)union.h 1.7 (Berkeley) 02/07/94 12 */ 13 14 struct union_args { 15 char *target; /* Target of loopback */ 16 }; 17 18 struct union_mount { 19 struct vnode *um_uppervp; 20 struct vnode *um_lowervp; 21 struct ucred *um_cred; /* Credentials of user calling mount */ 22 int um_cmode; /* cmask from mount process */ 23 }; 24 25 #ifdef KERNEL 26 27 /* 28 * DEFDIRMODE is the mode bits used to create a shadow directory. 29 */ 30 #define VRWXMODE (VREAD|VWRITE|VEXEC) 31 #define VRWMODE (VREAD|VWRITE) 32 #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6)) 33 #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6)) 34 35 /* 36 * A cache of vnode references 37 */ 38 struct union_node { 39 struct union_node *un_next; /* Hash chain */ 40 struct vnode *un_vnode; /* Back pointer */ 41 struct vnode *un_uppervp; /* overlaying object */ 42 struct vnode *un_lowervp; /* underlying object */ 43 struct vnode *un_dirvp; /* Parent dir of uppervp */ 44 char *un_path; /* saved component name */ 45 int un_hash; /* saved un_path hash value */ 46 int un_openl; /* # of opens on lowervp */ 47 int un_flags; 48 #ifdef DIAGNOSTIC 49 pid_t un_pid; 50 #endif 51 }; 52 53 #define UN_WANT 0x01 54 #define UN_LOCKED 0x02 55 56 extern int union_allocvp __P((struct vnode **, struct mount *, 57 struct vnode *, struct vnode *, 58 struct componentname *, struct vnode *, 59 struct vnode *)); 60 extern int union_copyfile __P((struct proc *, struct ucred *, 61 struct vnode *, struct vnode *)); 62 extern int union_mkshadow __P((struct union_mount *, struct vnode *, 63 struct componentname *, struct vnode **)); 64 extern int union_vn_create __P((struct vnode **, struct union_node *, 65 struct proc *)); 66 extern void union_removed_upper __P((struct union_node *un)); 67 68 #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) 69 #define VTOUNION(vp) ((struct union_node *)(vp)->v_data) 70 #define UNIONTOV(un) ((un)->un_vnode) 71 #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) 72 #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) 73 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) 74 75 extern int (**union_vnodeop_p)(); 76 extern struct vfsops union_vfsops; 77 #endif /* KERNEL */ 78