| @@ -1,606 +1,610 @@ | | | @@ -1,606 +1,610 @@ |
1 | /* $NetBSD: vnode.h,v 1.257 2016/01/22 22:43:25 dholland Exp $ */ | | 1 | /* $NetBSD: vnode.h,v 1.258 2016/01/23 16:02:09 christos Exp $ */ |
2 | | | 2 | |
3 | /*- | | 3 | /*- |
4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. | | 4 | * Copyright (c) 2008 The NetBSD Foundation, Inc. |
5 | * All rights reserved. | | 5 | * All rights reserved. |
6 | * | | 6 | * |
7 | * Redistribution and use in source and binary forms, with or without | | 7 | * Redistribution and use in source and binary forms, with or without |
8 | * modification, are permitted provided that the following conditions | | 8 | * modification, are permitted provided that the following conditions |
9 | * are met: | | 9 | * are met: |
10 | * 1. Redistributions of source code must retain the above copyright | | 10 | * 1. Redistributions of source code must retain the above copyright |
11 | * notice, this list of conditions and the following disclaimer. | | 11 | * notice, this list of conditions and the following disclaimer. |
12 | * 2. Redistributions in binary form must reproduce the above copyright | | 12 | * 2. Redistributions in binary form must reproduce the above copyright |
13 | * notice, this list of conditions and the following disclaimer in the | | 13 | * notice, this list of conditions and the following disclaimer in the |
14 | * documentation and/or other materials provided with the distribution. | | 14 | * documentation and/or other materials provided with the distribution. |
15 | * | | 15 | * |
16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS | | 16 | * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS |
17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED | | 17 | * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED |
18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR | | 18 | * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS | | 19 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS |
20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR | | 20 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF | | 21 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS | | 22 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN | | 23 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | | 24 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE | | 25 | * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
26 | * POSSIBILITY OF SUCH DAMAGE. | | 26 | * POSSIBILITY OF SUCH DAMAGE. |
27 | */ | | 27 | */ |
28 | | | 28 | |
29 | /* | | 29 | /* |
30 | * Copyright (c) 1989, 1993 | | 30 | * Copyright (c) 1989, 1993 |
31 | * The Regents of the University of California. All rights reserved. | | 31 | * The Regents of the University of California. All rights reserved. |
32 | * | | 32 | * |
33 | * Redistribution and use in source and binary forms, with or without | | 33 | * Redistribution and use in source and binary forms, with or without |
34 | * modification, are permitted provided that the following conditions | | 34 | * modification, are permitted provided that the following conditions |
35 | * are met: | | 35 | * are met: |
36 | * 1. Redistributions of source code must retain the above copyright | | 36 | * 1. Redistributions of source code must retain the above copyright |
37 | * notice, this list of conditions and the following disclaimer. | | 37 | * notice, this list of conditions and the following disclaimer. |
38 | * 2. Redistributions in binary form must reproduce the above copyright | | 38 | * 2. Redistributions in binary form must reproduce the above copyright |
39 | * notice, this list of conditions and the following disclaimer in the | | 39 | * notice, this list of conditions and the following disclaimer in the |
40 | * documentation and/or other materials provided with the distribution. | | 40 | * documentation and/or other materials provided with the distribution. |
41 | * 3. Neither the name of the University nor the names of its contributors | | 41 | * 3. Neither the name of the University nor the names of its contributors |
42 | * may be used to endorse or promote products derived from this software | | 42 | * may be used to endorse or promote products derived from this software |
43 | * without specific prior written permission. | | 43 | * without specific prior written permission. |
44 | * | | 44 | * |
45 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND | | 45 | * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND |
46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE | | 46 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE | | 47 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE | | 48 | * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE |
49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | | 49 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS | | 50 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS |
51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) | | 51 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) |
52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT | | 52 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT |
53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY | | 53 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY |
54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | | 54 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
55 | * SUCH DAMAGE. | | 55 | * SUCH DAMAGE. |
56 | * | | 56 | * |
57 | * @(#)vnode.h 8.17 (Berkeley) 5/20/95 | | 57 | * @(#)vnode.h 8.17 (Berkeley) 5/20/95 |
58 | */ | | 58 | */ |
59 | | | 59 | |
60 | #ifndef _SYS_VNODE_H_ | | 60 | #ifndef _SYS_VNODE_H_ |
61 | #define _SYS_VNODE_H_ | | 61 | #define _SYS_VNODE_H_ |
62 | | | 62 | |
63 | #include <sys/event.h> | | 63 | #include <sys/event.h> |
64 | #include <sys/queue.h> | | 64 | #include <sys/queue.h> |
65 | #include <sys/condvar.h> | | 65 | #include <sys/condvar.h> |
66 | #include <sys/rwlock.h> | | 66 | #include <sys/rwlock.h> |
67 | #include <sys/mutex.h> | | 67 | #include <sys/mutex.h> |
68 | #include <sys/time.h> | | 68 | #include <sys/time.h> |
69 | | | 69 | |
70 | /* XXX: clean up includes later */ | | 70 | /* XXX: clean up includes later */ |
| | | 71 | #if defined(_KERNEL) || defined(_KMEMUSER) |
71 | #include <uvm/uvm_param.h> /* XXX */ | | 72 | #include <uvm/uvm_param.h> /* XXX */ |
72 | #include <uvm/uvm_pglist.h> /* XXX */ | | 73 | #include <uvm/uvm_pglist.h> /* XXX */ |
73 | #include <uvm/uvm_object.h> /* XXX */ | | 74 | #include <uvm/uvm_object.h> /* XXX */ |
74 | #include <uvm/uvm_extern.h> /* XXX */ | | 75 | #include <uvm/uvm_extern.h> /* XXX */ |
75 | | | 76 | |
76 | struct namecache; | | 77 | struct namecache; |
77 | struct uvm_ractx; | | 78 | struct uvm_ractx; |
| | | 79 | #endif |
78 | | | 80 | |
79 | /* | | 81 | /* |
80 | * The vnode is the focus of all file activity in UNIX. There is a | | 82 | * The vnode is the focus of all file activity in UNIX. There is a |
81 | * unique vnode allocated for each active file, each current directory, | | 83 | * unique vnode allocated for each active file, each current directory, |
82 | * each mounted-on file, text file, and the root. | | 84 | * each mounted-on file, text file, and the root. |
83 | */ | | 85 | */ |
84 | | | 86 | |
85 | /* | | 87 | /* |
86 | * Vnode types. VNON means no type. | | 88 | * Vnode types. VNON means no type. |
87 | */ | | 89 | */ |
88 | enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD }; | | 90 | enum vtype { VNON, VREG, VDIR, VBLK, VCHR, VLNK, VSOCK, VFIFO, VBAD }; |
89 | | | 91 | |
90 | #define VNODE_TYPES \ | | 92 | #define VNODE_TYPES \ |
91 | "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD" | | 93 | "VNON", "VREG", "VDIR", "VBLK", "VCHR", "VLNK", "VSOCK", "VFIFO", "VBAD" |
92 | | | 94 | |
93 | /* | | 95 | /* |
94 | * Vnode tag types. | | 96 | * Vnode tag types. |
95 | * These are for the benefit of external programs only (e.g., pstat) | | 97 | * These are for the benefit of external programs only (e.g., pstat) |
96 | * and should NEVER be inspected by the kernel. | | 98 | * and should NEVER be inspected by the kernel. |
97 | */ | | 99 | */ |
98 | enum vtagtype { | | 100 | enum vtagtype { |
99 | VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, | | 101 | VT_NON, VT_UFS, VT_NFS, VT_MFS, VT_MSDOSFS, VT_LFS, VT_LOFS, |
100 | VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, | | 102 | VT_FDESC, VT_PORTAL, VT_NULL, VT_UMAP, VT_KERNFS, VT_PROCFS, |
101 | VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA, | | 103 | VT_AFS, VT_ISOFS, VT_UNION, VT_ADOSFS, VT_EXT2FS, VT_CODA, |
102 | VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS, | | 104 | VT_FILECORE, VT_NTFS, VT_VFS, VT_OVERLAY, VT_SMBFS, VT_PTYFS, |
103 | VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS, | | 105 | VT_TMPFS, VT_UDF, VT_SYSVBFS, VT_PUFFS, VT_HFS, VT_EFS, VT_ZFS, |
104 | VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS | | 106 | VT_RUMP, VT_NILFS, VT_V7FS, VT_CHFS |
105 | }; | | 107 | }; |
106 | | | 108 | |
107 | #define VNODE_TAGS \ | | 109 | #define VNODE_TAGS \ |
108 | "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \ | | 110 | "VT_NON", "VT_UFS", "VT_NFS", "VT_MFS", "VT_MSDOSFS", "VT_LFS", "VT_LOFS", \ |
109 | "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \ | | 111 | "VT_FDESC", "VT_PORTAL", "VT_NULL", "VT_UMAP", "VT_KERNFS", "VT_PROCFS", \ |
110 | "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \ | | 112 | "VT_AFS", "VT_ISOFS", "VT_UNION", "VT_ADOSFS", "VT_EXT2FS", "VT_CODA", \ |
111 | "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \ | | 113 | "VT_FILECORE", "VT_NTFS", "VT_VFS", "VT_OVERLAY", "VT_SMBFS", "VT_PTYFS", \ |
112 | "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \ | | 114 | "VT_TMPFS", "VT_UDF", "VT_SYSVBFS", "VT_PUFFS", "VT_HFS", "VT_EFS", \ |
113 | "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS" | | 115 | "VT_ZFS", "VT_RUMP", "VT_NILFS", "VT_V7FS", "VT_CHFS" |
114 | | | 116 | |
| | | 117 | #if defined(_KERNEL) || defined(_KMEMUSER) |
115 | struct vnode; | | 118 | struct vnode; |
116 | struct buf; | | 119 | struct buf; |
117 | | | 120 | |
118 | LIST_HEAD(buflists, buf); | | 121 | LIST_HEAD(buflists, buf); |
119 | TAILQ_HEAD(vnodelst, vnode); | | 122 | TAILQ_HEAD(vnodelst, vnode); |
120 | | | 123 | |
121 | /* | | 124 | /* |
122 | * Reading or writing any of these items requires holding the appropriate | | 125 | * Reading or writing any of these items requires holding the appropriate |
123 | * lock. Field markings and the corresponding locks: | | 126 | * lock. Field markings and the corresponding locks: |
124 | * | | 127 | * |
125 | * : stable, reference to the vnode is required | | 128 | * : stable, reference to the vnode is required |
126 | * f vnode_free_list_lock, or vrele_lock for vrele_list | | 129 | * f vnode_free_list_lock, or vrele_lock for vrele_list |
127 | * i v_interlock | | 130 | * i v_interlock |
128 | * m mntvnode_lock | | 131 | * m mntvnode_lock |
129 | * n namecache_lock | | 132 | * n namecache_lock |
130 | * s syncer_data_lock | | 133 | * s syncer_data_lock |
131 | * u locked by underlying filesystem | | 134 | * u locked by underlying filesystem |
132 | * v vnode lock | | 135 | * v vnode lock |
133 | * x v_interlock + bufcache_lock to modify, either to inspect | | 136 | * x v_interlock + bufcache_lock to modify, either to inspect |
134 | * | | 137 | * |
135 | * Each underlying filesystem allocates its own private area and hangs | | 138 | * Each underlying filesystem allocates its own private area and hangs |
136 | * it from v_data. | | 139 | * it from v_data. |
137 | */ | | 140 | */ |
138 | struct vnode { | | 141 | struct vnode { |
139 | struct uvm_object v_uobj; /* i: the VM object */ | | 142 | struct uvm_object v_uobj; /* i: the VM object */ |
140 | kcondvar_t v_cv; /* i: synchronization */ | | 143 | kcondvar_t v_cv; /* i: synchronization */ |
141 | voff_t v_size; /* i: size of file */ | | 144 | voff_t v_size; /* i: size of file */ |
142 | voff_t v_writesize; /* i: new size after write */ | | 145 | voff_t v_writesize; /* i: new size after write */ |
143 | int v_iflag; /* i: VI_* flags */ | | 146 | int v_iflag; /* i: VI_* flags */ |
144 | int v_vflag; /* v: VV_* flags */ | | 147 | int v_vflag; /* v: VV_* flags */ |
145 | int v_uflag; /* u: VU_* flags */ | | 148 | int v_uflag; /* u: VU_* flags */ |
146 | int v_numoutput; /* i: # of pending writes */ | | 149 | int v_numoutput; /* i: # of pending writes */ |
147 | int v_writecount; /* i: ref count of writers */ | | 150 | int v_writecount; /* i: ref count of writers */ |
148 | int v_holdcnt; /* i: page & buffer refs */ | | 151 | int v_holdcnt; /* i: page & buffer refs */ |
149 | int v_synclist_slot; /* s: synclist slot index */ | | 152 | int v_synclist_slot; /* s: synclist slot index */ |
150 | struct mount *v_mount; /* v: ptr to vfs we are in */ | | 153 | struct mount *v_mount; /* v: ptr to vfs we are in */ |
151 | int (**v_op)(void *); /* :: vnode operations vector */ | | 154 | int (**v_op)(void *); /* :: vnode operations vector */ |
152 | TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */ | | 155 | TAILQ_ENTRY(vnode) v_freelist; /* f: vnode freelist */ |
153 | struct vnodelst *v_freelisthd; /* f: which freelist? */ | | 156 | struct vnodelst *v_freelisthd; /* f: which freelist? */ |
154 | TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */ | | 157 | TAILQ_ENTRY(vnode) v_mntvnodes; /* m: vnodes for mount point */ |
155 | struct buflists v_cleanblkhd; /* x: clean blocklist head */ | | 158 | struct buflists v_cleanblkhd; /* x: clean blocklist head */ |
156 | struct buflists v_dirtyblkhd; /* x: dirty blocklist head */ | | 159 | struct buflists v_dirtyblkhd; /* x: dirty blocklist head */ |
157 | TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */ | | 160 | TAILQ_ENTRY(vnode) v_synclist; /* s: vnodes with dirty bufs */ |
158 | LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */ | | 161 | LIST_HEAD(, namecache) v_dnclist; /* n: namecaches (children) */ |
159 | LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */ | | 162 | LIST_HEAD(, namecache) v_nclist; /* n: namecaches (parent) */ |
160 | union { | | 163 | union { |
161 | struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */ | | 164 | struct mount *vu_mountedhere;/* v: ptr to vfs (VDIR) */ |
162 | struct socket *vu_socket; /* v: unix ipc (VSOCK) */ | | 165 | struct socket *vu_socket; /* v: unix ipc (VSOCK) */ |
163 | struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */ | | 166 | struct specnode *vu_specnode; /* v: device (VCHR, VBLK) */ |
164 | struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */ | | 167 | struct fifoinfo *vu_fifoinfo; /* v: fifo (VFIFO) */ |
165 | struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */ | | 168 | struct uvm_ractx *vu_ractx; /* i: read-ahead ctx (VREG) */ |
166 | } v_un; | | 169 | } v_un; |
167 | enum vtype v_type; /* :: vnode type */ | | 170 | enum vtype v_type; /* :: vnode type */ |
168 | enum vtagtype v_tag; /* :: type of underlying data */ | | 171 | enum vtagtype v_tag; /* :: type of underlying data */ |
169 | krwlock_t v_lock; /* v: lock for this vnode */ | | 172 | krwlock_t v_lock; /* v: lock for this vnode */ |
170 | void *v_data; /* :: private data for fs */ | | 173 | void *v_data; /* :: private data for fs */ |
171 | struct klist v_klist; /* i: notes attached to vnode */ | | 174 | struct klist v_klist; /* i: notes attached to vnode */ |
172 | }; | | 175 | }; |
173 | #define v_usecount v_uobj.uo_refs | | 176 | #define v_usecount v_uobj.uo_refs |
174 | #define v_interlock v_uobj.vmobjlock | | 177 | #define v_interlock v_uobj.vmobjlock |
175 | #define v_mountedhere v_un.vu_mountedhere | | 178 | #define v_mountedhere v_un.vu_mountedhere |
176 | #define v_socket v_un.vu_socket | | 179 | #define v_socket v_un.vu_socket |
177 | #define v_specnode v_un.vu_specnode | | 180 | #define v_specnode v_un.vu_specnode |
178 | #define v_fifoinfo v_un.vu_fifoinfo | | 181 | #define v_fifoinfo v_un.vu_fifoinfo |
179 | #define v_ractx v_un.vu_ractx | | 182 | #define v_ractx v_un.vu_ractx |
180 | | | 183 | |
181 | typedef struct vnodelst vnodelst_t; | | 184 | typedef struct vnodelst vnodelst_t; |
182 | typedef struct vnode vnode_t; | | 185 | typedef struct vnode vnode_t; |
| | | 186 | #endif |
183 | | | 187 | |
184 | /* | | 188 | /* |
185 | * Vnode flags. The first set are locked by vnode lock or are stable. | | 189 | * Vnode flags. The first set are locked by vnode lock or are stable. |
186 | * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used | | 190 | * VSYSTEM is only used to skip vflush()ing quota files. VISTTY is used |
187 | * when reading dead vnodes. | | 191 | * when reading dead vnodes. |
188 | */ | | 192 | */ |
189 | #define VV_ROOT 0x00000001 /* root of its file system */ | | 193 | #define VV_ROOT 0x00000001 /* root of its file system */ |
190 | #define VV_SYSTEM 0x00000002 /* vnode being used by kernel */ | | 194 | #define VV_SYSTEM 0x00000002 /* vnode being used by kernel */ |
191 | #define VV_ISTTY 0x00000004 /* vnode represents a tty */ | | 195 | #define VV_ISTTY 0x00000004 /* vnode represents a tty */ |
192 | #define VV_MAPPED 0x00000008 /* vnode might have user mappings */ | | 196 | #define VV_MAPPED 0x00000008 /* vnode might have user mappings */ |
193 | #define VV_MPSAFE 0x00000010 /* file system code is MP safe */ | | 197 | #define VV_MPSAFE 0x00000010 /* file system code is MP safe */ |
194 | #define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */ | | 198 | #define VV_LOCKSWORK 0x00000020 /* FS supports locking discipline */ |
195 | | | 199 | |
196 | /* | | 200 | /* |
197 | * The second set are locked by vp->v_interlock. | | 201 | * The second set are locked by vp->v_interlock. |
198 | */ | | 202 | */ |
199 | #define VI_TEXT 0x00000100 /* vnode is a pure text prototype */ | | 203 | #define VI_TEXT 0x00000100 /* vnode is a pure text prototype */ |
200 | #define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */ | | 204 | #define VI_EXECMAP 0x00000200 /* might have PROT_EXEC mappings */ |
201 | #define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */ | | 205 | #define VI_WRMAP 0x00000400 /* might have PROT_WRITE u. mappings */ |
202 | #define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */ | | 206 | #define VI_WRMAPDIRTY 0x00000800 /* might have dirty pages */ |
203 | #ifdef _VFS_VNODE_PRIVATE | | 207 | #ifdef _VFS_VNODE_PRIVATE |
204 | #define VI_XLOCK 0x00001000 /* vnode is locked to change type */ | | 208 | #define VI_XLOCK 0x00001000 /* vnode is locked to change type */ |
205 | #endif /* _VFS_VNODE_PRIVATE */ | | 209 | #endif /* _VFS_VNODE_PRIVATE */ |
206 | #define VI_ONWORKLST 0x00004000 /* On syncer work-list */ | | 210 | #define VI_ONWORKLST 0x00004000 /* On syncer work-list */ |
207 | #ifdef _VFS_VNODE_PRIVATE | | 211 | #ifdef _VFS_VNODE_PRIVATE |
208 | #define VI_MARKER 0x00008000 /* Dummy marker vnode */ | | 212 | #define VI_MARKER 0x00008000 /* Dummy marker vnode */ |
209 | #endif /* _VFS_VNODE_PRIVATE */ | | 213 | #endif /* _VFS_VNODE_PRIVATE */ |
210 | #ifdef _VFS_VNODE_PRIVATE | | 214 | #ifdef _VFS_VNODE_PRIVATE |
211 | #define VI_CLEAN 0x00080000 /* has been reclaimed */ | | 215 | #define VI_CLEAN 0x00080000 /* has been reclaimed */ |
212 | #define VI_CHANGING 0x00100000 /* vnode changes state */ | | 216 | #define VI_CHANGING 0x00100000 /* vnode changes state */ |
213 | #endif /* _VFS_VNODE_PRIVATE */ | | 217 | #endif /* _VFS_VNODE_PRIVATE */ |
214 | | | 218 | |
215 | /* | | 219 | /* |
216 | * The third set are locked by the underlying file system. | | 220 | * The third set are locked by the underlying file system. |
217 | */ | | 221 | */ |
218 | #define VU_DIROP 0x01000000 /* LFS: involved in a directory op */ | | 222 | #define VU_DIROP 0x01000000 /* LFS: involved in a directory op */ |
219 | | | 223 | |
220 | #define VNODE_FLAGBITS \ | | 224 | #define VNODE_FLAGBITS \ |
221 | "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \ | | 225 | "\20\1ROOT\2SYSTEM\3ISTTY\4MAPPED\5MPSAFE\6LOCKSWORK\11TEXT\12EXECMAP" \ |
222 | "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \ | | 226 | "\13WRMAP\14WRMAPDIRTY\15XLOCK\17ONWORKLST\20MARKER" \ |
223 | "\24CLEAN\25CHANGING\31DIROP" | | 227 | "\24CLEAN\25CHANGING\31DIROP" |
224 | | | 228 | |
225 | #define VSIZENOTSET ((voff_t)-1) | | 229 | #define VSIZENOTSET ((voff_t)-1) |
226 | | | 230 | |
227 | /* | | 231 | /* |
228 | * vnode lock flags | | 232 | * vnode lock flags |
229 | */ | | 233 | */ |
230 | #define LK_SHARED 0x00000001 /* shared lock */ | | 234 | #define LK_SHARED 0x00000001 /* shared lock */ |
231 | #define LK_EXCLUSIVE 0x00000002 /* exclusive lock */ | | 235 | #define LK_EXCLUSIVE 0x00000002 /* exclusive lock */ |
232 | #define LK_NOWAIT 0x00000010 /* do not sleep to await lock */ | | 236 | #define LK_NOWAIT 0x00000010 /* do not sleep to await lock */ |
233 | #define LK_RETRY 0x00020000 /* vn_lock: retry until locked */ | | 237 | #define LK_RETRY 0x00020000 /* vn_lock: retry until locked */ |
234 | | | 238 | |
235 | /* | | 239 | /* |
236 | * Vnode attributes. A field value of VNOVAL represents a field whose value | | 240 | * Vnode attributes. A field value of VNOVAL represents a field whose value |
237 | * is unavailable (getattr) or which is not to be changed (setattr). | | 241 | * is unavailable (getattr) or which is not to be changed (setattr). |
238 | */ | | 242 | */ |
239 | struct vattr { | | 243 | struct vattr { |
240 | enum vtype va_type; /* vnode type (for create) */ | | 244 | enum vtype va_type; /* vnode type (for create) */ |
241 | mode_t va_mode; /* files access mode and type */ | | 245 | mode_t va_mode; /* files access mode and type */ |
242 | nlink_t va_nlink; /* number of references to file */ | | 246 | nlink_t va_nlink; /* number of references to file */ |
243 | uid_t va_uid; /* owner user id */ | | 247 | uid_t va_uid; /* owner user id */ |
244 | gid_t va_gid; /* owner group id */ | | 248 | gid_t va_gid; /* owner group id */ |
245 | dev_t va_fsid; /* file system id (dev for now) */ | | 249 | dev_t va_fsid; /* file system id (dev for now) */ |
246 | ino_t va_fileid; /* file id */ | | 250 | ino_t va_fileid; /* file id */ |
247 | u_quad_t va_size; /* file size in bytes */ | | 251 | u_quad_t va_size; /* file size in bytes */ |
248 | long va_blocksize; /* blocksize preferred for i/o */ | | 252 | long va_blocksize; /* blocksize preferred for i/o */ |
249 | struct timespec va_atime; /* time of last access */ | | 253 | struct timespec va_atime; /* time of last access */ |
250 | struct timespec va_mtime; /* time of last modification */ | | 254 | struct timespec va_mtime; /* time of last modification */ |
251 | struct timespec va_ctime; /* time file changed */ | | 255 | struct timespec va_ctime; /* time file changed */ |
252 | struct timespec va_birthtime; /* time file created */ | | 256 | struct timespec va_birthtime; /* time file created */ |
253 | u_long va_gen; /* generation number of file */ | | 257 | u_long va_gen; /* generation number of file */ |
254 | u_long va_flags; /* flags defined for file */ | | 258 | u_long va_flags; /* flags defined for file */ |
255 | dev_t va_rdev; /* device the special file represents */ | | 259 | dev_t va_rdev; /* device the special file represents */ |
256 | u_quad_t va_bytes; /* bytes of disk space held by file */ | | 260 | u_quad_t va_bytes; /* bytes of disk space held by file */ |
257 | u_quad_t va_filerev; /* file modification number */ | | 261 | u_quad_t va_filerev; /* file modification number */ |
258 | u_int va_vaflags; /* operations flags, see below */ | | 262 | u_int va_vaflags; /* operations flags, see below */ |
259 | long va_spare; /* remain quad aligned */ | | 263 | long va_spare; /* remain quad aligned */ |
260 | }; | | 264 | }; |
261 | | | 265 | |
262 | /* | | 266 | /* |
263 | * Flags for va_vaflags. | | 267 | * Flags for va_vaflags. |
264 | */ | | 268 | */ |
265 | #define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ | | 269 | #define VA_UTIMES_NULL 0x01 /* utimes argument was NULL */ |
266 | #define VA_EXCLUSIVE 0x02 /* exclusive create request */ | | 270 | #define VA_EXCLUSIVE 0x02 /* exclusive create request */ |
267 | | | 271 | |
268 | #ifdef _KERNEL | | 272 | #ifdef _KERNEL |
269 | | | 273 | |
270 | /* | | 274 | /* |
271 | * Flags for ioflag. | | 275 | * Flags for ioflag. |
272 | */ | | 276 | */ |
273 | #define IO_UNIT 0x00010 /* do I/O as atomic unit */ | | 277 | #define IO_UNIT 0x00010 /* do I/O as atomic unit */ |
274 | #define IO_APPEND 0x00020 /* append write to end */ | | 278 | #define IO_APPEND 0x00020 /* append write to end */ |
275 | #define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */ | | 279 | #define IO_SYNC (0x40|IO_DSYNC) /* sync I/O file integrity completion */ |
276 | #define IO_NODELOCKED 0x00080 /* underlying node already locked */ | | 280 | #define IO_NODELOCKED 0x00080 /* underlying node already locked */ |
277 | #define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */ | | 281 | #define IO_NDELAY 0x00100 /* FNDELAY flag set in file table */ |
278 | #define IO_DSYNC 0x00200 /* sync I/O data integrity completion */ | | 282 | #define IO_DSYNC 0x00200 /* sync I/O data integrity completion */ |
279 | #define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */ | | 283 | #define IO_ALTSEMANTICS 0x00400 /* use alternate i/o semantics */ |
280 | #define IO_NORMAL 0x00800 /* operate on regular data */ | | 284 | #define IO_NORMAL 0x00800 /* operate on regular data */ |
281 | #define IO_EXT 0x01000 /* operate on extended attributes */ | | 285 | #define IO_EXT 0x01000 /* operate on extended attributes */ |
282 | #define IO_DIRECT 0x02000 /* direct I/O hint */ | | 286 | #define IO_DIRECT 0x02000 /* direct I/O hint */ |
283 | #define IO_JOURNALLOCKED 0x04000 /* journal is already locked */ | | 287 | #define IO_JOURNALLOCKED 0x04000 /* journal is already locked */ |
284 | #define IO_ADV_MASK 0x00003 /* access pattern hint */ | | 288 | #define IO_ADV_MASK 0x00003 /* access pattern hint */ |
285 | | | 289 | |
286 | #define IO_ADV_SHIFT 0 | | 290 | #define IO_ADV_SHIFT 0 |
287 | #define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK) | | 291 | #define IO_ADV_ENCODE(adv) (((adv) << IO_ADV_SHIFT) & IO_ADV_MASK) |
288 | #define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT) | | 292 | #define IO_ADV_DECODE(ioflag) (((ioflag) & IO_ADV_MASK) >> IO_ADV_SHIFT) |
289 | | | 293 | |
290 | /* | | 294 | /* |
291 | * Modes. | | 295 | * Modes. |
292 | */ | | 296 | */ |
293 | #define VREAD 00004 /* read, write, execute permissions */ | | 297 | #define VREAD 00004 /* read, write, execute permissions */ |
294 | #define VWRITE 00002 | | 298 | #define VWRITE 00002 |
295 | #define VEXEC 00001 | | 299 | #define VEXEC 00001 |
296 | | | 300 | |
297 | /* | | 301 | /* |
298 | * Token indicating no attribute value yet assigned. | | 302 | * Token indicating no attribute value yet assigned. |
299 | */ | | 303 | */ |
300 | #define VNOVAL (-1) | | 304 | #define VNOVAL (-1) |
301 | | | 305 | |
302 | /* | | 306 | /* |
303 | * Convert between vnode types and inode formats (since POSIX.1 | | 307 | * Convert between vnode types and inode formats (since POSIX.1 |
304 | * defines mode word of stat structure in terms of inode formats). | | 308 | * defines mode word of stat structure in terms of inode formats). |
305 | */ | | 309 | */ |
306 | extern const enum vtype iftovt_tab[]; | | 310 | extern const enum vtype iftovt_tab[]; |
307 | extern const int vttoif_tab[]; | | 311 | extern const int vttoif_tab[]; |
308 | #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) | | 312 | #define IFTOVT(mode) (iftovt_tab[((mode) & S_IFMT) >> 12]) |
309 | #define VTTOIF(indx) (vttoif_tab[(int)(indx)]) | | 313 | #define VTTOIF(indx) (vttoif_tab[(int)(indx)]) |
310 | #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) | | 314 | #define MAKEIMODE(indx, mode) (int)(VTTOIF(indx) | (mode)) |
311 | | | 315 | |
312 | /* | | 316 | /* |
313 | * Flags to various vnode functions. | | 317 | * Flags to various vnode functions. |
314 | */ | | 318 | */ |
315 | #define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ | | 319 | #define SKIPSYSTEM 0x0001 /* vflush: skip vnodes marked VSYSTEM */ |
316 | #define FORCECLOSE 0x0002 /* vflush: force file closeure */ | | 320 | #define FORCECLOSE 0x0002 /* vflush: force file closeure */ |
317 | #define WRITECLOSE 0x0004 /* vflush: only close writable files */ | | 321 | #define WRITECLOSE 0x0004 /* vflush: only close writable files */ |
318 | #define V_SAVE 0x0001 /* vinvalbuf: sync file first */ | | 322 | #define V_SAVE 0x0001 /* vinvalbuf: sync file first */ |
319 | | | 323 | |
320 | /* | | 324 | /* |
321 | * Flags to various vnode operations. | | 325 | * Flags to various vnode operations. |
322 | */ | | 326 | */ |
323 | #define REVOKEALL 0x0001 /* revoke: revoke all aliases */ | | 327 | #define REVOKEALL 0x0001 /* revoke: revoke all aliases */ |
324 | | | 328 | |
325 | #define FSYNC_WAIT 0x0001 /* fsync: wait for completion */ | | 329 | #define FSYNC_WAIT 0x0001 /* fsync: wait for completion */ |
326 | #define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */ | | 330 | #define FSYNC_DATAONLY 0x0002 /* fsync: hint: sync file data only */ |
327 | #define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */ | | 331 | #define FSYNC_RECLAIM 0x0004 /* fsync: hint: vnode is being reclaimed */ |
328 | #define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */ | | 332 | #define FSYNC_LAZY 0x0008 /* fsync: lazy sync (trickle) */ |
329 | #define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */ | | 333 | #define FSYNC_NOLOG 0x0010 /* fsync: do not flush the log */ |
330 | #define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */ | | 334 | #define FSYNC_CACHE 0x0100 /* fsync: flush disk caches too */ |
331 | | | 335 | |
332 | #define UPDATE_WAIT 0x0001 /* update: wait for completion */ | | 336 | #define UPDATE_WAIT 0x0001 /* update: wait for completion */ |
333 | #define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */ | | 337 | #define UPDATE_DIROP 0x0002 /* update: hint to fs to wait or not */ |
334 | #define UPDATE_CLOSE 0x0004 /* update: clean up on close */ | | 338 | #define UPDATE_CLOSE 0x0004 /* update: clean up on close */ |
335 | | | 339 | |
336 | #define VDEAD_NOWAIT 0x0001 /* vdead_check: do not sleep */ | | 340 | #define VDEAD_NOWAIT 0x0001 /* vdead_check: do not sleep */ |
337 | | | 341 | |
338 | void holdrelel(struct vnode *); | | 342 | void holdrelel(struct vnode *); |
339 | void vholdl(struct vnode *); | | 343 | void vholdl(struct vnode *); |
340 | void vref(struct vnode *); | | 344 | void vref(struct vnode *); |
341 | | | 345 | |
342 | static __inline void holdrele(struct vnode *) __unused; | | 346 | static __inline void holdrele(struct vnode *) __unused; |
343 | static __inline void vhold(struct vnode *) __unused; | | 347 | static __inline void vhold(struct vnode *) __unused; |
344 | | | 348 | |
345 | /* | | 349 | /* |
346 | * decrease buf or page ref | | 350 | * decrease buf or page ref |
347 | */ | | 351 | */ |
348 | static __inline void | | 352 | static __inline void |
349 | holdrele(struct vnode *vp) | | 353 | holdrele(struct vnode *vp) |
350 | { | | 354 | { |
351 | | | 355 | |
352 | mutex_enter(vp->v_interlock); | | 356 | mutex_enter(vp->v_interlock); |
353 | holdrelel(vp); | | 357 | holdrelel(vp); |
354 | mutex_exit(vp->v_interlock); | | 358 | mutex_exit(vp->v_interlock); |
355 | } | | 359 | } |
356 | | | 360 | |
357 | /* | | 361 | /* |
358 | * increase buf or page ref | | 362 | * increase buf or page ref |
359 | */ | | 363 | */ |
360 | static __inline void | | 364 | static __inline void |
361 | vhold(struct vnode *vp) | | 365 | vhold(struct vnode *vp) |
362 | { | | 366 | { |
363 | | | 367 | |
364 | mutex_enter(vp->v_interlock); | | 368 | mutex_enter(vp->v_interlock); |
365 | vholdl(vp); | | 369 | vholdl(vp); |
366 | mutex_exit(vp->v_interlock); | | 370 | mutex_exit(vp->v_interlock); |
367 | } | | 371 | } |
368 | | | 372 | |
369 | #define NULLVP ((struct vnode *)NULL) | | 373 | #define NULLVP ((struct vnode *)NULL) |
370 | | | 374 | |
371 | static __inline void | | 375 | static __inline void |
372 | VN_KNOTE(struct vnode *vp, long hint) | | 376 | VN_KNOTE(struct vnode *vp, long hint) |
373 | { | | 377 | { |
374 | | | 378 | |
375 | mutex_enter(vp->v_interlock); | | 379 | mutex_enter(vp->v_interlock); |
376 | KNOTE(&vp->v_klist, hint); | | 380 | KNOTE(&vp->v_klist, hint); |
377 | mutex_exit(vp->v_interlock); | | 381 | mutex_exit(vp->v_interlock); |
378 | } | | 382 | } |
379 | | | 383 | |
380 | /* | | 384 | /* |
381 | * Global vnode data. | | 385 | * Global vnode data. |
382 | */ | | 386 | */ |
383 | extern struct vnode *rootvnode; /* root (i.e. "/") vnode */ | | 387 | extern struct vnode *rootvnode; /* root (i.e. "/") vnode */ |
384 | extern int desiredvnodes; /* number of vnodes desired */ | | 388 | extern int desiredvnodes; /* number of vnodes desired */ |
385 | extern u_int numvnodes; /* current number of vnodes */ | | 389 | extern u_int numvnodes; /* current number of vnodes */ |
386 | | | 390 | |
387 | #endif /* _KERNEL */ | | 391 | #endif /* _KERNEL */ |
388 | | | 392 | |
389 | | | 393 | |
390 | /* | | 394 | /* |
391 | * Mods for exensibility. | | 395 | * Mods for exensibility. |
392 | */ | | 396 | */ |
393 | | | 397 | |
394 | /* | | 398 | /* |
395 | * Flags for vdesc_flags: | | 399 | * Flags for vdesc_flags: |
396 | */ | | 400 | */ |
397 | #define VDESC_MAX_VPS 8 | | 401 | #define VDESC_MAX_VPS 8 |
398 | /* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ | | 402 | /* Low order 16 flag bits are reserved for willrele flags for vp arguments. */ |
399 | #define VDESC_VP0_WILLRELE 0x00000001 | | 403 | #define VDESC_VP0_WILLRELE 0x00000001 |
400 | #define VDESC_VP1_WILLRELE 0x00000002 | | 404 | #define VDESC_VP1_WILLRELE 0x00000002 |
401 | #define VDESC_VP2_WILLRELE 0x00000004 | | 405 | #define VDESC_VP2_WILLRELE 0x00000004 |
402 | #define VDESC_VP3_WILLRELE 0x00000008 | | 406 | #define VDESC_VP3_WILLRELE 0x00000008 |
403 | #define VDESC_VP0_WILLUNLOCK 0x00000100 | | 407 | #define VDESC_VP0_WILLUNLOCK 0x00000100 |
404 | #define VDESC_VP1_WILLUNLOCK 0x00000200 | | 408 | #define VDESC_VP1_WILLUNLOCK 0x00000200 |
405 | #define VDESC_VP2_WILLUNLOCK 0x00000400 | | 409 | #define VDESC_VP2_WILLUNLOCK 0x00000400 |
406 | #define VDESC_VP3_WILLUNLOCK 0x00000800 | | 410 | #define VDESC_VP3_WILLUNLOCK 0x00000800 |
407 | #define VDESC_VP0_WILLPUT 0x00000101 | | 411 | #define VDESC_VP0_WILLPUT 0x00000101 |
408 | #define VDESC_VP1_WILLPUT 0x00000202 | | 412 | #define VDESC_VP1_WILLPUT 0x00000202 |
409 | #define VDESC_VP2_WILLPUT 0x00000404 | | 413 | #define VDESC_VP2_WILLPUT 0x00000404 |
410 | #define VDESC_VP3_WILLPUT 0x00000808 | | 414 | #define VDESC_VP3_WILLPUT 0x00000808 |
411 | | | 415 | |
412 | /* | | 416 | /* |
413 | * VDESC_NO_OFFSET is used to identify the end of the offset list | | 417 | * VDESC_NO_OFFSET is used to identify the end of the offset list |
414 | * and in places where no such field exists. | | 418 | * and in places where no such field exists. |
415 | */ | | 419 | */ |
416 | #define VDESC_NO_OFFSET -1 | | 420 | #define VDESC_NO_OFFSET -1 |
417 | | | 421 | |
418 | /* | | 422 | /* |
419 | * This structure describes the vnode operation taking place. | | 423 | * This structure describes the vnode operation taking place. |
420 | */ | | 424 | */ |
421 | struct vnodeop_desc { | | 425 | struct vnodeop_desc { |
422 | int vdesc_offset; /* offset in vector--first for speed */ | | 426 | int vdesc_offset; /* offset in vector--first for speed */ |
423 | const char *vdesc_name; /* a readable name for debugging */ | | 427 | const char *vdesc_name; /* a readable name for debugging */ |
424 | int vdesc_flags; /* VDESC_* flags */ | | 428 | int vdesc_flags; /* VDESC_* flags */ |
425 | | | 429 | |
426 | /* | | 430 | /* |
427 | * These ops are used by bypass routines to map and locate arguments. | | 431 | * These ops are used by bypass routines to map and locate arguments. |
428 | * Creds and procs are not needed in bypass routines, but sometimes | | 432 | * Creds and procs are not needed in bypass routines, but sometimes |
429 | * they are useful to (for example) transport layers. | | 433 | * they are useful to (for example) transport layers. |
430 | * Nameidata is useful because it has a cred in it. | | 434 | * Nameidata is useful because it has a cred in it. |
431 | */ | | 435 | */ |
432 | const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ | | 436 | const int *vdesc_vp_offsets; /* list ended by VDESC_NO_OFFSET */ |
433 | int vdesc_vpp_offset; /* return vpp location */ | | 437 | int vdesc_vpp_offset; /* return vpp location */ |
434 | int vdesc_cred_offset; /* cred location, if any */ | | 438 | int vdesc_cred_offset; /* cred location, if any */ |
435 | int vdesc_componentname_offset; /* if any */ | | 439 | int vdesc_componentname_offset; /* if any */ |
436 | }; | | 440 | }; |
437 | | | 441 | |
438 | #ifdef _KERNEL | | 442 | #ifdef _KERNEL |
439 | | | 443 | |
440 | /* | | 444 | /* |
441 | * Interlock for scanning list of vnodes attached to a mountpoint | | 445 | * Interlock for scanning list of vnodes attached to a mountpoint |
442 | */ | | 446 | */ |
443 | extern kmutex_t mntvnode_lock; | | 447 | extern kmutex_t mntvnode_lock; |
444 | | | 448 | |
445 | /* | | 449 | /* |
446 | * Union filesystem hook for vn_readdir(). | | 450 | * Union filesystem hook for vn_readdir(). |
447 | */ | | 451 | */ |
448 | extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *); | | 452 | extern int (*vn_union_readdir_hook) (struct vnode **, struct file *, struct lwp *); |
449 | | | 453 | |
450 | /* | | 454 | /* |
451 | * Macros for offsets in the vdesc struct. | | 455 | * Macros for offsets in the vdesc struct. |
452 | */ | | 456 | */ |
453 | #define VOPARG_OFFSETOF(type, member) offsetof(type, member) | | 457 | #define VOPARG_OFFSETOF(type, member) offsetof(type, member) |
454 | #define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset))) | | 458 | #define VOPARG_OFFSETTO(type,offset,sp) ((type)(((char *)(sp)) + (offset))) |
455 | | | 459 | |
456 | /* | | 460 | /* |
457 | * This structure is used to configure the new vnodeops vector. | | 461 | * This structure is used to configure the new vnodeops vector. |
458 | */ | | 462 | */ |
459 | struct vnodeopv_entry_desc { | | 463 | struct vnodeopv_entry_desc { |
460 | const struct vnodeop_desc *opve_op; /* which operation this is */ | | 464 | const struct vnodeop_desc *opve_op; /* which operation this is */ |
461 | int (*opve_impl)(void *); /* code implementing this operation */ | | 465 | int (*opve_impl)(void *); /* code implementing this operation */ |
462 | }; | | 466 | }; |
463 | | | 467 | |
464 | struct vnodeopv_desc { | | 468 | struct vnodeopv_desc { |
465 | /* ptr to the ptr to the vector where op should go */ | | 469 | /* ptr to the ptr to the vector where op should go */ |
466 | int (***opv_desc_vector_p)(void *); | | 470 | int (***opv_desc_vector_p)(void *); |
467 | const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */ | | 471 | const struct vnodeopv_entry_desc *opv_desc_ops; /* null terminated list */ |
468 | }; | | 472 | }; |
469 | | | 473 | |
470 | /* | | 474 | /* |
471 | * A default routine which just returns an error. | | 475 | * A default routine which just returns an error. |
472 | */ | | 476 | */ |
473 | int vn_default_error(void *); | | 477 | int vn_default_error(void *); |
474 | | | 478 | |
475 | /* | | 479 | /* |
476 | * A generic structure. | | 480 | * A generic structure. |
477 | * This can be used by bypass routines to identify generic arguments. | | 481 | * This can be used by bypass routines to identify generic arguments. |
478 | */ | | 482 | */ |
479 | struct vop_generic_args { | | 483 | struct vop_generic_args { |
480 | struct vnodeop_desc *a_desc; | | 484 | struct vnodeop_desc *a_desc; |
481 | /* other random data follows, presumably */ | | 485 | /* other random data follows, presumably */ |
482 | }; | | 486 | }; |
483 | | | 487 | |
484 | /* | | 488 | /* |
485 | * VOCALL calls an op given an ops vector. We break it out because BSD's | | 489 | * VOCALL calls an op given an ops vector. We break it out because BSD's |
486 | * vclean changes the ops vector and then wants to call ops with the old | | 490 | * vclean changes the ops vector and then wants to call ops with the old |
487 | * vector. | | 491 | * vector. |
488 | */ | | 492 | */ |
489 | /* | | 493 | /* |
490 | * actually, vclean doesn't use it anymore, but nfs does, | | 494 | * actually, vclean doesn't use it anymore, but nfs does, |
491 | * for device specials and fifos. | | 495 | * for device specials and fifos. |
492 | */ | | 496 | */ |
493 | #define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP)) | | 497 | #define VOCALL(OPSV,OFF,AP) (( *((OPSV)[(OFF)])) (AP)) |
494 | | | 498 | |
495 | /* | | 499 | /* |
496 | * This call works for vnodes in the kernel. | | 500 | * This call works for vnodes in the kernel. |
497 | */ | | 501 | */ |
498 | #define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP)) | | 502 | #define VCALL(VP,OFF,AP) VOCALL((VP)->v_op,(OFF),(AP)) |
499 | #define VDESC(OP) (& __CONCAT(OP,_desc)) | | 503 | #define VDESC(OP) (& __CONCAT(OP,_desc)) |
500 | #define VOFFSET(OP) (VDESC(OP)->vdesc_offset) | | 504 | #define VOFFSET(OP) (VDESC(OP)->vdesc_offset) |
501 | | | 505 | |
502 | /* XXX This include should go away */ | | 506 | /* XXX This include should go away */ |
503 | #include <sys/mount.h> | | 507 | #include <sys/mount.h> |
504 | | | 508 | |
505 | /* | | 509 | /* |
506 | * Finally, include the default set of vnode operations. | | 510 | * Finally, include the default set of vnode operations. |
507 | */ | | 511 | */ |
508 | #include <sys/vnode_if.h> | | 512 | #include <sys/vnode_if.h> |
509 | | | 513 | |
510 | /* | | 514 | /* |
511 | * Public vnode manipulation functions. | | 515 | * Public vnode manipulation functions. |
512 | */ | | 516 | */ |
513 | struct file; | | 517 | struct file; |
514 | struct filedesc; | | 518 | struct filedesc; |
515 | struct nameidata; | | 519 | struct nameidata; |
516 | struct proc; | | 520 | struct proc; |
517 | struct stat; | | 521 | struct stat; |
518 | struct uio; | | 522 | struct uio; |
519 | struct vattr; | | 523 | struct vattr; |
520 | struct vnode; | | 524 | struct vnode; |
521 | | | 525 | |
522 | /* see vnode(9) */ | | 526 | /* see vnode(9) */ |
523 | void vfs_vnode_sysinit(void); | | 527 | void vfs_vnode_sysinit(void); |
524 | int bdevvp(dev_t, struct vnode **); | | 528 | int bdevvp(dev_t, struct vnode **); |
525 | int cdevvp(dev_t, struct vnode **); | | 529 | int cdevvp(dev_t, struct vnode **); |
526 | int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t); | | 530 | int vaccess(enum vtype, mode_t, uid_t, gid_t, mode_t, kauth_cred_t); |
527 | void vattr_null(struct vattr *); | | 531 | void vattr_null(struct vattr *); |
528 | void vdevgone(int, int, int, enum vtype); | | 532 | void vdevgone(int, int, int, enum vtype); |
529 | int vfinddev(dev_t, enum vtype, struct vnode **); | | 533 | int vfinddev(dev_t, enum vtype, struct vnode **); |
530 | int vflush(struct mount *, struct vnode *, int); | | 534 | int vflush(struct mount *, struct vnode *, int); |
531 | int vflushbuf(struct vnode *, int); | | 535 | int vflushbuf(struct vnode *, int); |
532 | int vget(struct vnode *, int, bool); | | 536 | int vget(struct vnode *, int, bool); |
533 | void vgone(struct vnode *); | | 537 | void vgone(struct vnode *); |
534 | int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); | | 538 | int vinvalbuf(struct vnode *, int, kauth_cred_t, struct lwp *, bool, int); |
535 | void vprint(const char *, struct vnode *); | | 539 | void vprint(const char *, struct vnode *); |
536 | void vput(struct vnode *); | | 540 | void vput(struct vnode *); |
537 | bool vrecycle(struct vnode *); | | 541 | bool vrecycle(struct vnode *); |
538 | void vrele(struct vnode *); | | 542 | void vrele(struct vnode *); |
539 | void vrele_async(struct vnode *); | | 543 | void vrele_async(struct vnode *); |
540 | void vrele_flush(void); | | 544 | void vrele_flush(void); |
541 | int vtruncbuf(struct vnode *, daddr_t, bool, int); | | 545 | int vtruncbuf(struct vnode *, daddr_t, bool, int); |
542 | void vwakeup(struct buf *); | | 546 | void vwakeup(struct buf *); |
543 | int vdead_check(struct vnode *, int); | | 547 | int vdead_check(struct vnode *, int); |
544 | void vrevoke(struct vnode *); | | 548 | void vrevoke(struct vnode *); |
545 | struct vnode * | | 549 | struct vnode * |
546 | vnalloc(struct mount *); | | 550 | vnalloc(struct mount *); |
547 | void vnfree(struct vnode *); | | 551 | void vnfree(struct vnode *); |
548 | void vremfree(struct vnode *); | | 552 | void vremfree(struct vnode *); |
549 | int vcache_get(struct mount *, const void *, size_t, struct vnode **); | | 553 | int vcache_get(struct mount *, const void *, size_t, struct vnode **); |
550 | int vcache_new(struct mount *, struct vnode *, | | 554 | int vcache_new(struct mount *, struct vnode *, |
551 | struct vattr *, kauth_cred_t, struct vnode **); | | 555 | struct vattr *, kauth_cred_t, struct vnode **); |
552 | int vcache_rekey_enter(struct mount *, struct vnode *, | | 556 | int vcache_rekey_enter(struct mount *, struct vnode *, |
553 | const void *, size_t, const void *, size_t); | | 557 | const void *, size_t, const void *, size_t); |
554 | void vcache_rekey_exit(struct mount *, struct vnode *, | | 558 | void vcache_rekey_exit(struct mount *, struct vnode *, |
555 | const void *, size_t, const void *, size_t); | | 559 | const void *, size_t, const void *, size_t); |
556 | void vcache_remove(struct mount *, const void *, size_t); | | 560 | void vcache_remove(struct mount *, const void *, size_t); |
557 | | | 561 | |
558 | /* see vnsubr(9) */ | | 562 | /* see vnsubr(9) */ |
559 | int vn_bwrite(void *); | | 563 | int vn_bwrite(void *); |
560 | int vn_close(struct vnode *, int, kauth_cred_t); | | 564 | int vn_close(struct vnode *, int, kauth_cred_t); |
561 | int vn_isunder(struct vnode *, struct vnode *, struct lwp *); | | 565 | int vn_isunder(struct vnode *, struct vnode *, struct lwp *); |
562 | int vn_lock(struct vnode *, int); | | 566 | int vn_lock(struct vnode *, int); |
563 | void vn_markexec(struct vnode *); | | 567 | void vn_markexec(struct vnode *); |
564 | int vn_marktext(struct vnode *); | | 568 | int vn_marktext(struct vnode *); |
565 | int vn_open(struct nameidata *, int, int); | | 569 | int vn_open(struct nameidata *, int, int); |
566 | int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg, | | 570 | int vn_rdwr(enum uio_rw, struct vnode *, void *, int, off_t, enum uio_seg, |
567 | int, kauth_cred_t, size_t *, struct lwp *); | | 571 | int, kauth_cred_t, size_t *, struct lwp *); |
568 | int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *, | | 572 | int vn_readdir(struct file *, char *, int, u_int, int *, struct lwp *, |
569 | off_t **, int *); | | 573 | off_t **, int *); |
570 | int vn_stat(struct vnode *, struct stat *); | | 574 | int vn_stat(struct vnode *, struct stat *); |
571 | int vn_kqfilter(struct file *, struct knote *); | | 575 | int vn_kqfilter(struct file *, struct knote *); |
572 | int vn_writechk(struct vnode *); | | 576 | int vn_writechk(struct vnode *); |
573 | int vn_openchk(struct vnode *, kauth_cred_t, int); | | 577 | int vn_openchk(struct vnode *, kauth_cred_t, int); |
574 | int vn_extattr_get(struct vnode *, int, int, const char *, size_t *, | | 578 | int vn_extattr_get(struct vnode *, int, int, const char *, size_t *, |
575 | void *, struct lwp *); | | 579 | void *, struct lwp *); |
576 | int vn_extattr_set(struct vnode *, int, int, const char *, size_t, | | 580 | int vn_extattr_set(struct vnode *, int, int, const char *, size_t, |
577 | const void *, struct lwp *); | | 581 | const void *, struct lwp *); |
578 | int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *); | | 582 | int vn_extattr_rm(struct vnode *, int, int, const char *, struct lwp *); |
579 | void vn_ra_allocctx(struct vnode *); | | 583 | void vn_ra_allocctx(struct vnode *); |
580 | int vn_fifo_bypass(void *); | | 584 | int vn_fifo_bypass(void *); |
581 | | | 585 | |
582 | /* initialise global vnode management */ | | 586 | /* initialise global vnode management */ |
583 | void vntblinit(void); | | 587 | void vntblinit(void); |
584 | | | 588 | |
585 | /* misc stuff */ | | 589 | /* misc stuff */ |
586 | void sched_sync(void *); | | 590 | void sched_sync(void *); |
587 | void vn_syncer_add_to_worklist(struct vnode *, int); | | 591 | void vn_syncer_add_to_worklist(struct vnode *, int); |
588 | void vn_syncer_remove_from_worklist(struct vnode *); | | 592 | void vn_syncer_remove_from_worklist(struct vnode *); |
589 | int dorevoke(struct vnode *, kauth_cred_t); | | 593 | int dorevoke(struct vnode *, kauth_cred_t); |
590 | int rawdev_mounted(struct vnode *, struct vnode **); | | 594 | int rawdev_mounted(struct vnode *, struct vnode **); |
591 | uint8_t vtype2dt(enum vtype); | | 595 | uint8_t vtype2dt(enum vtype); |
592 | | | 596 | |
593 | /* see vfssubr(9) */ | | 597 | /* see vfssubr(9) */ |
594 | void vfs_getnewfsid(struct mount *); | | 598 | void vfs_getnewfsid(struct mount *); |
595 | int vfs_drainvnodes(long); | | 599 | int vfs_drainvnodes(long); |
596 | void vfs_timestamp(struct timespec *); | | 600 | void vfs_timestamp(struct timespec *); |
597 | #if defined(DDB) || defined(DEBUGPRINT) | | 601 | #if defined(DDB) || defined(DEBUGPRINT) |
598 | void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...) | | 602 | void vfs_vnode_print(struct vnode *, int, void (*)(const char *, ...) |
599 | __printflike(1, 2)); | | 603 | __printflike(1, 2)); |
600 | void vfs_mount_print(struct mount *, int, void (*)(const char *, ...) | | 604 | void vfs_mount_print(struct mount *, int, void (*)(const char *, ...) |
601 | __printflike(1, 2)); | | 605 | __printflike(1, 2)); |
602 | #endif /* DDB */ | | 606 | #endif /* DDB */ |
603 | | | 607 | |
604 | #endif /* _KERNEL */ | | 608 | #endif /* _KERNEL */ |
605 | | | 609 | |
606 | #endif /* !_SYS_VNODE_H_ */ | | 610 | #endif /* !_SYS_VNODE_H_ */ |