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.6 (Berkeley) 02/04/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_open; /* # of opens on lowervp */ 46 int un_flags; 47 pid_t un_pid; 48 }; 49 50 #define UN_WANT 0x01 51 #define UN_LOCKED 0x02 52 53 extern int union_allocvp __P((struct vnode **, struct mount *, 54 struct vnode *, struct vnode *, 55 struct componentname *, struct vnode *, 56 struct vnode *)); 57 extern int union_copyfile __P((struct proc *, struct ucred *, 58 struct vnode *, struct vnode *)); 59 extern int union_mkshadow __P((struct union_mount *, struct vnode *, 60 struct componentname *, struct vnode **)); 61 extern int union_vn_create __P((struct vnode **, struct union_node *, 62 struct proc *)); 63 64 #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) 65 #define VTOUNION(vp) ((struct union_node *)(vp)->v_data) 66 #define UNIONTOV(un) ((un)->un_vnode) 67 #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) 68 #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) 69 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) 70 71 extern int (**union_vnodeop_p)(); 72 extern struct vfsops union_vfsops; 73 #endif /* KERNEL */ 74