author | rsb |
Sat, 25 Feb 2006 01:33:06 -0800 | |
changeset 1488 | 196daa2cf3db |
parent 789 | b348f31ed315 |
child 1925 | 91047fd43318 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
1488 | 5 |
* Common Development and Distribution License (the "License"). |
6 |
* You may not use this file except in compliance with the License. |
|
0 | 7 |
* |
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
/* |
|
1488 | 22 |
* Copyright 2006 Sun Microsystems, Inc. All rights reserved. |
0 | 23 |
* Use is subject to license terms. |
24 |
*/ |
|
25 |
||
26 |
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ |
|
27 |
/* All Rights Reserved */ |
|
28 |
||
29 |
/* |
|
30 |
* University Copyright- Copyright (c) 1982, 1986, 1988 |
|
31 |
* The Regents of the University of California |
|
32 |
* All Rights Reserved |
|
33 |
* |
|
34 |
* University Acknowledgment- Portions of this document are derived from |
|
35 |
* software developed by the University of California, Berkeley, and its |
|
36 |
* contributors. |
|
37 |
*/ |
|
38 |
||
39 |
#ifndef _SYS_VNODE_H |
|
40 |
#define _SYS_VNODE_H |
|
41 |
||
42 |
#pragma ident "%Z%%M% %I% %E% SMI" |
|
43 |
||
44 |
#include <sys/types.h> |
|
45 |
#include <sys/t_lock.h> |
|
46 |
#include <sys/rwstlock.h> |
|
47 |
#include <sys/time_impl.h> |
|
48 |
#include <sys/cred.h> |
|
49 |
#include <sys/uio.h> |
|
50 |
#include <sys/resource.h> |
|
51 |
#include <vm/seg_enum.h> |
|
1488 | 52 |
#include <sys/kstat.h> |
53 |
#include <sys/kmem.h> |
|
54 |
#include <sys/avl.h> |
|
0 | 55 |
#ifdef _KERNEL |
56 |
#include <sys/buf.h> |
|
57 |
#endif /* _KERNEL */ |
|
58 |
||
59 |
#ifdef __cplusplus |
|
60 |
extern "C" { |
|
61 |
#endif |
|
62 |
||
63 |
||
64 |
typedef int (*fs_generic_func_p) (); |
|
65 |
||
66 |
/* |
|
67 |
* File systems use arrays of fs_operation_def structures to form |
|
68 |
* name/value pairs of operations. These arrays get passed to: |
|
69 |
* |
|
70 |
* - vn_make_ops() to create vnodeops |
|
71 |
* - vfs_makefsops()/vfs_setfsops() to create vfsops. |
|
72 |
*/ |
|
73 |
typedef struct fs_operation_def { |
|
74 |
char *name; /* name of operation (NULL at end) */ |
|
75 |
fs_generic_func_p func; /* function implementing operation */ |
|
76 |
} fs_operation_def_t; |
|
77 |
||
78 |
/* |
|
79 |
* The operation registration mechanism uses two master tables of operations: |
|
80 |
* one for vnode operations (vn_ops_table[]) and one for vfs operations |
|
81 |
* (vfs_ops_table[]). These tables are arrays of fs_operation_trans_def |
|
82 |
* structures. They contain all of the information necessary for the system |
|
83 |
* to populate an operations structure (e.g., vnodeops, vfsops). |
|
84 |
* |
|
85 |
* File systems call registration routines (vfs_setfsops(), vfs_makefsops(), |
|
86 |
* and vn_make_ops()) and pass in their operations specification tables |
|
87 |
* (arrays of fs_operation_def structures). These routines use the master |
|
88 |
* table(s) of operations to build a vnodeops or vfsops structure. |
|
89 |
*/ |
|
90 |
typedef struct fs_operation_trans_def { |
|
91 |
char *name; /* name of operation (NULL at end) */ |
|
92 |
int offset; /* byte offset within ops vector */ |
|
93 |
fs_generic_func_p defaultFunc; /* default function */ |
|
94 |
fs_generic_func_p errorFunc; /* error function */ |
|
95 |
} fs_operation_trans_def_t; |
|
96 |
||
97 |
||
98 |
/* |
|
1488 | 99 |
* Statistics for all vnode operations. |
100 |
* All operations record number of ops (since boot/mount/zero'ed). |
|
101 |
* Certain I/O operations (read, write, readdir) also record number |
|
102 |
* of bytes transferred. |
|
103 |
* This appears in two places in the system: one is embedded in each |
|
104 |
* vfs_t. There is also an array of vopstats_t structures allocated |
|
105 |
* on a per-fstype basis. |
|
106 |
*/ |
|
107 |
||
108 |
#define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */ |
|
109 |
||
110 |
typedef struct vopstats { |
|
111 |
kstat_named_t nopen; /* VOP_OPEN */ |
|
112 |
kstat_named_t nclose; /* VOP_CLOSE */ |
|
113 |
kstat_named_t nread; /* VOP_READ */ |
|
114 |
kstat_named_t read_bytes; |
|
115 |
kstat_named_t nwrite; /* VOP_WRITE */ |
|
116 |
kstat_named_t write_bytes; |
|
117 |
kstat_named_t nioctl; /* VOP_IOCTL */ |
|
118 |
kstat_named_t nsetfl; /* VOP_SETFL */ |
|
119 |
kstat_named_t ngetattr; /* VOP_GETATTR */ |
|
120 |
kstat_named_t nsetattr; /* VOP_SETATTR */ |
|
121 |
kstat_named_t naccess; /* VOP_ACCESS */ |
|
122 |
kstat_named_t nlookup; /* VOP_LOOKUP */ |
|
123 |
kstat_named_t ncreate; /* VOP_CREATE */ |
|
124 |
kstat_named_t nremove; /* VOP_REMOVE */ |
|
125 |
kstat_named_t nlink; /* VOP_LINK */ |
|
126 |
kstat_named_t nrename; /* VOP_RENAME */ |
|
127 |
kstat_named_t nmkdir; /* VOP_MKDIR */ |
|
128 |
kstat_named_t nrmdir; /* VOP_RMDIR */ |
|
129 |
kstat_named_t nreaddir; /* VOP_READDIR */ |
|
130 |
kstat_named_t readdir_bytes; |
|
131 |
kstat_named_t nsymlink; /* VOP_SYMLINK */ |
|
132 |
kstat_named_t nreadlink; /* VOP_READLINK */ |
|
133 |
kstat_named_t nfsync; /* VOP_FSYNC */ |
|
134 |
kstat_named_t ninactive; /* VOP_INACTIVE */ |
|
135 |
kstat_named_t nfid; /* VOP_FID */ |
|
136 |
kstat_named_t nrwlock; /* VOP_RWLOCK */ |
|
137 |
kstat_named_t nrwunlock; /* VOP_RWUNLOCK */ |
|
138 |
kstat_named_t nseek; /* VOP_SEEK */ |
|
139 |
kstat_named_t ncmp; /* VOP_CMP */ |
|
140 |
kstat_named_t nfrlock; /* VOP_FRLOCK */ |
|
141 |
kstat_named_t nspace; /* VOP_SPACE */ |
|
142 |
kstat_named_t nrealvp; /* VOP_REALVP */ |
|
143 |
kstat_named_t ngetpage; /* VOP_GETPAGE */ |
|
144 |
kstat_named_t nputpage; /* VOP_PUTPAGE */ |
|
145 |
kstat_named_t nmap; /* VOP_MAP */ |
|
146 |
kstat_named_t naddmap; /* VOP_ADDMAP */ |
|
147 |
kstat_named_t ndelmap; /* VOP_DELMAP */ |
|
148 |
kstat_named_t npoll; /* VOP_POLL */ |
|
149 |
kstat_named_t ndump; /* VOP_DUMP */ |
|
150 |
kstat_named_t npathconf; /* VOP_PATHCONF */ |
|
151 |
kstat_named_t npageio; /* VOP_PAGEIO */ |
|
152 |
kstat_named_t ndumpctl; /* VOP_DUMPCTL */ |
|
153 |
kstat_named_t ndispose; /* VOP_DISPOSE */ |
|
154 |
kstat_named_t nsetsecattr; /* VOP_SETSECATTR */ |
|
155 |
kstat_named_t ngetsecattr; /* VOP_GETSECATTR */ |
|
156 |
kstat_named_t nshrlock; /* VOP_SHRLOCK */ |
|
157 |
kstat_named_t nvnevent; /* VOP_VNEVENT */ |
|
158 |
} vopstats_t; |
|
159 |
||
160 |
/* |
|
0 | 161 |
* The vnode is the focus of all file activity in UNIX. |
162 |
* A vnode is allocated for each active file, each current |
|
163 |
* directory, each mounted-on file, and the root. |
|
164 |
* |
|
165 |
* Each vnode is usually associated with a file-system-specific node (for |
|
166 |
* UFS, this is the in-memory inode). Generally, a vnode and an fs-node |
|
167 |
* should be created and destroyed together as a pair. |
|
168 |
* |
|
169 |
* If a vnode is reused for a new file, it should be reinitialized by calling |
|
170 |
* either vn_reinit() or vn_recycle(). |
|
171 |
* |
|
172 |
* vn_reinit() resets the entire vnode as if it was returned by vn_alloc(). |
|
173 |
* The caller is responsible for setting up the entire vnode after calling |
|
174 |
* vn_reinit(). This is important when using kmem caching where the vnode is |
|
175 |
* allocated by a constructor, for instance. |
|
176 |
* |
|
177 |
* vn_recycle() is used when the file system keeps some state around in both |
|
178 |
* the vnode and the associated FS-node. In UFS, for example, the inode of |
|
179 |
* a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc. |
|
180 |
* remains the same but certain fields related to the previous instance need |
|
181 |
* to be reset. In particular: |
|
182 |
* v_femhead |
|
183 |
* v_path |
|
184 |
* v_rdcnt, v_wrcnt |
|
185 |
* v_mmap_read, v_mmap_write |
|
186 |
*/ |
|
187 |
||
188 |
/* |
|
189 |
* vnode types. VNON means no type. These values are unrelated to |
|
190 |
* values in on-disk inodes. |
|
191 |
*/ |
|
192 |
typedef enum vtype { |
|
193 |
VNON = 0, |
|
194 |
VREG = 1, |
|
195 |
VDIR = 2, |
|
196 |
VBLK = 3, |
|
197 |
VCHR = 4, |
|
198 |
VLNK = 5, |
|
199 |
VFIFO = 6, |
|
200 |
VDOOR = 7, |
|
201 |
VPROC = 8, |
|
202 |
VSOCK = 9, |
|
203 |
VPORT = 10, |
|
204 |
VBAD = 11 |
|
205 |
} vtype_t; |
|
206 |
||
207 |
/* |
|
208 |
* Many of the fields in the vnode are read-only once they are initialized |
|
209 |
* at vnode creation time. Other fields are protected by locks. |
|
210 |
* |
|
211 |
* IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They |
|
212 |
* may not be embedded into the file-system specific node (inode). The |
|
213 |
* size of vnodes may change. |
|
214 |
* |
|
215 |
* The v_lock protects: |
|
216 |
* v_flag |
|
217 |
* v_stream |
|
218 |
* v_count |
|
219 |
* v_shrlocks |
|
220 |
* v_path |
|
221 |
* |
|
222 |
* A special lock (implemented by vn_vfswlock in vnode.c) protects: |
|
223 |
* v_vfsmountedhere |
|
224 |
* |
|
225 |
* The global flock_lock mutex (in flock.c) protects: |
|
226 |
* v_filocks |
|
227 |
* |
|
228 |
* IMPORTANT NOTE: |
|
229 |
* |
|
230 |
* The following vnode fields are considered public and may safely be |
|
231 |
* accessed by file systems or other consumers: |
|
232 |
* |
|
233 |
* v_lock |
|
234 |
* v_flag |
|
235 |
* v_count |
|
236 |
* v_data |
|
237 |
* v_vfsp |
|
238 |
* v_stream |
|
239 |
* v_type |
|
240 |
* v_rdev |
|
241 |
* |
|
242 |
* ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD. |
|
243 |
* In particular, file systems should not access other fields; they may |
|
244 |
* change or even be removed. The functionality which was once provided |
|
245 |
* by these fields is available through vn_* functions. |
|
246 |
*/ |
|
247 |
||
248 |
struct fem_head; /* from fem.h */ |
|
249 |
||
250 |
typedef struct vnode { |
|
251 |
kmutex_t v_lock; /* protects vnode fields */ |
|
252 |
uint_t v_flag; /* vnode flags (see below) */ |
|
253 |
uint_t v_count; /* reference count */ |
|
254 |
void *v_data; /* private data for fs */ |
|
255 |
struct vfs *v_vfsp; /* ptr to containing VFS */ |
|
256 |
struct stdata *v_stream; /* associated stream */ |
|
257 |
enum vtype v_type; /* vnode type */ |
|
258 |
dev_t v_rdev; /* device (VCHR, VBLK) */ |
|
259 |
||
260 |
/* PRIVATE FIELDS BELOW - DO NOT USE */ |
|
261 |
||
262 |
struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */ |
|
263 |
struct vnodeops *v_op; /* vnode operations */ |
|
264 |
struct page *v_pages; /* vnode pages list */ |
|
265 |
pgcnt_t v_npages; /* # pages on this vnode */ |
|
266 |
pgcnt_t v_msnpages; /* # pages charged to v_mset */ |
|
267 |
struct page *v_scanfront; /* scanner front hand */ |
|
268 |
struct page *v_scanback; /* scanner back hand */ |
|
269 |
struct filock *v_filocks; /* ptr to filock list */ |
|
270 |
struct shrlocklist *v_shrlocks; /* ptr to shrlock list */ |
|
271 |
krwlock_t v_nbllock; /* sync for NBMAND locks */ |
|
272 |
kcondvar_t v_cv; /* synchronize locking */ |
|
273 |
void *v_locality; /* hook for locality info */ |
|
274 |
struct fem_head *v_femhead; /* fs monitoring */ |
|
275 |
char *v_path; /* cached path */ |
|
276 |
uint_t v_rdcnt; /* open for read count (VREG only) */ |
|
277 |
uint_t v_wrcnt; /* open for write count (VREG only) */ |
|
278 |
u_longlong_t v_mmap_read; /* mmap read count */ |
|
279 |
u_longlong_t v_mmap_write; /* mmap write count */ |
|
280 |
void *v_mpssdata; /* info for large page mappings */ |
|
281 |
hrtime_t v_scantime; /* last time this vnode was scanned */ |
|
282 |
ushort_t v_mset; /* memory set ID */ |
|
283 |
uint_t v_msflags; /* memory set flags */ |
|
284 |
struct vnode *v_msnext; /* list of vnodes on an mset */ |
|
285 |
struct vnode *v_msprev; /* list of vnodes on an mset */ |
|
286 |
krwlock_t v_mslock; /* protects v_mset */ |
|
287 |
} vnode_t; |
|
288 |
||
289 |
#define IS_DEVVP(vp) \ |
|
290 |
((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO) |
|
291 |
||
292 |
/* |
|
293 |
* vnode flags. |
|
294 |
*/ |
|
295 |
#define VROOT 0x01 /* root of its file system */ |
|
296 |
#define VNOCACHE 0x02 /* don't keep cache pages on vnode */ |
|
297 |
#define VNOMAP 0x04 /* file cannot be mapped/faulted */ |
|
298 |
#define VDUP 0x08 /* file should be dup'ed rather then opened */ |
|
299 |
#define VNOSWAP 0x10 /* file cannot be used as virtual swap device */ |
|
300 |
#define VNOMOUNT 0x20 /* file cannot be covered by mount */ |
|
301 |
#define VISSWAP 0x40 /* vnode is being used for swap */ |
|
302 |
#define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */ |
|
303 |
||
304 |
#define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0) |
|
305 |
||
306 |
typedef struct vn_vfslocks_entry { |
|
307 |
rwstlock_t ve_lock; |
|
308 |
void *ve_vpvfs; |
|
309 |
struct vn_vfslocks_entry *ve_next; |
|
310 |
uint32_t ve_refcnt; |
|
311 |
char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \ |
|
312 |
sizeof (uint32_t)]; |
|
313 |
} vn_vfslocks_entry_t; |
|
314 |
||
315 |
/* |
|
316 |
* The following two flags are used to lock the v_vfsmountedhere field |
|
317 |
*/ |
|
318 |
#define VVFSLOCK 0x100 |
|
319 |
#define VVFSWAIT 0x200 |
|
320 |
||
321 |
/* |
|
322 |
* Used to serialize VM operations on a vnode |
|
323 |
*/ |
|
324 |
#define VVMLOCK 0x400 |
|
325 |
||
326 |
/* |
|
327 |
* Tell vn_open() not to fail a directory open for writing but |
|
328 |
* to go ahead and call VOP_OPEN() to let the filesystem check. |
|
329 |
*/ |
|
330 |
#define VDIROPEN 0x800 |
|
331 |
||
332 |
/* |
|
333 |
* Flag to let the VM system know that this file is most likely a binary |
|
334 |
* or shared library since it has been mmap()ed EXEC at some time. |
|
335 |
*/ |
|
336 |
#define VVMEXEC 0x1000 |
|
337 |
||
338 |
#define VPXFS 0x2000 /* clustering: global fs proxy vnode */ |
|
339 |
||
340 |
#define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS) |
|
341 |
||
342 |
#define V_XATTRDIR 0x4000 /* attribute unnamed directory */ |
|
343 |
||
344 |
#define V_LOCALITY 0x8000 /* whether locality aware */ |
|
345 |
||
346 |
/* |
|
347 |
* Flag that indicates the VM should maintain the v_pages list with all modified |
|
348 |
* pages on one end and unmodified pages at the other. This makes finding dirty |
|
349 |
* pages to write back to disk much faster at the expense of taking a minor |
|
350 |
* fault on the first store instruction which touches a writable page. |
|
351 |
*/ |
|
352 |
#define VMODSORT (0x10000) |
|
353 |
#define IS_VMODSORT(vp) \ |
|
354 |
(pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0) |
|
355 |
||
356 |
#define VISSWAPFS 0x20000 /* vnode is being used for swapfs */ |
|
357 |
#define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0) |
|
358 |
||
359 |
/* |
|
360 |
* Vnode attributes. A bit-mask is supplied as part of the |
|
361 |
* structure to indicate the attributes the caller wants to |
|
362 |
* set (setattr) or extract (getattr). |
|
363 |
*/ |
|
364 |
||
365 |
/* |
|
366 |
* Note that va_nodeid and va_nblocks are 64bit data type. |
|
367 |
* We support large files over NFSV3. With Solaris client and |
|
368 |
* Server that generates 64bit ino's and sizes these fields |
|
369 |
* will overflow if they are 32 bit sizes. |
|
370 |
*/ |
|
371 |
||
372 |
typedef struct vattr { |
|
373 |
uint_t va_mask; /* bit-mask of attributes */ |
|
374 |
vtype_t va_type; /* vnode type (for create) */ |
|
375 |
mode_t va_mode; /* file access mode */ |
|
376 |
uid_t va_uid; /* owner user id */ |
|
377 |
gid_t va_gid; /* owner group id */ |
|
378 |
dev_t va_fsid; /* file system id (dev for now) */ |
|
379 |
u_longlong_t va_nodeid; /* node id */ |
|
380 |
nlink_t va_nlink; /* number of references to file */ |
|
381 |
u_offset_t va_size; /* file size in bytes */ |
|
382 |
timestruc_t va_atime; /* time of last access */ |
|
383 |
timestruc_t va_mtime; /* time of last modification */ |
|
384 |
timestruc_t va_ctime; /* time of last status change */ |
|
385 |
dev_t va_rdev; /* device the file represents */ |
|
386 |
uint_t va_blksize; /* fundamental block size */ |
|
387 |
u_longlong_t va_nblocks; /* # of blocks allocated */ |
|
388 |
uint_t va_seq; /* sequence number */ |
|
389 |
} vattr_t; |
|
390 |
||
391 |
#ifdef _SYSCALL32 |
|
392 |
/* |
|
393 |
* For bigtypes time_t changed to 64 bit on the 64-bit kernel. |
|
394 |
* Define an old version for user/kernel interface |
|
395 |
*/ |
|
396 |
||
397 |
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 |
|
398 |
#pragma pack(4) |
|
399 |
#endif |
|
400 |
||
401 |
typedef struct vattr32 { |
|
402 |
uint32_t va_mask; /* bit-mask of attributes */ |
|
403 |
vtype_t va_type; /* vnode type (for create) */ |
|
404 |
mode32_t va_mode; /* file access mode */ |
|
405 |
uid32_t va_uid; /* owner user id */ |
|
406 |
gid32_t va_gid; /* owner group id */ |
|
407 |
dev32_t va_fsid; /* file system id (dev for now) */ |
|
408 |
u_longlong_t va_nodeid; /* node id */ |
|
409 |
nlink_t va_nlink; /* number of references to file */ |
|
410 |
u_offset_t va_size; /* file size in bytes */ |
|
411 |
timestruc32_t va_atime; /* time of last access */ |
|
412 |
timestruc32_t va_mtime; /* time of last modification */ |
|
413 |
timestruc32_t va_ctime; /* time of last status change */ |
|
414 |
dev32_t va_rdev; /* device the file represents */ |
|
415 |
uint32_t va_blksize; /* fundamental block size */ |
|
416 |
u_longlong_t va_nblocks; /* # of blocks allocated */ |
|
417 |
uint32_t va_seq; /* sequence number */ |
|
418 |
} vattr32_t; |
|
419 |
||
420 |
#if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4 |
|
421 |
#pragma pack() |
|
422 |
#endif |
|
423 |
||
424 |
#else /* not _SYSCALL32 */ |
|
425 |
#define vattr32 vattr |
|
426 |
typedef vattr_t vattr32_t; |
|
427 |
#endif /* _SYSCALL32 */ |
|
428 |
||
429 |
/* |
|
430 |
* Attributes of interest to the caller of setattr or getattr. |
|
431 |
*/ |
|
432 |
#define AT_TYPE 0x0001 |
|
433 |
#define AT_MODE 0x0002 |
|
434 |
#define AT_UID 0x0004 |
|
435 |
#define AT_GID 0x0008 |
|
436 |
#define AT_FSID 0x0010 |
|
437 |
#define AT_NODEID 0x0020 |
|
438 |
#define AT_NLINK 0x0040 |
|
439 |
#define AT_SIZE 0x0080 |
|
440 |
#define AT_ATIME 0x0100 |
|
441 |
#define AT_MTIME 0x0200 |
|
442 |
#define AT_CTIME 0x0400 |
|
443 |
#define AT_RDEV 0x0800 |
|
444 |
#define AT_BLKSIZE 0x1000 |
|
445 |
#define AT_NBLOCKS 0x2000 |
|
446 |
/* 0x4000 */ /* unused */ |
|
447 |
#define AT_SEQ 0x8000 |
|
448 |
||
449 |
#define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\ |
|
450 |
AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\ |
|
451 |
AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) |
|
452 |
||
453 |
#define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\ |
|
454 |
AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE) |
|
455 |
||
456 |
#define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME) |
|
457 |
||
458 |
#define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\ |
|
459 |
AT_BLKSIZE|AT_NBLOCKS|AT_SEQ) |
|
460 |
||
461 |
/* |
|
462 |
* Modes. Some values same as S_xxx entries from stat.h for convenience. |
|
463 |
*/ |
|
464 |
#define VSUID 04000 /* set user id on execution */ |
|
465 |
#define VSGID 02000 /* set group id on execution */ |
|
466 |
#define VSVTX 01000 /* save swapped text even after use */ |
|
467 |
||
468 |
/* |
|
469 |
* Permissions. |
|
470 |
*/ |
|
471 |
#define VREAD 00400 |
|
472 |
#define VWRITE 00200 |
|
473 |
#define VEXEC 00100 |
|
474 |
||
475 |
#define MODEMASK 07777 /* mode bits plus permission bits */ |
|
476 |
#define PERMMASK 00777 /* permission bits */ |
|
477 |
||
478 |
/* |
|
479 |
* Check whether mandatory file locking is enabled. |
|
480 |
*/ |
|
481 |
||
482 |
#define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID) |
|
483 |
#define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode)) |
|
484 |
||
485 |
/* |
|
486 |
* Flags for vnode operations. |
|
487 |
*/ |
|
488 |
enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */ |
|
489 |
enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */ |
|
490 |
enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */ |
|
491 |
enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */ |
|
492 |
||
493 |
typedef enum rm rm_t; |
|
494 |
typedef enum symfollow symfollow_t; |
|
495 |
typedef enum vcexcl vcexcl_t; |
|
496 |
typedef enum create create_t; |
|
497 |
||
498 |
/* Vnode Events - Used by VOP_VNEVENT */ |
|
499 |
typedef enum vnevent { |
|
500 |
VE_SUPPORT = 0, /* Query */ |
|
501 |
VE_RENAME_SRC = 1, /* Rename, with vnode as source */ |
|
502 |
VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */ |
|
503 |
VE_REMOVE = 3, /* Remove of vnode's name */ |
|
504 |
VE_RMDIR = 4 /* Remove of directory vnode's name */ |
|
505 |
} vnevent_t; |
|
506 |
||
507 |
/* |
|
508 |
* Values for checking vnode open and map counts |
|
509 |
*/ |
|
510 |
enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR }; |
|
511 |
||
512 |
typedef enum v_mode v_mode_t; |
|
513 |
||
514 |
#define V_TRUE 1 |
|
515 |
#define V_FALSE 0 |
|
516 |
||
517 |
/* |
|
518 |
* Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations |
|
519 |
*/ |
|
520 |
||
521 |
typedef struct vsecattr { |
|
522 |
uint_t vsa_mask; /* See below */ |
|
523 |
int vsa_aclcnt; /* ACL entry count */ |
|
524 |
void *vsa_aclentp; /* pointer to ACL entries */ |
|
525 |
int vsa_dfaclcnt; /* default ACL entry count */ |
|
526 |
void *vsa_dfaclentp; /* pointer to default ACL entries */ |
|
527 |
} vsecattr_t; |
|
528 |
||
529 |
/* vsa_mask values */ |
|
530 |
#define VSA_ACL 0x0001 |
|
531 |
#define VSA_ACLCNT 0x0002 |
|
532 |
#define VSA_DFACL 0x0004 |
|
533 |
#define VSA_DFACLCNT 0x0008 |
|
534 |
#define VSA_ACE 0x0010 |
|
535 |
#define VSA_ACECNT 0x0020 |
|
536 |
||
537 |
/* |
|
538 |
* Structure used by various vnode operations to determine |
|
539 |
* the context (pid, host, identity) of a caller. |
|
540 |
* |
|
541 |
* The cc_caller_id is used to identify one or more callers who invoke |
|
542 |
* operations, possibly on behalf of others. For example, the NFS |
|
543 |
* server could have it's own cc_caller_id which can be detected by |
|
544 |
* vnode/vfs operations or (FEM) monitors on those operations. New |
|
545 |
* caller IDs are generated by fs_new_caller_id(). |
|
546 |
*/ |
|
547 |
typedef struct caller_context { |
|
548 |
pid_t cc_pid; /* Process ID of the caller */ |
|
549 |
int cc_sysid; /* System ID, used for remote calls */ |
|
550 |
u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */ |
|
551 |
} caller_context_t; |
|
552 |
||
553 |
/* |
|
554 |
* Structure tags for function prototypes, defined elsewhere. |
|
555 |
*/ |
|
556 |
struct pathname; |
|
557 |
struct fid; |
|
558 |
struct flock64; |
|
559 |
struct flk_callback; |
|
560 |
struct shrlock; |
|
561 |
struct page; |
|
562 |
struct seg; |
|
563 |
struct as; |
|
564 |
struct pollhead; |
|
565 |
||
566 |
/* |
|
567 |
* Operations on vnodes. Note: File systems should never operate directly |
|
568 |
* on a 'vnodeops' structure -- it WILL change in future releases! They |
|
569 |
* should use vn_make_ops() to create the structure. |
|
570 |
*/ |
|
571 |
typedef struct vnodeops { |
|
572 |
const char *vnop_name; |
|
573 |
int (*vop_open)(vnode_t **, int, cred_t *); |
|
574 |
int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *); |
|
575 |
int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, |
|
576 |
caller_context_t *); |
|
577 |
int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, |
|
578 |
caller_context_t *); |
|
579 |
int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, int *); |
|
580 |
int (*vop_setfl)(vnode_t *, int, int, cred_t *); |
|
581 |
int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *); |
|
582 |
int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, |
|
583 |
caller_context_t *); |
|
584 |
int (*vop_access)(vnode_t *, int, int, cred_t *); |
|
585 |
int (*vop_lookup)(vnode_t *, char *, vnode_t **, struct pathname *, |
|
586 |
int, vnode_t *, cred_t *); |
|
587 |
int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, int, |
|
588 |
vnode_t **, cred_t *, int); |
|
589 |
int (*vop_remove)(vnode_t *, char *, cred_t *); |
|
590 |
int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *); |
|
591 |
int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, cred_t *); |
|
592 |
int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, |
|
593 |
cred_t *); |
|
594 |
int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *); |
|
595 |
int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *); |
|
596 |
int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, cred_t *); |
|
597 |
int (*vop_readlink)(vnode_t *, uio_t *, cred_t *); |
|
598 |
int (*vop_fsync)(vnode_t *, int, cred_t *); |
|
599 |
void (*vop_inactive)(vnode_t *, cred_t *); |
|
600 |
int (*vop_fid)(vnode_t *, struct fid *); |
|
601 |
int (*vop_rwlock)(vnode_t *, int, caller_context_t *); |
|
602 |
void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); |
|
603 |
int (*vop_seek)(vnode_t *, offset_t, offset_t *); |
|
604 |
int (*vop_cmp)(vnode_t *, vnode_t *); |
|
605 |
int (*vop_frlock)(vnode_t *, int, struct flock64 *, int, offset_t, |
|
606 |
struct flk_callback *, cred_t *); |
|
607 |
int (*vop_space)(vnode_t *, int, struct flock64 *, int, offset_t, |
|
608 |
cred_t *, caller_context_t *); |
|
609 |
int (*vop_realvp)(vnode_t *, vnode_t **); |
|
610 |
int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, |
|
611 |
struct page **, size_t, struct seg *, |
|
612 |
caddr_t, enum seg_rw, cred_t *); |
|
613 |
int (*vop_putpage)(vnode_t *, offset_t, size_t, int, cred_t *); |
|
614 |
int (*vop_map)(vnode_t *, offset_t, struct as *, caddr_t *, size_t, |
|
615 |
uchar_t, uchar_t, uint_t, cred_t *); |
|
616 |
int (*vop_addmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, |
|
617 |
uchar_t, uchar_t, uint_t, cred_t *); |
|
618 |
int (*vop_delmap)(vnode_t *, offset_t, struct as *, caddr_t, size_t, |
|
619 |
uint_t, uint_t, uint_t, cred_t *); |
|
620 |
int (*vop_poll)(vnode_t *, short, int, short *, struct pollhead **); |
|
621 |
int (*vop_dump)(vnode_t *, caddr_t, int, int); |
|
622 |
int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *); |
|
623 |
int (*vop_pageio)(vnode_t *, struct page *, u_offset_t, size_t, |
|
624 |
int, cred_t *); |
|
625 |
int (*vop_dumpctl)(vnode_t *, int, int *); |
|
626 |
void (*vop_dispose)(vnode_t *, struct page *, int, int, cred_t *); |
|
627 |
int (*vop_setsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); |
|
628 |
int (*vop_getsecattr)(vnode_t *, vsecattr_t *, int, cred_t *); |
|
629 |
int (*vop_shrlock)(vnode_t *, int, struct shrlock *, int, cred_t *); |
|
630 |
int (*vop_vnevent)(vnode_t *, vnevent_t); |
|
631 |
} vnodeops_t; |
|
632 |
||
633 |
#ifdef _KERNEL |
|
634 |
||
635 |
extern int fop_open(vnode_t **, int, cred_t *); |
|
636 |
extern int fop_close(vnode_t *, int, int, offset_t, cred_t *); |
|
637 |
extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *); |
|
638 |
extern int fop_write(vnode_t *, uio_t *, int, cred_t *, |
|
639 |
caller_context_t *); |
|
640 |
extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *); |
|
641 |
extern int fop_setfl(vnode_t *, int, int, cred_t *); |
|
642 |
extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *); |
|
643 |
extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *, |
|
644 |
caller_context_t *); |
|
645 |
extern int fop_access(vnode_t *, int, int, cred_t *); |
|
646 |
extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *, |
|
647 |
int, vnode_t *, cred_t *); |
|
648 |
extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int, |
|
649 |
vnode_t **, cred_t *, int); |
|
650 |
extern int fop_remove(vnode_t *vp, char *, cred_t *); |
|
651 |
extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *); |
|
652 |
extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *); |
|
653 |
extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *); |
|
654 |
extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *); |
|
655 |
extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *); |
|
656 |
extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *); |
|
657 |
extern int fop_readlink(vnode_t *, uio_t *, cred_t *); |
|
658 |
extern int fop_fsync(vnode_t *, int, cred_t *); |
|
659 |
extern void fop_inactive(vnode_t *, cred_t *); |
|
660 |
extern int fop_fid(vnode_t *, struct fid *); |
|
661 |
extern int fop_rwlock(vnode_t *, int, caller_context_t *); |
|
662 |
extern void fop_rwunlock(vnode_t *, int, caller_context_t *); |
|
663 |
extern int fop_seek(vnode_t *, offset_t, offset_t *); |
|
664 |
extern int fop_cmp(vnode_t *, vnode_t *); |
|
665 |
extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t, |
|
666 |
struct flk_callback *, cred_t *); |
|
667 |
extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t, |
|
668 |
cred_t *, caller_context_t *); |
|
669 |
extern int fop_realvp(vnode_t *, vnode_t **); |
|
670 |
extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *, |
|
671 |
struct page **, size_t, struct seg *, |
|
672 |
caddr_t, enum seg_rw, cred_t *); |
|
673 |
extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *); |
|
674 |
extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t, |
|
675 |
uchar_t, uchar_t, uint_t, cred_t *cr); |
|
676 |
extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, |
|
677 |
uchar_t, uchar_t, uint_t, cred_t *); |
|
678 |
extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t, |
|
679 |
uint_t, uint_t, uint_t, cred_t *); |
|
680 |
extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **); |
|
681 |
extern int fop_dump(vnode_t *, caddr_t, int, int); |
|
682 |
extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *); |
|
683 |
extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int, |
|
684 |
cred_t *); |
|
685 |
extern int fop_dumpctl(vnode_t *, int, int *); |
|
686 |
extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *); |
|
687 |
extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *); |
|
688 |
extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *); |
|
689 |
extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *); |
|
690 |
extern int fop_vnevent(vnode_t *, vnevent_t); |
|
691 |
||
692 |
#endif /* _KERNEL */ |
|
693 |
||
694 |
#define VOP_OPEN(vpp, mode, cr) \ |
|
695 |
fop_open(vpp, mode, cr) |
|
696 |
#define VOP_CLOSE(vp, f, c, o, cr) \ |
|
697 |
fop_close(vp, f, c, o, cr) |
|
698 |
#define VOP_READ(vp, uiop, iof, cr, ct) \ |
|
699 |
fop_read(vp, uiop, iof, cr, ct) |
|
700 |
#define VOP_WRITE(vp, uiop, iof, cr, ct) \ |
|
701 |
fop_write(vp, uiop, iof, cr, ct) |
|
702 |
#define VOP_IOCTL(vp, cmd, a, f, cr, rvp) \ |
|
703 |
fop_ioctl(vp, cmd, a, f, cr, rvp) |
|
704 |
#define VOP_SETFL(vp, f, a, cr) \ |
|
705 |
fop_setfl(vp, f, a, cr) |
|
706 |
#define VOP_GETATTR(vp, vap, f, cr) \ |
|
707 |
fop_getattr(vp, vap, f, cr) |
|
708 |
#define VOP_SETATTR(vp, vap, f, cr, ct) \ |
|
709 |
fop_setattr(vp, vap, f, cr, ct) |
|
710 |
#define VOP_ACCESS(vp, mode, f, cr) \ |
|
711 |
fop_access(vp, mode, f, cr) |
|
712 |
#define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr) \ |
|
713 |
fop_lookup(vp, cp, vpp, pnp, f, rdir, cr) |
|
714 |
#define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag) \ |
|
715 |
fop_create(dvp, p, vap, ex, mode, vpp, cr, flag) |
|
716 |
#define VOP_REMOVE(dvp, p, cr) \ |
|
717 |
fop_remove(dvp, p, cr) |
|
718 |
#define VOP_LINK(tdvp, fvp, p, cr) \ |
|
719 |
fop_link(tdvp, fvp, p, cr) |
|
720 |
#define VOP_RENAME(fvp, fnm, tdvp, tnm, cr) \ |
|
721 |
fop_rename(fvp, fnm, tdvp, tnm, cr) |
|
722 |
#define VOP_MKDIR(dp, p, vap, vpp, cr) \ |
|
723 |
fop_mkdir(dp, p, vap, vpp, cr) |
|
724 |
#define VOP_RMDIR(dp, p, cdir, cr) \ |
|
725 |
fop_rmdir(dp, p, cdir, cr) |
|
726 |
#define VOP_READDIR(vp, uiop, cr, eofp) \ |
|
727 |
fop_readdir(vp, uiop, cr, eofp) |
|
728 |
#define VOP_SYMLINK(dvp, lnm, vap, tnm, cr) \ |
|
729 |
fop_symlink(dvp, lnm, vap, tnm, cr) |
|
730 |
#define VOP_READLINK(vp, uiop, cr) \ |
|
731 |
fop_readlink(vp, uiop, cr) |
|
732 |
#define VOP_FSYNC(vp, syncflag, cr) \ |
|
733 |
fop_fsync(vp, syncflag, cr) |
|
734 |
#define VOP_INACTIVE(vp, cr) \ |
|
735 |
fop_inactive(vp, cr) |
|
736 |
#define VOP_FID(vp, fidp) \ |
|
737 |
fop_fid(vp, fidp) |
|
738 |
#define VOP_RWLOCK(vp, w, ct) \ |
|
739 |
fop_rwlock(vp, w, ct) |
|
740 |
#define VOP_RWUNLOCK(vp, w, ct) \ |
|
741 |
fop_rwunlock(vp, w, ct) |
|
742 |
#define VOP_SEEK(vp, ooff, noffp) \ |
|
743 |
fop_seek(vp, ooff, noffp) |
|
744 |
#define VOP_CMP(vp1, vp2) \ |
|
745 |
fop_cmp(vp1, vp2) |
|
746 |
#define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr) \ |
|
747 |
fop_frlock(vp, cmd, a, f, o, cb, cr) |
|
748 |
#define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \ |
|
749 |
fop_space(vp, cmd, a, f, o, cr, ct) |
|
750 |
#define VOP_REALVP(vp1, vp2) \ |
|
751 |
fop_realvp(vp1, vp2) |
|
752 |
#define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr) \ |
|
753 |
fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr) |
|
754 |
#define VOP_PUTPAGE(vp, of, sz, fl, cr) \ |
|
755 |
fop_putpage(vp, of, sz, fl, cr) |
|
756 |
#define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr) \ |
|
757 |
fop_map(vp, of, as, a, sz, p, mp, fl, cr) |
|
758 |
#define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr) \ |
|
759 |
fop_addmap(vp, of, as, a, sz, p, mp, fl, cr) |
|
760 |
#define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr) \ |
|
761 |
fop_delmap(vp, of, as, a, sz, p, mp, fl, cr) |
|
762 |
#define VOP_POLL(vp, events, anyyet, reventsp, phpp) \ |
|
763 |
fop_poll(vp, events, anyyet, reventsp, phpp) |
|
764 |
#define VOP_DUMP(vp, addr, bn, count) \ |
|
765 |
fop_dump(vp, addr, bn, count) |
|
766 |
#define VOP_PATHCONF(vp, cmd, valp, cr) \ |
|
767 |
fop_pathconf(vp, cmd, valp, cr) |
|
768 |
#define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr) \ |
|
769 |
fop_pageio(vp, pp, io_off, io_len, flags, cr) |
|
770 |
#define VOP_DUMPCTL(vp, action, blkp) \ |
|
771 |
fop_dumpctl(vp, action, blkp) |
|
772 |
#define VOP_DISPOSE(vp, pp, flag, dn, cr) \ |
|
773 |
fop_dispose(vp, pp, flag, dn, cr) |
|
774 |
#define VOP_GETSECATTR(vp, vsap, f, cr) \ |
|
775 |
fop_getsecattr(vp, vsap, f, cr) |
|
776 |
#define VOP_SETSECATTR(vp, vsap, f, cr) \ |
|
777 |
fop_setsecattr(vp, vsap, f, cr) |
|
778 |
#define VOP_SHRLOCK(vp, cmd, shr, f, cr) \ |
|
779 |
fop_shrlock(vp, cmd, shr, f, cr) |
|
780 |
#define VOP_VNEVENT(vp, vnevent) \ |
|
781 |
fop_vnevent(vp, vnevent) |
|
782 |
||
783 |
#define VOPNAME_OPEN "open" |
|
784 |
#define VOPNAME_CLOSE "close" |
|
785 |
#define VOPNAME_READ "read" |
|
786 |
#define VOPNAME_WRITE "write" |
|
787 |
#define VOPNAME_IOCTL "ioctl" |
|
788 |
#define VOPNAME_SETFL "setfl" |
|
789 |
#define VOPNAME_GETATTR "getattr" |
|
790 |
#define VOPNAME_SETATTR "setattr" |
|
791 |
#define VOPNAME_ACCESS "access" |
|
792 |
#define VOPNAME_LOOKUP "lookup" |
|
793 |
#define VOPNAME_CREATE "create" |
|
794 |
#define VOPNAME_REMOVE "remove" |
|
795 |
#define VOPNAME_LINK "link" |
|
796 |
#define VOPNAME_RENAME "rename" |
|
797 |
#define VOPNAME_MKDIR "mkdir" |
|
798 |
#define VOPNAME_RMDIR "rmdir" |
|
799 |
#define VOPNAME_READDIR "readdir" |
|
800 |
#define VOPNAME_SYMLINK "symlink" |
|
801 |
#define VOPNAME_READLINK "readlink" |
|
802 |
#define VOPNAME_FSYNC "fsync" |
|
803 |
#define VOPNAME_INACTIVE "inactive" |
|
804 |
#define VOPNAME_FID "fid" |
|
805 |
#define VOPNAME_RWLOCK "rwlock" |
|
806 |
#define VOPNAME_RWUNLOCK "rwunlock" |
|
807 |
#define VOPNAME_SEEK "seek" |
|
808 |
#define VOPNAME_CMP "cmp" |
|
809 |
#define VOPNAME_FRLOCK "frlock" |
|
810 |
#define VOPNAME_SPACE "space" |
|
811 |
#define VOPNAME_REALVP "realvp" |
|
812 |
#define VOPNAME_GETPAGE "getpage" |
|
813 |
#define VOPNAME_PUTPAGE "putpage" |
|
814 |
#define VOPNAME_MAP "map" |
|
815 |
#define VOPNAME_ADDMAP "addmap" |
|
816 |
#define VOPNAME_DELMAP "delmap" |
|
817 |
#define VOPNAME_POLL "poll" |
|
818 |
#define VOPNAME_DUMP "dump" |
|
819 |
#define VOPNAME_PATHCONF "pathconf" |
|
820 |
#define VOPNAME_PAGEIO "pageio" |
|
821 |
#define VOPNAME_DUMPCTL "dumpctl" |
|
822 |
#define VOPNAME_DISPOSE "dispose" |
|
823 |
#define VOPNAME_GETSECATTR "getsecattr" |
|
824 |
#define VOPNAME_SETSECATTR "setsecattr" |
|
825 |
#define VOPNAME_SHRLOCK "shrlock" |
|
826 |
#define VOPNAME_VNEVENT "vnevent" |
|
827 |
||
828 |
/* |
|
829 |
* Flags for VOP_LOOKUP |
|
830 |
*/ |
|
831 |
#define LOOKUP_DIR 0x01 /* want parent dir vp */ |
|
832 |
#define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */ |
|
833 |
#define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */ |
|
834 |
||
835 |
/* |
|
836 |
* Flags for VOP_RWLOCK/VOP_RWUNLOCK |
|
837 |
* VOP_RWLOCK will return the flag that was actually set, or -1 if none. |
|
838 |
*/ |
|
839 |
#define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */ |
|
840 |
#define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */ |
|
841 |
||
842 |
/* |
|
843 |
* Flags for VOP_DUMPCTL |
|
844 |
*/ |
|
845 |
#define DUMP_ALLOC 0 |
|
846 |
#define DUMP_FREE 1 |
|
847 |
#define DUMP_SCAN 2 |
|
848 |
||
849 |
/* |
|
850 |
* Public vnode manipulation functions. |
|
851 |
*/ |
|
852 |
#ifdef _KERNEL |
|
853 |
||
854 |
vnode_t *vn_alloc(int); |
|
855 |
void vn_reinit(vnode_t *); |
|
856 |
void vn_recycle(vnode_t *); |
|
857 |
void vn_free(vnode_t *); |
|
858 |
||
859 |
int vn_is_readonly(vnode_t *); |
|
860 |
int vn_is_opened(vnode_t *, v_mode_t); |
|
861 |
int vn_is_mapped(vnode_t *, v_mode_t); |
|
862 |
||
863 |
int vn_can_change_zones(vnode_t *vp); |
|
864 |
||
865 |
int vn_has_flocks(vnode_t *); |
|
866 |
int vn_has_mandatory_locks(vnode_t *, int); |
|
867 |
int vn_has_cached_data(vnode_t *); |
|
868 |
||
869 |
void vn_setops(vnode_t *, vnodeops_t *); |
|
870 |
vnodeops_t *vn_getops(vnode_t *); |
|
871 |
int vn_matchops(vnode_t *, vnodeops_t *); |
|
872 |
int vn_matchopval(vnode_t *, char *, fs_generic_func_p); |
|
873 |
int vn_ismntpt(vnode_t *); |
|
874 |
||
875 |
struct vfs *vn_mountedvfs(vnode_t *); |
|
876 |
||
877 |
void vn_create_cache(void); |
|
878 |
void vn_destroy_cache(void); |
|
879 |
||
880 |
int vn_make_ops(const char *, const fs_operation_def_t *, vnodeops_t **); |
|
881 |
void vn_freevnodeops(vnodeops_t *); |
|
882 |
||
883 |
int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode, |
|
884 |
struct vnode **vpp, enum create crwhy, mode_t umask); |
|
885 |
int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode, |
|
886 |
struct vnode **vpp, enum create crwhy, |
|
887 |
mode_t umask, struct vnode *startvp); |
|
888 |
int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap, |
|
889 |
enum vcexcl excl, int mode, struct vnode **vpp, |
|
890 |
enum create why, int flag, mode_t umask); |
|
891 |
int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap, |
|
892 |
enum vcexcl excl, int mode, struct vnode **vpp, |
|
893 |
enum create why, int flag, mode_t umask, struct vnode *startvp); |
|
894 |
int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len, |
|
895 |
offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit, |
|
896 |
cred_t *cr, ssize_t *residp); |
|
897 |
void vn_rele(struct vnode *vp); |
|
898 |
void vn_rele_stream(struct vnode *vp); |
|
899 |
int vn_link(char *from, char *to, enum uio_seg seg); |
|
900 |
int vn_rename(char *from, char *to, enum uio_seg seg); |
|
901 |
int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname, |
|
902 |
enum uio_seg seg); |
|
903 |
int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag); |
|
904 |
int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg, |
|
905 |
enum rm dirflag); |
|
906 |
int vn_compare(vnode_t *vp1, vnode_t *vp2); |
|
907 |
int vn_vfswlock(struct vnode *vp); |
|
908 |
int vn_vfswlock_wait(struct vnode *vp); |
|
909 |
int vn_vfsrlock(struct vnode *vp); |
|
910 |
int vn_vfsrlock_wait(struct vnode *vp); |
|
911 |
void vn_vfsunlock(struct vnode *vp); |
|
912 |
int vn_vfswlock_held(struct vnode *vp); |
|
913 |
vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr); |
|
914 |
vnode_t *makespecvp(dev_t dev, vtype_t type); |
|
915 |
vn_vfslocks_entry_t *vn_vfslocks_getlock(void *); |
|
916 |
void vn_vfslocks_rele(vn_vfslocks_entry_t *); |
|
917 |
||
254
349581d9fc98
6175313 io provider exposes our reluctance to set vnode paths
eschrock
parents:
0
diff
changeset
|
918 |
void vn_copypath(struct vnode *src, struct vnode *dst); |
349581d9fc98
6175313 io provider exposes our reluctance to set vnode paths
eschrock
parents:
0
diff
changeset
|
919 |
void vn_setpath_str(struct vnode *vp, const char *str, size_t len); |
349581d9fc98
6175313 io provider exposes our reluctance to set vnode paths
eschrock
parents:
0
diff
changeset
|
920 |
void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp, |
349581d9fc98
6175313 io provider exposes our reluctance to set vnode paths
eschrock
parents:
0
diff
changeset
|
921 |
const char *path, size_t plen); |
349581d9fc98
6175313 io provider exposes our reluctance to set vnode paths
eschrock
parents:
0
diff
changeset
|
922 |
|
0 | 923 |
/* Vnode event notification */ |
924 |
void vnevent_rename_src(vnode_t *); |
|
925 |
void vnevent_rename_dest(vnode_t *); |
|
926 |
void vnevent_remove(vnode_t *); |
|
927 |
void vnevent_rmdir(vnode_t *); |
|
928 |
int vnevent_support(vnode_t *); |
|
929 |
||
930 |
/* Context identification */ |
|
931 |
u_longlong_t fs_new_caller_id(); |
|
932 |
||
933 |
int vn_vmpss_usepageio(vnode_t *); |
|
934 |
||
935 |
/* |
|
936 |
* Needed for use of IS_VMODSORT() in kernel. |
|
937 |
*/ |
|
938 |
extern uint_t pvn_vmodsort_supported; |
|
939 |
||
940 |
#define VN_HOLD(vp) { \ |
|
941 |
mutex_enter(&(vp)->v_lock); \ |
|
942 |
(vp)->v_count++; \ |
|
943 |
mutex_exit(&(vp)->v_lock); \ |
|
944 |
} |
|
945 |
||
946 |
#define VN_RELE(vp) { \ |
|
947 |
vn_rele(vp); \ |
|
948 |
} |
|
949 |
||
950 |
#define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \ |
|
951 |
(vp)->v_vfsp = (vfsp); \ |
|
952 |
(vp)->v_type = (type); \ |
|
953 |
(vp)->v_rdev = (dev); \ |
|
954 |
} |
|
955 |
||
956 |
/* |
|
957 |
* Compare two vnodes for equality. In general this macro should be used |
|
958 |
* in preference to calling VOP_CMP directly. |
|
959 |
*/ |
|
960 |
#define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \ |
|
961 |
((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \ |
|
962 |
VOP_CMP(VP1, VP2) : 0)) |
|
963 |
||
964 |
#endif /* _KERNEL */ |
|
965 |
||
966 |
/* |
|
967 |
* Flags to VOP_SETATTR/VOP_GETATTR. |
|
968 |
*/ |
|
969 |
#define ATTR_UTIME 0x01 /* non-default utime(2) request */ |
|
970 |
#define ATTR_EXEC 0x02 /* invocation from exec(2) */ |
|
971 |
#define ATTR_COMM 0x04 /* yield common vp attributes */ |
|
972 |
#define ATTR_HINT 0x08 /* information returned will be `hint' */ |
|
973 |
#define ATTR_REAL 0x10 /* yield attributes of the real vp */ |
|
974 |
||
975 |
/* |
|
976 |
* Generally useful macros. |
|
977 |
*/ |
|
978 |
#define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize) |
|
789 | 979 |
|
980 |
#define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone) |
|
981 |
||
0 | 982 |
#define NULLVP ((struct vnode *)0) |
983 |
#define NULLVPP ((struct vnode **)0) |
|
984 |
||
985 |
#ifdef _KERNEL |
|
986 |
||
987 |
/* |
|
988 |
* Structure used while handling asynchronous VOP_PUTPAGE operations. |
|
989 |
*/ |
|
990 |
struct async_reqs { |
|
991 |
struct async_reqs *a_next; /* pointer to next arg struct */ |
|
992 |
struct vnode *a_vp; /* vnode pointer */ |
|
993 |
u_offset_t a_off; /* offset in file */ |
|
994 |
uint_t a_len; /* size of i/o request */ |
|
995 |
int a_flags; /* flags to indicate operation type */ |
|
996 |
struct cred *a_cred; /* cred pointer */ |
|
997 |
ushort_t a_prealloced; /* set if struct is pre-allocated */ |
|
998 |
}; |
|
999 |
||
1000 |
/* |
|
1001 |
* VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE(). |
|
1002 |
*/ |
|
1003 |
#define VN_DISPOSE(pp, flag, dn, cr) { \ |
|
1004 |
extern struct vnode kvp; \ |
|
1005 |
if ((pp)->p_vnode != NULL && (pp)->p_vnode != &kvp) \ |
|
1006 |
VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr)); \ |
|
1007 |
else if ((flag) == B_FREE) \ |
|
1008 |
page_free((pp), (dn)); \ |
|
1009 |
else \ |
|
1010 |
page_destroy((pp), (dn)); \ |
|
1011 |
} |
|
1012 |
||
1013 |
#endif /* _KERNEL */ |
|
1014 |
||
1015 |
#ifdef __cplusplus |
|
1016 |
} |
|
1017 |
#endif |
|
1018 |
||
1019 |
#endif /* _SYS_VNODE_H */ |