Commit | Line | Data |
---|---|---|
cad9958b JSP |
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 | * | |
58572fc0 | 11 | * @(#)union.h 2.2 (Berkeley) %G% |
cad9958b JSP |
12 | */ |
13 | ||
14 | struct union_args { | |
15 | char *target; /* Target of loopback */ | |
692a90df | 16 | int mntflags; /* Options on the mount */ |
cad9958b JSP |
17 | }; |
18 | ||
692a90df JSP |
19 | #define UNMNT_ABOVE 0x0001 /* Target appears below mount point */ |
20 | #define UNMNT_BELOW 0x0002 /* Target appears below mount point */ | |
21 | #define UNMNT_REPLACE 0x0003 /* Target replaces mount point */ | |
22 | #define UNMNT_OPMASK 0x0003 | |
23 | ||
cad9958b JSP |
24 | struct union_mount { |
25 | struct vnode *um_uppervp; | |
26 | struct vnode *um_lowervp; | |
27 | struct ucred *um_cred; /* Credentials of user calling mount */ | |
3b293975 | 28 | int um_cmode; /* cmask from mount process */ |
cad9958b JSP |
29 | }; |
30 | ||
cad9958b JSP |
31 | #ifdef KERNEL |
32 | ||
33 | /* | |
34 | * DEFDIRMODE is the mode bits used to create a shadow directory. | |
35 | */ | |
36 | #define VRWXMODE (VREAD|VWRITE|VEXEC) | |
37 | #define VRWMODE (VREAD|VWRITE) | |
38 | #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6)) | |
39 | #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6)) | |
40 | ||
41 | /* | |
42 | * A cache of vnode references | |
43 | */ | |
44 | struct union_node { | |
58572fc0 | 45 | LIST_ENTRY(union_node) un_cache; /* Hash chain */ |
79f80c71 | 46 | struct vnode *un_vnode; /* Back pointer */ |
cad9958b JSP |
47 | struct vnode *un_uppervp; /* overlaying object */ |
48 | struct vnode *un_lowervp; /* underlying object */ | |
49 | struct vnode *un_dirvp; /* Parent dir of uppervp */ | |
cad9958b | 50 | char *un_path; /* saved component name */ |
ed5969c8 JSP |
51 | int un_hash; /* saved un_path hash value */ |
52 | int un_openl; /* # of opens on lowervp */ | |
cad9958b | 53 | int un_flags; |
ed5969c8 | 54 | #ifdef DIAGNOSTIC |
cad9958b | 55 | pid_t un_pid; |
ed5969c8 | 56 | #endif |
cad9958b JSP |
57 | }; |
58 | ||
e2a2f3a7 JSP |
59 | #define UN_WANT 0x01 |
60 | #define UN_LOCKED 0x02 | |
61 | #define UN_ULOCK 0x04 /* Upper node is locked */ | |
62 | #define UN_KLOCK 0x08 /* Keep upper node locked on vput */ | |
63 | ||
81be6ee0 JSP |
64 | extern int union_allocvp __P((struct vnode **, struct mount *, |
65 | struct vnode *, struct vnode *, | |
66 | struct componentname *, struct vnode *, | |
67 | struct vnode *)); | |
68 | extern int union_copyfile __P((struct proc *, struct ucred *, | |
69 | struct vnode *, struct vnode *)); | |
3b293975 JSP |
70 | extern int union_mkshadow __P((struct union_mount *, struct vnode *, |
71 | struct componentname *, struct vnode **)); | |
81be6ee0 | 72 | extern int union_vn_create __P((struct vnode **, struct union_node *, |
3b293975 | 73 | struct proc *)); |
15a86f7e JSP |
74 | extern int union_cn_close __P((struct vnode *, int, struct ucred *, |
75 | struct proc *)); | |
ed5969c8 | 76 | extern void union_removed_upper __P((struct union_node *un)); |
15a86f7e | 77 | extern struct vnode *union_lowervp __P((struct vnode *)); |
58572fc0 JSP |
78 | extern void union_newlower __P((struct union_node *, struct vnode *)); |
79 | extern void union_newupper __P((struct union_node *, struct vnode *)); | |
cad9958b JSP |
80 | |
81 | #define MOUNTTOUNIONMOUNT(mp) ((struct union_mount *)((mp)->mnt_data)) | |
82 | #define VTOUNION(vp) ((struct union_node *)(vp)->v_data) | |
83 | #define UNIONTOV(un) ((un)->un_vnode) | |
84 | #define LOWERVP(vp) (VTOUNION(vp)->un_lowervp) | |
01dac67e | 85 | #define UPPERVP(vp) (VTOUNION(vp)->un_uppervp) |
cad9958b JSP |
86 | #define OTHERVP(vp) (UPPERVP(vp) ? UPPERVP(vp) : LOWERVP(vp)) |
87 | ||
88 | extern int (**union_vnodeop_p)(); | |
89 | extern struct vfsops union_vfsops; | |
90 | #endif /* KERNEL */ |