xref: /original-bsd/sys/miscfs/union/union.h (revision 9979a570)
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.5 (Berkeley) 02/03/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 };
23 
24 /* begin XXX */
25 #define VT_UNION VT_LOFS
26 /*#define MOUNT_UNION 15*/
27 /* end XXX */
28 
29 #ifdef KERNEL
30 
31 /*
32  * DEFDIRMODE is the mode bits used to create a shadow directory.
33  */
34 #define VRWXMODE (VREAD|VWRITE|VEXEC)
35 #define VRWMODE (VREAD|VWRITE)
36 #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
37 #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
38 
39 /*
40  * A cache of vnode references
41  */
42 struct union_node {
43 	struct union_node	*un_next;	/* Hash chain */
44 	struct vnode		*un_vnode;	/* Back pointer */
45 	struct vnode	        *un_uppervp;	/* overlaying object */
46 	struct vnode	        *un_lowervp;	/* underlying object */
47 	struct vnode		*un_dirvp;	/* Parent dir of uppervp */
48 	char			*un_path;	/* saved component name */
49 	int			un_flags;
50 	pid_t			un_pid;
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_vn_create __P((struct vnode **, struct union_node *,
63 				int, struct proc *));
64 
65 #define	MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data))
66 #define	VTOUNION(vp) ((struct union_node *)(vp)->v_data)
67 #define	UNIONTOV(un) ((un)->un_vnode)
68 #define	LOWERVP(vp) (VTOUNION(vp)->un_lowervp)
69 #define	UPPERVP(vp) (VTOUNION(vp)->un_uppervp)
70 #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp))
71 
72 extern int (**union_vnodeop_p)();
73 extern struct vfsops union_vfsops;
74 #endif /* KERNEL */
75