__P()!=wanted, remove old style prototypes from the vfs subtree
[dragonfly.git] / sys / vfs / union / union.h
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  * Redistribution and use in source and binary forms, with or without
10  * modification, are permitted provided that the following conditions
11  * are met:
12  * 1. Redistributions of source code must retain the above copyright
13  *    notice, this list of conditions and the following disclaimer.
14  * 2. Redistributions in binary form must reproduce the above copyright
15  *    notice, this list of conditions and the following disclaimer in the
16  *    documentation and/or other materials provided with the distribution.
17  * 3. All advertising materials mentioning features or use of this software
18  *    must display the following acknowledgement:
19  *      This product includes software developed by the University of
20  *      California, Berkeley and its contributors.
21  * 4. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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: src/sys/miscfs/union/union.h,v 1.17 1999/12/29 04:54:48 peter Exp $
39  * $DragonFly: src/sys/vfs/union/union.h,v 1.4 2003/08/20 09:56:34 rob Exp $
40  */
41
42 struct union_args {
43         char            *target;        /* Target of loopback  */
44         int             mntflags;       /* Options on the mount */
45 };
46
47 #define UNMNT_ABOVE     0x0001          /* Target appears below mount point */
48 #define UNMNT_BELOW     0x0002          /* Target appears below mount point */
49 #define UNMNT_REPLACE   0x0003          /* Target replaces mount point */
50 #define UNMNT_OPMASK    0x0003
51
52 struct union_mount {
53         struct vnode    *um_uppervp;    /* UN_ULOCK holds locking state */
54         struct vnode    *um_lowervp;    /* Left unlocked */
55         struct ucred    *um_cred;       /* Credentials of user calling mount */
56         int             um_cmode;       /* cmask from mount process */
57         int             um_op;          /* Operation mode */
58 };
59
60 #ifdef _KERNEL
61
62 #ifndef DIAGNOSTIC
63 #define DIAGNOSTIC
64 #endif
65
66 /*
67  * DEFDIRMODE is the mode bits used to create a shadow directory.
68  */
69 #define VRWXMODE (VREAD|VWRITE|VEXEC)
70 #define VRWMODE (VREAD|VWRITE)
71 #define UN_DIRMODE ((VRWXMODE)|(VRWXMODE>>3)|(VRWXMODE>>6))
72 #define UN_FILEMODE ((VRWMODE)|(VRWMODE>>3)|(VRWMODE>>6))
73
74 /*
75  * A cache of vnode references  (hangs off v_data)
76  *
77  * Placing un_lock as the first elements theoretically allows us to
78  * use the vop_stdlock functions.  However, we need to make sure of
79  * certain side effects so we will still punch in our own code.
80  */
81 struct union_node {
82         struct lock             un_lock;
83         LIST_ENTRY(union_node)  un_cache;       /* Hash chain */
84         struct vnode            *un_vnode;      /* Back pointer */
85         struct vnode            *un_uppervp;    /* overlaying object */
86         struct vnode            *un_lowervp;    /* underlying object */
87         struct vnode            *un_dirvp;      /* Parent dir of uppervp */
88         struct vnode            *un_pvp;        /* Parent vnode */
89         char                    *un_path;       /* saved component name */
90         int                     un_openl;       /* # of opens on lowervp */
91         int                     un_exclcnt;     /* exclusive count */
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
101 /*
102  * XXX UN_ULOCK -       indicates that the uppervp is locked
103  *
104  * UN_CACHED -  node is in the union cache
105  */
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
117 extern int union_allocvp (struct vnode **, struct mount *,
118                                 struct vnode *, 
119                                 struct vnode *, 
120                                 struct componentname *, struct vnode *,
121                                 struct vnode *, int);
122 extern int union_freevp (struct vnode *);
123 extern struct vnode *union_dircache (struct vnode *, struct thread *);
124 extern int union_copyup (struct union_node *, int, struct ucred *,
125                                 struct thread *);
126 extern int union_dowhiteout (struct union_node *, struct ucred *,
127                                         struct thread *);
128 extern int union_mkshadow (struct union_mount *, struct vnode *,
129                                 struct componentname *, struct vnode **);
130 extern int union_mkwhiteout (struct union_mount *, struct vnode *,
131                                 struct componentname *, char *);
132 extern int union_cn_close (struct vnode *, int, struct ucred *,
133                                 struct thread *);
134 extern void union_removed_upper (struct union_node *un);
135 extern struct vnode *union_lowervp (struct vnode *);
136 extern void union_newsize (struct vnode *, off_t, off_t);
137 extern void union_vm_coherency (struct vnode *, struct uio *, int);
138
139 extern int (*union_dircheckp) (struct thread *, 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
152 extern vop_t **union_vnodeop_p;
153 extern struct vfsops union_vfsops;
154 extern int uniondebug;
155
156 #endif /* _KERNEL */