Print this page
OS-5148 ftruncate at offset should emit proper events
Reviewed by: Bryan Cantrill <bryan@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Fix vnode.h mismerge
OS-3294 add support for inotify
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Robert Mustacchi <rm@joyent.com>
| Split |
Close |
| Expand all |
| Collapse all |
--- old/usr/src/uts/common/sys/vnode.h
+++ new/usr/src/uts/common/sys/vnode.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
|
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 - * Copyright (c) 2013, Joyent, Inc. All rights reserved.
24 + * Copyright (c) 2014, Joyent, Inc. All rights reserved.
25 25 */
26 26
27 27 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
28 28 /* All Rights Reserved */
29 29
30 30 /*
31 31 * University Copyright- Copyright (c) 1982, 1986, 1988
32 32 * The Regents of the University of California
33 33 * All Rights Reserved
34 34 *
35 35 * University Acknowledgment- Portions of this document are derived from
36 36 * software developed by the University of California, Berkeley, and its
37 37 * contributors.
38 38 */
39 39
40 40 #ifndef _SYS_VNODE_H
41 41 #define _SYS_VNODE_H
42 42
43 43 #include <sys/types.h>
44 44 #include <sys/t_lock.h>
45 45 #include <sys/rwstlock.h>
46 46 #include <sys/time_impl.h>
47 47 #include <sys/cred.h>
48 48 #include <sys/uio.h>
49 49 #include <sys/resource.h>
50 50 #include <vm/seg_enum.h>
51 51 #include <sys/kstat.h>
52 52 #include <sys/kmem.h>
53 53 #include <sys/list.h>
54 54 #ifdef _KERNEL
55 55 #include <sys/buf.h>
56 56 #endif /* _KERNEL */
57 57
58 58 #ifdef __cplusplus
59 59 extern "C" {
60 60 #endif
61 61
62 62 /*
63 63 * Statistics for all vnode operations.
64 64 * All operations record number of ops (since boot/mount/zero'ed).
65 65 * Certain I/O operations (read, write, readdir) also record number
66 66 * of bytes transferred.
67 67 * This appears in two places in the system: one is embedded in each
68 68 * vfs_t. There is also an array of vopstats_t structures allocated
69 69 * on a per-fstype basis.
70 70 */
71 71
72 72 #define VOPSTATS_STR "vopstats_" /* Initial string for vopstat kstats */
73 73
74 74 typedef struct vopstats {
75 75 kstat_named_t nopen; /* VOP_OPEN */
76 76 kstat_named_t nclose; /* VOP_CLOSE */
77 77 kstat_named_t nread; /* VOP_READ */
78 78 kstat_named_t read_bytes;
79 79 kstat_named_t nwrite; /* VOP_WRITE */
80 80 kstat_named_t write_bytes;
81 81 kstat_named_t nioctl; /* VOP_IOCTL */
82 82 kstat_named_t nsetfl; /* VOP_SETFL */
83 83 kstat_named_t ngetattr; /* VOP_GETATTR */
84 84 kstat_named_t nsetattr; /* VOP_SETATTR */
85 85 kstat_named_t naccess; /* VOP_ACCESS */
86 86 kstat_named_t nlookup; /* VOP_LOOKUP */
87 87 kstat_named_t ncreate; /* VOP_CREATE */
88 88 kstat_named_t nremove; /* VOP_REMOVE */
89 89 kstat_named_t nlink; /* VOP_LINK */
90 90 kstat_named_t nrename; /* VOP_RENAME */
91 91 kstat_named_t nmkdir; /* VOP_MKDIR */
92 92 kstat_named_t nrmdir; /* VOP_RMDIR */
93 93 kstat_named_t nreaddir; /* VOP_READDIR */
94 94 kstat_named_t readdir_bytes;
95 95 kstat_named_t nsymlink; /* VOP_SYMLINK */
96 96 kstat_named_t nreadlink; /* VOP_READLINK */
97 97 kstat_named_t nfsync; /* VOP_FSYNC */
98 98 kstat_named_t ninactive; /* VOP_INACTIVE */
99 99 kstat_named_t nfid; /* VOP_FID */
100 100 kstat_named_t nrwlock; /* VOP_RWLOCK */
101 101 kstat_named_t nrwunlock; /* VOP_RWUNLOCK */
102 102 kstat_named_t nseek; /* VOP_SEEK */
103 103 kstat_named_t ncmp; /* VOP_CMP */
104 104 kstat_named_t nfrlock; /* VOP_FRLOCK */
105 105 kstat_named_t nspace; /* VOP_SPACE */
106 106 kstat_named_t nrealvp; /* VOP_REALVP */
107 107 kstat_named_t ngetpage; /* VOP_GETPAGE */
108 108 kstat_named_t nputpage; /* VOP_PUTPAGE */
109 109 kstat_named_t nmap; /* VOP_MAP */
110 110 kstat_named_t naddmap; /* VOP_ADDMAP */
111 111 kstat_named_t ndelmap; /* VOP_DELMAP */
112 112 kstat_named_t npoll; /* VOP_POLL */
113 113 kstat_named_t ndump; /* VOP_DUMP */
114 114 kstat_named_t npathconf; /* VOP_PATHCONF */
115 115 kstat_named_t npageio; /* VOP_PAGEIO */
116 116 kstat_named_t ndumpctl; /* VOP_DUMPCTL */
117 117 kstat_named_t ndispose; /* VOP_DISPOSE */
118 118 kstat_named_t nsetsecattr; /* VOP_SETSECATTR */
119 119 kstat_named_t ngetsecattr; /* VOP_GETSECATTR */
120 120 kstat_named_t nshrlock; /* VOP_SHRLOCK */
121 121 kstat_named_t nvnevent; /* VOP_VNEVENT */
122 122 kstat_named_t nreqzcbuf; /* VOP_REQZCBUF */
123 123 kstat_named_t nretzcbuf; /* VOP_RETZCBUF */
124 124 } vopstats_t;
125 125
126 126 /*
127 127 * The vnode is the focus of all file activity in UNIX.
128 128 * A vnode is allocated for each active file, each current
129 129 * directory, each mounted-on file, and the root.
130 130 *
131 131 * Each vnode is usually associated with a file-system-specific node (for
132 132 * UFS, this is the in-memory inode). Generally, a vnode and an fs-node
133 133 * should be created and destroyed together as a pair.
134 134 *
135 135 * If a vnode is reused for a new file, it should be reinitialized by calling
136 136 * either vn_reinit() or vn_recycle().
137 137 *
138 138 * vn_reinit() resets the entire vnode as if it was returned by vn_alloc().
139 139 * The caller is responsible for setting up the entire vnode after calling
140 140 * vn_reinit(). This is important when using kmem caching where the vnode is
141 141 * allocated by a constructor, for instance.
142 142 *
143 143 * vn_recycle() is used when the file system keeps some state around in both
144 144 * the vnode and the associated FS-node. In UFS, for example, the inode of
145 145 * a deleted file can be reused immediately. The v_data, v_vfsp, v_op, etc.
146 146 * remains the same but certain fields related to the previous instance need
147 147 * to be reset. In particular:
148 148 * v_femhead
149 149 * v_path
150 150 * v_rdcnt, v_wrcnt
151 151 * v_mmap_read, v_mmap_write
152 152 */
153 153
154 154 /*
155 155 * vnode types. VNON means no type. These values are unrelated to
156 156 * values in on-disk inodes.
157 157 */
158 158 typedef enum vtype {
159 159 VNON = 0,
160 160 VREG = 1,
161 161 VDIR = 2,
162 162 VBLK = 3,
163 163 VCHR = 4,
164 164 VLNK = 5,
165 165 VFIFO = 6,
166 166 VDOOR = 7,
167 167 VPROC = 8,
168 168 VSOCK = 9,
169 169 VPORT = 10,
170 170 VBAD = 11
171 171 } vtype_t;
172 172
173 173 /*
174 174 * VSD - Vnode Specific Data
175 175 * Used to associate additional private data with a vnode.
176 176 */
177 177 struct vsd_node {
178 178 list_node_t vs_nodes; /* list of all VSD nodes */
179 179 uint_t vs_nkeys; /* entries in value array */
180 180 void **vs_value; /* array of value/key */
181 181 };
182 182
183 183 /*
184 184 * Many of the fields in the vnode are read-only once they are initialized
185 185 * at vnode creation time. Other fields are protected by locks.
186 186 *
187 187 * IMPORTANT: vnodes should be created ONLY by calls to vn_alloc(). They
188 188 * may not be embedded into the file-system specific node (inode). The
189 189 * size of vnodes may change.
190 190 *
191 191 * The v_lock protects:
192 192 * v_flag
193 193 * v_stream
194 194 * v_count
195 195 * v_shrlocks
196 196 * v_path
197 197 * v_vsd
198 198 * v_xattrdir
199 199 *
200 200 * A special lock (implemented by vn_vfswlock in vnode.c) protects:
201 201 * v_vfsmountedhere
202 202 *
203 203 * The global flock_lock mutex (in flock.c) protects:
204 204 * v_filocks
205 205 *
206 206 * IMPORTANT NOTE:
207 207 *
208 208 * The following vnode fields are considered public and may safely be
209 209 * accessed by file systems or other consumers:
210 210 *
211 211 * v_lock
212 212 * v_flag
213 213 * v_count
214 214 * v_data
215 215 * v_vfsp
216 216 * v_stream
217 217 * v_type
218 218 * v_rdev
219 219 *
220 220 * ALL OTHER FIELDS SHOULD BE ACCESSED ONLY BY THE OWNER OF THAT FIELD.
221 221 * In particular, file systems should not access other fields; they may
222 222 * change or even be removed. The functionality which was once provided
223 223 * by these fields is available through vn_* functions.
224 224 */
225 225
226 226 struct fem_head; /* from fem.h */
227 227
228 228 typedef struct vnode {
229 229 kmutex_t v_lock; /* protects vnode fields */
230 230 uint_t v_flag; /* vnode flags (see below) */
231 231 uint_t v_count; /* reference count */
232 232 void *v_data; /* private data for fs */
233 233 struct vfs *v_vfsp; /* ptr to containing VFS */
234 234 struct stdata *v_stream; /* associated stream */
235 235 enum vtype v_type; /* vnode type */
236 236 dev_t v_rdev; /* device (VCHR, VBLK) */
237 237
238 238 /* PRIVATE FIELDS BELOW - DO NOT USE */
239 239
240 240 struct vfs *v_vfsmountedhere; /* ptr to vfs mounted here */
241 241 struct vnodeops *v_op; /* vnode operations */
242 242 struct page *v_pages; /* vnode pages list */
243 243 struct filock *v_filocks; /* ptr to filock list */
244 244 struct shrlocklist *v_shrlocks; /* ptr to shrlock list */
245 245 krwlock_t v_nbllock; /* sync for NBMAND locks */
246 246 kcondvar_t v_cv; /* synchronize locking */
247 247 void *v_locality; /* hook for locality info */
248 248 struct fem_head *v_femhead; /* fs monitoring */
249 249 char *v_path; /* cached path */
250 250 uint_t v_rdcnt; /* open for read count (VREG only) */
251 251 uint_t v_wrcnt; /* open for write count (VREG only) */
252 252 u_longlong_t v_mmap_read; /* mmap read count */
253 253 u_longlong_t v_mmap_write; /* mmap write count */
254 254 void *v_mpssdata; /* info for large page mappings */
255 255 void *v_fopdata; /* list of file ops event watches */
256 256 kmutex_t v_vsd_lock; /* protects v_vsd field */
257 257 struct vsd_node *v_vsd; /* vnode specific data */
258 258 struct vnode *v_xattrdir; /* unnamed extended attr dir (GFS) */
259 259 uint_t v_count_dnlc; /* dnlc reference count */
260 260 } vnode_t;
261 261
262 262 #define IS_DEVVP(vp) \
263 263 ((vp)->v_type == VCHR || (vp)->v_type == VBLK || (vp)->v_type == VFIFO)
264 264
265 265 #define VNODE_ALIGN 64
266 266 /* Count of low-order 0 bits in a vnode *, based on size and alignment. */
267 267 #if defined(_LP64)
268 268 #define VNODE_ALIGN_LOG2 8
269 269 #else
270 270 #define VNODE_ALIGN_LOG2 7
271 271 #endif
272 272
273 273 /*
274 274 * vnode flags.
275 275 */
276 276 #define VROOT 0x01 /* root of its file system */
277 277 #define VNOCACHE 0x02 /* don't keep cache pages on vnode */
278 278 #define VNOMAP 0x04 /* file cannot be mapped/faulted */
279 279 #define VDUP 0x08 /* file should be dup'ed rather then opened */
280 280 #define VNOSWAP 0x10 /* file cannot be used as virtual swap device */
281 281 #define VNOMOUNT 0x20 /* file cannot be covered by mount */
282 282 #define VISSWAP 0x40 /* vnode is being used for swap */
283 283 #define VSWAPLIKE 0x80 /* vnode acts like swap (but may not be) */
284 284
285 285 #define IS_SWAPVP(vp) (((vp)->v_flag & (VISSWAP | VSWAPLIKE)) != 0)
286 286
287 287 typedef struct vn_vfslocks_entry {
288 288 rwstlock_t ve_lock;
289 289 void *ve_vpvfs;
290 290 struct vn_vfslocks_entry *ve_next;
291 291 uint32_t ve_refcnt;
292 292 char pad[64 - sizeof (rwstlock_t) - 2 * sizeof (void *) - \
293 293 sizeof (uint32_t)];
294 294 } vn_vfslocks_entry_t;
295 295
296 296 /*
297 297 * The following two flags are used to lock the v_vfsmountedhere field
298 298 */
299 299 #define VVFSLOCK 0x100
300 300 #define VVFSWAIT 0x200
301 301
302 302 /*
303 303 * Used to serialize VM operations on a vnode
304 304 */
305 305 #define VVMLOCK 0x400
306 306
307 307 /*
308 308 * Tell vn_open() not to fail a directory open for writing but
309 309 * to go ahead and call VOP_OPEN() to let the filesystem check.
310 310 */
311 311 #define VDIROPEN 0x800
312 312
313 313 /*
314 314 * Flag to let the VM system know that this file is most likely a binary
315 315 * or shared library since it has been mmap()ed EXEC at some time.
316 316 */
317 317 #define VVMEXEC 0x1000
318 318
319 319 #define VPXFS 0x2000 /* clustering: global fs proxy vnode */
320 320
321 321 #define IS_PXFSVP(vp) ((vp)->v_flag & VPXFS)
322 322
323 323 #define V_XATTRDIR 0x4000 /* attribute unnamed directory */
324 324
325 325 #define IS_XATTRDIR(vp) ((vp)->v_flag & V_XATTRDIR)
326 326
327 327 #define V_LOCALITY 0x8000 /* whether locality aware */
328 328
329 329 /*
330 330 * Flag that indicates the VM should maintain the v_pages list with all modified
331 331 * pages on one end and unmodified pages at the other. This makes finding dirty
332 332 * pages to write back to disk much faster at the expense of taking a minor
333 333 * fault on the first store instruction which touches a writable page.
334 334 */
335 335 #define VMODSORT (0x10000)
336 336 #define IS_VMODSORT(vp) \
337 337 (pvn_vmodsort_supported != 0 && ((vp)->v_flag & VMODSORT) != 0)
338 338
339 339 #define VISSWAPFS 0x20000 /* vnode is being used for swapfs */
340 340
341 341 /*
342 342 * The mdb memstat command assumes that IS_SWAPFSVP only uses the
343 343 * vnode's v_flag field. If this changes, cache the additional
344 344 * fields in mdb; see vn_get in mdb/common/modules/genunix/memory.c
345 345 */
346 346 #define IS_SWAPFSVP(vp) (((vp)->v_flag & VISSWAPFS) != 0)
347 347
348 348 #define V_SYSATTR 0x40000 /* vnode is a GFS system attribute */
349 349
350 350 /*
351 351 * Vnode attributes. A bit-mask is supplied as part of the
352 352 * structure to indicate the attributes the caller wants to
353 353 * set (setattr) or extract (getattr).
354 354 */
355 355
356 356 /*
357 357 * Note that va_nodeid and va_nblocks are 64bit data type.
358 358 * We support large files over NFSV3. With Solaris client and
359 359 * Server that generates 64bit ino's and sizes these fields
360 360 * will overflow if they are 32 bit sizes.
361 361 */
362 362
363 363 typedef struct vattr {
364 364 uint_t va_mask; /* bit-mask of attributes */
365 365 vtype_t va_type; /* vnode type (for create) */
366 366 mode_t va_mode; /* file access mode */
367 367 uid_t va_uid; /* owner user id */
368 368 gid_t va_gid; /* owner group id */
369 369 dev_t va_fsid; /* file system id (dev for now) */
370 370 u_longlong_t va_nodeid; /* node id */
371 371 nlink_t va_nlink; /* number of references to file */
372 372 u_offset_t va_size; /* file size in bytes */
373 373 timestruc_t va_atime; /* time of last access */
374 374 timestruc_t va_mtime; /* time of last modification */
375 375 timestruc_t va_ctime; /* time of last status change */
376 376 dev_t va_rdev; /* device the file represents */
377 377 uint_t va_blksize; /* fundamental block size */
378 378 u_longlong_t va_nblocks; /* # of blocks allocated */
379 379 uint_t va_seq; /* sequence number */
380 380 } vattr_t;
381 381
382 382 #define AV_SCANSTAMP_SZ 32 /* length of anti-virus scanstamp */
383 383
384 384 /*
385 385 * Structure of all optional attributes.
386 386 */
387 387 typedef struct xoptattr {
388 388 timestruc_t xoa_createtime; /* Create time of file */
389 389 uint8_t xoa_archive;
390 390 uint8_t xoa_system;
391 391 uint8_t xoa_readonly;
392 392 uint8_t xoa_hidden;
393 393 uint8_t xoa_nounlink;
394 394 uint8_t xoa_immutable;
395 395 uint8_t xoa_appendonly;
396 396 uint8_t xoa_nodump;
397 397 uint8_t xoa_opaque;
398 398 uint8_t xoa_av_quarantined;
399 399 uint8_t xoa_av_modified;
400 400 uint8_t xoa_av_scanstamp[AV_SCANSTAMP_SZ];
401 401 uint8_t xoa_reparse;
402 402 uint64_t xoa_generation;
403 403 uint8_t xoa_offline;
404 404 uint8_t xoa_sparse;
405 405 } xoptattr_t;
406 406
407 407 /*
408 408 * The xvattr structure is really a variable length structure that
409 409 * is made up of:
410 410 * - The classic vattr_t (xva_vattr)
411 411 * - a 32 bit quantity (xva_mapsize) that specifies the size of the
412 412 * attribute bitmaps in 32 bit words.
413 413 * - A pointer to the returned attribute bitmap (needed because the
414 414 * previous element, the requested attribute bitmap) is variable lenth.
415 415 * - The requested attribute bitmap, which is an array of 32 bit words.
416 416 * Callers use the XVA_SET_REQ() macro to set the bits corresponding to
417 417 * the attributes that are being requested.
418 418 * - The returned attribute bitmap, which is an array of 32 bit words.
419 419 * File systems that support optional attributes use the XVA_SET_RTN()
420 420 * macro to set the bits corresponding to the attributes that are being
421 421 * returned.
422 422 * - The xoptattr_t structure which contains the attribute values
423 423 *
424 424 * xva_mapsize determines how many words in the attribute bitmaps.
425 425 * Immediately following the attribute bitmaps is the xoptattr_t.
426 426 * xva_getxoptattr() is used to get the pointer to the xoptattr_t
427 427 * section.
428 428 */
429 429
430 430 #define XVA_MAPSIZE 3 /* Size of attr bitmaps */
431 431 #define XVA_MAGIC 0x78766174 /* Magic # for verification */
432 432
433 433 /*
434 434 * The xvattr structure is an extensible structure which permits optional
435 435 * attributes to be requested/returned. File systems may or may not support
436 436 * optional attributes. They do so at their own discretion but if they do
437 437 * support optional attributes, they must register the VFSFT_XVATTR feature
438 438 * so that the optional attributes can be set/retrived.
439 439 *
440 440 * The fields of the xvattr structure are:
441 441 *
442 442 * xva_vattr - The first element of an xvattr is a legacy vattr structure
443 443 * which includes the common attributes. If AT_XVATTR is set in the va_mask
444 444 * then the entire structure is treated as an xvattr. If AT_XVATTR is not
445 445 * set, then only the xva_vattr structure can be used.
446 446 *
447 447 * xva_magic - 0x78766174 (hex for "xvat"). Magic number for verification.
448 448 *
449 449 * xva_mapsize - Size of requested and returned attribute bitmaps.
450 450 *
451 451 * xva_rtnattrmapp - Pointer to xva_rtnattrmap[]. We need this since the
452 452 * size of the array before it, xva_reqattrmap[], could change which means
453 453 * the location of xva_rtnattrmap[] could change. This will allow unbundled
454 454 * file systems to find the location of xva_rtnattrmap[] when the sizes change.
455 455 *
456 456 * xva_reqattrmap[] - Array of requested attributes. Attributes are
457 457 * represented by a specific bit in a specific element of the attribute
458 458 * map array. Callers set the bits corresponding to the attributes
459 459 * that the caller wants to get/set.
460 460 *
461 461 * xva_rtnattrmap[] - Array of attributes that the file system was able to
462 462 * process. Not all file systems support all optional attributes. This map
463 463 * informs the caller which attributes the underlying file system was able
464 464 * to set/get. (Same structure as the requested attributes array in terms
465 465 * of each attribute corresponding to specific bits and array elements.)
466 466 *
467 467 * xva_xoptattrs - Structure containing values of optional attributes.
468 468 * These values are only valid if the corresponding bits in xva_reqattrmap
469 469 * are set and the underlying file system supports those attributes.
470 470 */
471 471 typedef struct xvattr {
472 472 vattr_t xva_vattr; /* Embedded vattr structure */
473 473 uint32_t xva_magic; /* Magic Number */
474 474 uint32_t xva_mapsize; /* Size of attr bitmap (32-bit words) */
475 475 uint32_t *xva_rtnattrmapp; /* Ptr to xva_rtnattrmap[] */
476 476 uint32_t xva_reqattrmap[XVA_MAPSIZE]; /* Requested attrs */
477 477 uint32_t xva_rtnattrmap[XVA_MAPSIZE]; /* Returned attrs */
478 478 xoptattr_t xva_xoptattrs; /* Optional attributes */
479 479 } xvattr_t;
480 480
481 481 #ifdef _SYSCALL32
482 482 /*
483 483 * For bigtypes time_t changed to 64 bit on the 64-bit kernel.
484 484 * Define an old version for user/kernel interface
485 485 */
486 486
487 487 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
488 488 #pragma pack(4)
489 489 #endif
490 490
491 491 typedef struct vattr32 {
492 492 uint32_t va_mask; /* bit-mask of attributes */
493 493 vtype_t va_type; /* vnode type (for create) */
494 494 mode32_t va_mode; /* file access mode */
495 495 uid32_t va_uid; /* owner user id */
496 496 gid32_t va_gid; /* owner group id */
497 497 dev32_t va_fsid; /* file system id (dev for now) */
498 498 u_longlong_t va_nodeid; /* node id */
499 499 nlink_t va_nlink; /* number of references to file */
500 500 u_offset_t va_size; /* file size in bytes */
501 501 timestruc32_t va_atime; /* time of last access */
502 502 timestruc32_t va_mtime; /* time of last modification */
503 503 timestruc32_t va_ctime; /* time of last status change */
504 504 dev32_t va_rdev; /* device the file represents */
505 505 uint32_t va_blksize; /* fundamental block size */
506 506 u_longlong_t va_nblocks; /* # of blocks allocated */
507 507 uint32_t va_seq; /* sequence number */
508 508 } vattr32_t;
509 509
510 510 #if _LONG_LONG_ALIGNMENT == 8 && _LONG_LONG_ALIGNMENT_32 == 4
511 511 #pragma pack()
512 512 #endif
513 513
514 514 #else /* not _SYSCALL32 */
515 515 #define vattr32 vattr
516 516 typedef vattr_t vattr32_t;
517 517 #endif /* _SYSCALL32 */
518 518
519 519 /*
520 520 * Attributes of interest to the caller of setattr or getattr.
521 521 */
522 522 #define AT_TYPE 0x00001
523 523 #define AT_MODE 0x00002
524 524 #define AT_UID 0x00004
525 525 #define AT_GID 0x00008
526 526 #define AT_FSID 0x00010
527 527 #define AT_NODEID 0x00020
528 528 #define AT_NLINK 0x00040
529 529 #define AT_SIZE 0x00080
530 530 #define AT_ATIME 0x00100
531 531 #define AT_MTIME 0x00200
532 532 #define AT_CTIME 0x00400
533 533 #define AT_RDEV 0x00800
534 534 #define AT_BLKSIZE 0x01000
535 535 #define AT_NBLOCKS 0x02000
536 536 /* 0x04000 */ /* unused */
537 537 #define AT_SEQ 0x08000
538 538 /*
539 539 * If AT_XVATTR is set then there are additional bits to process in
540 540 * the xvattr_t's attribute bitmap. If this is not set then the bitmap
541 541 * MUST be ignored. Note that this bit must be set/cleared explicitly.
542 542 * That is, setting AT_ALL will NOT set AT_XVATTR.
543 543 */
544 544 #define AT_XVATTR 0x10000
545 545
546 546 #define AT_ALL (AT_TYPE|AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|\
547 547 AT_NLINK|AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|\
548 548 AT_RDEV|AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
549 549
550 550 #define AT_STAT (AT_MODE|AT_UID|AT_GID|AT_FSID|AT_NODEID|AT_NLINK|\
551 551 AT_SIZE|AT_ATIME|AT_MTIME|AT_CTIME|AT_RDEV|AT_TYPE)
552 552
553 553 #define AT_TIMES (AT_ATIME|AT_MTIME|AT_CTIME)
554 554
555 555 #define AT_NOSET (AT_NLINK|AT_RDEV|AT_FSID|AT_NODEID|AT_TYPE|\
556 556 AT_BLKSIZE|AT_NBLOCKS|AT_SEQ)
557 557
558 558 /*
559 559 * Attribute bits used in the extensible attribute's (xva's) attribute
560 560 * bitmaps. Note that the bitmaps are made up of a variable length number
561 561 * of 32-bit words. The convention is to use XAT{n}_{attrname} where "n"
562 562 * is the element in the bitmap (starting at 1). This convention is for
563 563 * the convenience of the maintainer to keep track of which element each
564 564 * attribute belongs to.
565 565 *
566 566 * NOTE THAT CONSUMERS MUST *NOT* USE THE XATn_* DEFINES DIRECTLY. CONSUMERS
567 567 * MUST USE THE XAT_* DEFINES.
568 568 */
569 569 #define XAT0_INDEX 0LL /* Index into bitmap for XAT0 attrs */
570 570 #define XAT0_CREATETIME 0x00000001 /* Create time of file */
571 571 #define XAT0_ARCHIVE 0x00000002 /* Archive */
572 572 #define XAT0_SYSTEM 0x00000004 /* System */
573 573 #define XAT0_READONLY 0x00000008 /* Readonly */
574 574 #define XAT0_HIDDEN 0x00000010 /* Hidden */
575 575 #define XAT0_NOUNLINK 0x00000020 /* Nounlink */
576 576 #define XAT0_IMMUTABLE 0x00000040 /* immutable */
577 577 #define XAT0_APPENDONLY 0x00000080 /* appendonly */
578 578 #define XAT0_NODUMP 0x00000100 /* nodump */
579 579 #define XAT0_OPAQUE 0x00000200 /* opaque */
580 580 #define XAT0_AV_QUARANTINED 0x00000400 /* anti-virus quarantine */
581 581 #define XAT0_AV_MODIFIED 0x00000800 /* anti-virus modified */
582 582 #define XAT0_AV_SCANSTAMP 0x00001000 /* anti-virus scanstamp */
583 583 #define XAT0_REPARSE 0x00002000 /* FS reparse point */
584 584 #define XAT0_GEN 0x00004000 /* object generation number */
585 585 #define XAT0_OFFLINE 0x00008000 /* offline */
586 586 #define XAT0_SPARSE 0x00010000 /* sparse */
587 587
588 588 #define XAT0_ALL_ATTRS (XAT0_CREATETIME|XAT0_ARCHIVE|XAT0_SYSTEM| \
589 589 XAT0_READONLY|XAT0_HIDDEN|XAT0_NOUNLINK|XAT0_IMMUTABLE|XAT0_APPENDONLY| \
590 590 XAT0_NODUMP|XAT0_OPAQUE|XAT0_AV_QUARANTINED| XAT0_AV_MODIFIED| \
591 591 XAT0_AV_SCANSTAMP|XAT0_REPARSE|XATO_GEN|XAT0_OFFLINE|XAT0_SPARSE)
592 592
593 593 /* Support for XAT_* optional attributes */
594 594 #define XVA_MASK 0xffffffff /* Used to mask off 32 bits */
595 595 #define XVA_SHFT 32 /* Used to shift index */
596 596
597 597 /*
598 598 * Used to pry out the index and attribute bits from the XAT_* attributes
599 599 * defined below. Note that we're masking things down to 32 bits then
600 600 * casting to uint32_t.
601 601 */
602 602 #define XVA_INDEX(attr) ((uint32_t)(((attr) >> XVA_SHFT) & XVA_MASK))
603 603 #define XVA_ATTRBIT(attr) ((uint32_t)((attr) & XVA_MASK))
604 604
605 605 /*
606 606 * The following defines present a "flat namespace" so that consumers don't
607 607 * need to keep track of which element belongs to which bitmap entry.
608 608 *
609 609 * NOTE THAT THESE MUST NEVER BE OR-ed TOGETHER
610 610 */
611 611 #define XAT_CREATETIME ((XAT0_INDEX << XVA_SHFT) | XAT0_CREATETIME)
612 612 #define XAT_ARCHIVE ((XAT0_INDEX << XVA_SHFT) | XAT0_ARCHIVE)
613 613 #define XAT_SYSTEM ((XAT0_INDEX << XVA_SHFT) | XAT0_SYSTEM)
614 614 #define XAT_READONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_READONLY)
615 615 #define XAT_HIDDEN ((XAT0_INDEX << XVA_SHFT) | XAT0_HIDDEN)
616 616 #define XAT_NOUNLINK ((XAT0_INDEX << XVA_SHFT) | XAT0_NOUNLINK)
617 617 #define XAT_IMMUTABLE ((XAT0_INDEX << XVA_SHFT) | XAT0_IMMUTABLE)
618 618 #define XAT_APPENDONLY ((XAT0_INDEX << XVA_SHFT) | XAT0_APPENDONLY)
619 619 #define XAT_NODUMP ((XAT0_INDEX << XVA_SHFT) | XAT0_NODUMP)
620 620 #define XAT_OPAQUE ((XAT0_INDEX << XVA_SHFT) | XAT0_OPAQUE)
621 621 #define XAT_AV_QUARANTINED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_QUARANTINED)
622 622 #define XAT_AV_MODIFIED ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_MODIFIED)
623 623 #define XAT_AV_SCANSTAMP ((XAT0_INDEX << XVA_SHFT) | XAT0_AV_SCANSTAMP)
624 624 #define XAT_REPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_REPARSE)
625 625 #define XAT_GEN ((XAT0_INDEX << XVA_SHFT) | XAT0_GEN)
626 626 #define XAT_OFFLINE ((XAT0_INDEX << XVA_SHFT) | XAT0_OFFLINE)
627 627 #define XAT_SPARSE ((XAT0_INDEX << XVA_SHFT) | XAT0_SPARSE)
628 628
629 629 /*
630 630 * The returned attribute map array (xva_rtnattrmap[]) is located past the
631 631 * requested attribute map array (xva_reqattrmap[]). Its location changes
632 632 * when the array sizes change. We use a separate pointer in a known location
633 633 * (xva_rtnattrmapp) to hold the location of xva_rtnattrmap[]. This is
634 634 * set in xva_init()
635 635 */
636 636 #define XVA_RTNATTRMAP(xvap) ((xvap)->xva_rtnattrmapp)
637 637
638 638 /*
639 639 * XVA_SET_REQ() sets an attribute bit in the proper element in the bitmap
640 640 * of requested attributes (xva_reqattrmap[]).
641 641 */
642 642 #define XVA_SET_REQ(xvap, attr) \
643 643 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \
644 644 ASSERT((xvap)->xva_magic == XVA_MAGIC); \
645 645 (xvap)->xva_reqattrmap[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
646 646 /*
647 647 * XVA_CLR_REQ() clears an attribute bit in the proper element in the bitmap
648 648 * of requested attributes (xva_reqattrmap[]).
649 649 */
650 650 #define XVA_CLR_REQ(xvap, attr) \
651 651 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \
652 652 ASSERT((xvap)->xva_magic == XVA_MAGIC); \
653 653 (xvap)->xva_reqattrmap[XVA_INDEX(attr)] &= ~XVA_ATTRBIT(attr)
654 654
655 655 /*
656 656 * XVA_SET_RTN() sets an attribute bit in the proper element in the bitmap
657 657 * of returned attributes (xva_rtnattrmap[]).
658 658 */
659 659 #define XVA_SET_RTN(xvap, attr) \
660 660 ASSERT((xvap)->xva_vattr.va_mask | AT_XVATTR); \
661 661 ASSERT((xvap)->xva_magic == XVA_MAGIC); \
662 662 (XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] |= XVA_ATTRBIT(attr)
663 663
664 664 /*
665 665 * XVA_ISSET_REQ() checks the requested attribute bitmap (xva_reqattrmap[])
666 666 * to see of the corresponding attribute bit is set. If so, returns non-zero.
667 667 */
668 668 #define XVA_ISSET_REQ(xvap, attr) \
669 669 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \
670 670 ((xvap)->xva_magic == XVA_MAGIC) && \
671 671 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \
672 672 ((xvap)->xva_reqattrmap[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
673 673
674 674 /*
675 675 * XVA_ISSET_RTN() checks the returned attribute bitmap (xva_rtnattrmap[])
676 676 * to see of the corresponding attribute bit is set. If so, returns non-zero.
677 677 */
678 678 #define XVA_ISSET_RTN(xvap, attr) \
679 679 ((((xvap)->xva_vattr.va_mask | AT_XVATTR) && \
680 680 ((xvap)->xva_magic == XVA_MAGIC) && \
681 681 ((xvap)->xva_mapsize > XVA_INDEX(attr))) ? \
682 682 ((XVA_RTNATTRMAP(xvap))[XVA_INDEX(attr)] & XVA_ATTRBIT(attr)) : 0)
683 683
684 684 /*
685 685 * Modes. Some values same as S_xxx entries from stat.h for convenience.
686 686 */
687 687 #define VSUID 04000 /* set user id on execution */
688 688 #define VSGID 02000 /* set group id on execution */
689 689 #define VSVTX 01000 /* save swapped text even after use */
690 690
691 691 /*
692 692 * Permissions.
693 693 */
694 694 #define VREAD 00400
695 695 #define VWRITE 00200
696 696 #define VEXEC 00100
697 697
698 698 #define MODEMASK 07777 /* mode bits plus permission bits */
699 699 #define PERMMASK 00777 /* permission bits */
700 700
701 701 /*
702 702 * VOP_ACCESS flags
703 703 */
704 704 #define V_ACE_MASK 0x1 /* mask represents NFSv4 ACE permissions */
705 705 #define V_APPEND 0x2 /* want to do append only check */
706 706
707 707 /*
708 708 * Check whether mandatory file locking is enabled.
709 709 */
710 710
711 711 #define MANDMODE(mode) (((mode) & (VSGID|(VEXEC>>3))) == VSGID)
712 712 #define MANDLOCK(vp, mode) ((vp)->v_type == VREG && MANDMODE(mode))
713 713
714 714 /*
715 715 * Flags for vnode operations.
716 716 */
717 717 enum rm { RMFILE, RMDIRECTORY }; /* rm or rmdir (remove) */
718 718 enum symfollow { NO_FOLLOW, FOLLOW }; /* follow symlinks (or not) */
719 719 enum vcexcl { NONEXCL, EXCL }; /* (non)excl create */
720 720 enum create { CRCREAT, CRMKNOD, CRMKDIR }; /* reason for create */
721 721
722 722 typedef enum rm rm_t;
723 723 typedef enum symfollow symfollow_t;
724 724 typedef enum vcexcl vcexcl_t;
725 725 typedef enum create create_t;
726 726
727 727 /*
728 728 * Vnode Events - Used by VOP_VNEVENT
729 729 * The VE_PRE_RENAME_* events fire before the rename operation and are
730 730 * primarily used for specialized applications, such as NFSv4 delegation, which
731 731 * need to know about rename before it occurs.
732 732 */
733 733 typedef enum vnevent {
734 734 VE_SUPPORT = 0, /* Query */
735 735 VE_RENAME_SRC = 1, /* Rename, with vnode as source */
|
↓ open down ↓ |
701 lines elided |
↑ open up ↑ |
736 736 VE_RENAME_DEST = 2, /* Rename, with vnode as target/destination */
737 737 VE_REMOVE = 3, /* Remove of vnode's name */
738 738 VE_RMDIR = 4, /* Remove of directory vnode's name */
739 739 VE_CREATE = 5, /* Create with vnode's name which exists */
740 740 VE_LINK = 6, /* Link with vnode's name as source */
741 741 VE_RENAME_DEST_DIR = 7, /* Rename with vnode as target dir */
742 742 VE_MOUNTEDOVER = 8, /* File or Filesystem got mounted over vnode */
743 743 VE_TRUNCATE = 9, /* Truncate */
744 744 VE_PRE_RENAME_SRC = 10, /* Pre-rename, with vnode as source */
745 745 VE_PRE_RENAME_DEST = 11, /* Pre-rename, with vnode as target/dest. */
746 - VE_PRE_RENAME_DEST_DIR = 12 /* Pre-rename with vnode as target dir */
746 + VE_PRE_RENAME_DEST_DIR = 12, /* Pre-rename with vnode as target dir */
747 + VE_RENAME_SRC_DIR = 13, /* Rename with vnode as source dir */
748 + VE_RESIZE = 14 /* Resize/truncate to non-zero offset */
747 749 } vnevent_t;
748 750
749 751 /*
750 752 * Values for checking vnode open and map counts
751 753 */
752 754 enum v_mode { V_READ, V_WRITE, V_RDORWR, V_RDANDWR };
753 755
754 756 typedef enum v_mode v_mode_t;
755 757
756 758 #define V_TRUE 1
757 759 #define V_FALSE 0
758 760
759 761 /*
760 762 * Structure used on VOP_GETSECATTR and VOP_SETSECATTR operations
761 763 */
762 764
763 765 typedef struct vsecattr {
764 766 uint_t vsa_mask; /* See below */
765 767 int vsa_aclcnt; /* ACL entry count */
766 768 void *vsa_aclentp; /* pointer to ACL entries */
767 769 int vsa_dfaclcnt; /* default ACL entry count */
768 770 void *vsa_dfaclentp; /* pointer to default ACL entries */
769 771 size_t vsa_aclentsz; /* ACE size in bytes of vsa_aclentp */
770 772 uint_t vsa_aclflags; /* ACE ACL flags */
771 773 } vsecattr_t;
772 774
773 775 /* vsa_mask values */
774 776 #define VSA_ACL 0x0001
775 777 #define VSA_ACLCNT 0x0002
776 778 #define VSA_DFACL 0x0004
777 779 #define VSA_DFACLCNT 0x0008
778 780 #define VSA_ACE 0x0010
779 781 #define VSA_ACECNT 0x0020
780 782 #define VSA_ACE_ALLTYPES 0x0040
781 783 #define VSA_ACE_ACLFLAGS 0x0080 /* get/set ACE ACL flags */
782 784
783 785 /*
784 786 * Structure used by various vnode operations to determine
785 787 * the context (pid, host, identity) of a caller.
786 788 *
787 789 * The cc_caller_id is used to identify one or more callers who invoke
788 790 * operations, possibly on behalf of others. For example, the NFS
789 791 * server could have it's own cc_caller_id which can be detected by
790 792 * vnode/vfs operations or (FEM) monitors on those operations. New
791 793 * caller IDs are generated by fs_new_caller_id().
792 794 */
793 795 typedef struct caller_context {
794 796 pid_t cc_pid; /* Process ID of the caller */
795 797 int cc_sysid; /* System ID, used for remote calls */
796 798 u_longlong_t cc_caller_id; /* Identifier for (set of) caller(s) */
797 799 ulong_t cc_flags;
798 800 } caller_context_t;
799 801
800 802 /*
801 803 * Flags for caller context. The caller sets CC_DONTBLOCK if it does not
802 804 * want to block inside of a FEM monitor. The monitor will set CC_WOULDBLOCK
803 805 * and return EAGAIN if the operation would have blocked.
804 806 */
805 807 #define CC_WOULDBLOCK 0x01
806 808 #define CC_DONTBLOCK 0x02
807 809
808 810 /*
809 811 * Structure tags for function prototypes, defined elsewhere.
810 812 */
811 813 struct pathname;
812 814 struct fid;
813 815 struct flock64;
814 816 struct flk_callback;
815 817 struct shrlock;
816 818 struct page;
817 819 struct seg;
818 820 struct as;
819 821 struct pollhead;
820 822 struct taskq;
821 823
822 824 #ifdef _KERNEL
823 825
824 826 /*
825 827 * VNODE_OPS defines all the vnode operations. It is used to define
826 828 * the vnodeops structure (below) and the fs_func_p union (vfs_opreg.h).
827 829 */
828 830 #define VNODE_OPS \
829 831 int (*vop_open)(vnode_t **, int, cred_t *, \
830 832 caller_context_t *); \
831 833 int (*vop_close)(vnode_t *, int, int, offset_t, cred_t *, \
832 834 caller_context_t *); \
833 835 int (*vop_read)(vnode_t *, uio_t *, int, cred_t *, \
834 836 caller_context_t *); \
835 837 int (*vop_write)(vnode_t *, uio_t *, int, cred_t *, \
836 838 caller_context_t *); \
837 839 int (*vop_ioctl)(vnode_t *, int, intptr_t, int, cred_t *, \
838 840 int *, caller_context_t *); \
839 841 int (*vop_setfl)(vnode_t *, int, int, cred_t *, \
840 842 caller_context_t *); \
841 843 int (*vop_getattr)(vnode_t *, vattr_t *, int, cred_t *, \
842 844 caller_context_t *); \
843 845 int (*vop_setattr)(vnode_t *, vattr_t *, int, cred_t *, \
844 846 caller_context_t *); \
845 847 int (*vop_access)(vnode_t *, int, int, cred_t *, \
846 848 caller_context_t *); \
847 849 int (*vop_lookup)(vnode_t *, char *, vnode_t **, \
848 850 struct pathname *, \
849 851 int, vnode_t *, cred_t *, \
850 852 caller_context_t *, int *, \
851 853 struct pathname *); \
852 854 int (*vop_create)(vnode_t *, char *, vattr_t *, vcexcl_t, \
853 855 int, vnode_t **, cred_t *, int, \
854 856 caller_context_t *, vsecattr_t *); \
855 857 int (*vop_remove)(vnode_t *, char *, cred_t *, \
856 858 caller_context_t *, int); \
857 859 int (*vop_link)(vnode_t *, vnode_t *, char *, cred_t *, \
858 860 caller_context_t *, int); \
859 861 int (*vop_rename)(vnode_t *, char *, vnode_t *, char *, \
860 862 cred_t *, caller_context_t *, int); \
861 863 int (*vop_mkdir)(vnode_t *, char *, vattr_t *, vnode_t **, \
862 864 cred_t *, caller_context_t *, int, \
863 865 vsecattr_t *); \
864 866 int (*vop_rmdir)(vnode_t *, char *, vnode_t *, cred_t *, \
865 867 caller_context_t *, int); \
866 868 int (*vop_readdir)(vnode_t *, uio_t *, cred_t *, int *, \
867 869 caller_context_t *, int); \
868 870 int (*vop_symlink)(vnode_t *, char *, vattr_t *, char *, \
869 871 cred_t *, caller_context_t *, int); \
870 872 int (*vop_readlink)(vnode_t *, uio_t *, cred_t *, \
871 873 caller_context_t *); \
872 874 int (*vop_fsync)(vnode_t *, int, cred_t *, \
873 875 caller_context_t *); \
874 876 void (*vop_inactive)(vnode_t *, cred_t *, \
875 877 caller_context_t *); \
876 878 int (*vop_fid)(vnode_t *, struct fid *, \
877 879 caller_context_t *); \
878 880 int (*vop_rwlock)(vnode_t *, int, caller_context_t *); \
879 881 void (*vop_rwunlock)(vnode_t *, int, caller_context_t *); \
880 882 int (*vop_seek)(vnode_t *, offset_t, offset_t *, \
881 883 caller_context_t *); \
882 884 int (*vop_cmp)(vnode_t *, vnode_t *, caller_context_t *); \
883 885 int (*vop_frlock)(vnode_t *, int, struct flock64 *, \
884 886 int, offset_t, \
885 887 struct flk_callback *, cred_t *, \
886 888 caller_context_t *); \
887 889 int (*vop_space)(vnode_t *, int, struct flock64 *, \
888 890 int, offset_t, \
889 891 cred_t *, caller_context_t *); \
890 892 int (*vop_realvp)(vnode_t *, vnode_t **, \
891 893 caller_context_t *); \
892 894 int (*vop_getpage)(vnode_t *, offset_t, size_t, uint_t *, \
893 895 struct page **, size_t, struct seg *, \
894 896 caddr_t, enum seg_rw, cred_t *, \
895 897 caller_context_t *); \
896 898 int (*vop_putpage)(vnode_t *, offset_t, size_t, \
897 899 int, cred_t *, caller_context_t *); \
898 900 int (*vop_map)(vnode_t *, offset_t, struct as *, \
899 901 caddr_t *, size_t, \
900 902 uchar_t, uchar_t, uint_t, cred_t *, \
901 903 caller_context_t *); \
902 904 int (*vop_addmap)(vnode_t *, offset_t, struct as *, \
903 905 caddr_t, size_t, \
904 906 uchar_t, uchar_t, uint_t, cred_t *, \
905 907 caller_context_t *); \
906 908 int (*vop_delmap)(vnode_t *, offset_t, struct as *, \
907 909 caddr_t, size_t, \
908 910 uint_t, uint_t, uint_t, cred_t *, \
909 911 caller_context_t *); \
910 912 int (*vop_poll)(vnode_t *, short, int, short *, \
911 913 struct pollhead **, \
912 914 caller_context_t *); \
913 915 int (*vop_dump)(vnode_t *, caddr_t, offset_t, offset_t, \
914 916 caller_context_t *); \
915 917 int (*vop_pathconf)(vnode_t *, int, ulong_t *, cred_t *, \
916 918 caller_context_t *); \
917 919 int (*vop_pageio)(vnode_t *, struct page *, \
918 920 u_offset_t, size_t, int, cred_t *, \
919 921 caller_context_t *); \
920 922 int (*vop_dumpctl)(vnode_t *, int, offset_t *, \
921 923 caller_context_t *); \
922 924 void (*vop_dispose)(vnode_t *, struct page *, \
923 925 int, int, cred_t *, \
924 926 caller_context_t *); \
925 927 int (*vop_setsecattr)(vnode_t *, vsecattr_t *, \
926 928 int, cred_t *, caller_context_t *); \
927 929 int (*vop_getsecattr)(vnode_t *, vsecattr_t *, \
928 930 int, cred_t *, caller_context_t *); \
929 931 int (*vop_shrlock)(vnode_t *, int, struct shrlock *, \
930 932 int, cred_t *, caller_context_t *); \
931 933 int (*vop_vnevent)(vnode_t *, vnevent_t, vnode_t *, \
932 934 char *, caller_context_t *); \
933 935 int (*vop_reqzcbuf)(vnode_t *, enum uio_rw, xuio_t *, \
934 936 cred_t *, caller_context_t *); \
935 937 int (*vop_retzcbuf)(vnode_t *, xuio_t *, cred_t *, \
936 938 caller_context_t *)
937 939 /* NB: No ";" */
938 940
939 941 /*
940 942 * Operations on vnodes. Note: File systems must never operate directly
941 943 * on a 'vnodeops' structure -- it WILL change in future releases! They
942 944 * must use vn_make_ops() to create the structure.
943 945 */
944 946 typedef struct vnodeops {
945 947 const char *vnop_name;
946 948 VNODE_OPS; /* Signatures of all vnode operations (vops) */
947 949 } vnodeops_t;
948 950
949 951 typedef int (*fs_generic_func_p) (); /* Generic vop/vfsop/femop/fsemop ptr */
950 952
951 953 extern int fop_open(vnode_t **, int, cred_t *, caller_context_t *);
952 954 extern int fop_close(vnode_t *, int, int, offset_t, cred_t *,
953 955 caller_context_t *);
954 956 extern int fop_read(vnode_t *, uio_t *, int, cred_t *, caller_context_t *);
955 957 extern int fop_write(vnode_t *, uio_t *, int, cred_t *,
956 958 caller_context_t *);
957 959 extern int fop_ioctl(vnode_t *, int, intptr_t, int, cred_t *, int *,
958 960 caller_context_t *);
959 961 extern int fop_setfl(vnode_t *, int, int, cred_t *, caller_context_t *);
960 962 extern int fop_getattr(vnode_t *, vattr_t *, int, cred_t *,
961 963 caller_context_t *);
962 964 extern int fop_setattr(vnode_t *, vattr_t *, int, cred_t *,
963 965 caller_context_t *);
964 966 extern int fop_access(vnode_t *, int, int, cred_t *, caller_context_t *);
965 967 extern int fop_lookup(vnode_t *, char *, vnode_t **, struct pathname *,
966 968 int, vnode_t *, cred_t *, caller_context_t *,
967 969 int *, struct pathname *);
968 970 extern int fop_create(vnode_t *, char *, vattr_t *, vcexcl_t, int,
969 971 vnode_t **, cred_t *, int, caller_context_t *,
970 972 vsecattr_t *);
971 973 extern int fop_remove(vnode_t *vp, char *, cred_t *, caller_context_t *,
972 974 int);
973 975 extern int fop_link(vnode_t *, vnode_t *, char *, cred_t *,
974 976 caller_context_t *, int);
975 977 extern int fop_rename(vnode_t *, char *, vnode_t *, char *, cred_t *,
976 978 caller_context_t *, int);
977 979 extern int fop_mkdir(vnode_t *, char *, vattr_t *, vnode_t **, cred_t *,
978 980 caller_context_t *, int, vsecattr_t *);
979 981 extern int fop_rmdir(vnode_t *, char *, vnode_t *, cred_t *,
980 982 caller_context_t *, int);
981 983 extern int fop_readdir(vnode_t *, uio_t *, cred_t *, int *,
982 984 caller_context_t *, int);
983 985 extern int fop_symlink(vnode_t *, char *, vattr_t *, char *, cred_t *,
984 986 caller_context_t *, int);
985 987 extern int fop_readlink(vnode_t *, uio_t *, cred_t *, caller_context_t *);
986 988 extern int fop_fsync(vnode_t *, int, cred_t *, caller_context_t *);
987 989 extern void fop_inactive(vnode_t *, cred_t *, caller_context_t *);
988 990 extern int fop_fid(vnode_t *, struct fid *, caller_context_t *);
989 991 extern int fop_rwlock(vnode_t *, int, caller_context_t *);
990 992 extern void fop_rwunlock(vnode_t *, int, caller_context_t *);
991 993 extern int fop_seek(vnode_t *, offset_t, offset_t *, caller_context_t *);
992 994 extern int fop_cmp(vnode_t *, vnode_t *, caller_context_t *);
993 995 extern int fop_frlock(vnode_t *, int, struct flock64 *, int, offset_t,
994 996 struct flk_callback *, cred_t *,
995 997 caller_context_t *);
996 998 extern int fop_space(vnode_t *, int, struct flock64 *, int, offset_t,
997 999 cred_t *, caller_context_t *);
998 1000 extern int fop_realvp(vnode_t *, vnode_t **, caller_context_t *);
999 1001 extern int fop_getpage(vnode_t *, offset_t, size_t, uint_t *,
1000 1002 struct page **, size_t, struct seg *,
1001 1003 caddr_t, enum seg_rw, cred_t *,
1002 1004 caller_context_t *);
1003 1005 extern int fop_putpage(vnode_t *, offset_t, size_t, int, cred_t *,
1004 1006 caller_context_t *);
1005 1007 extern int fop_map(vnode_t *, offset_t, struct as *, caddr_t *, size_t,
1006 1008 uchar_t, uchar_t, uint_t, cred_t *cr,
1007 1009 caller_context_t *);
1008 1010 extern int fop_addmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
1009 1011 uchar_t, uchar_t, uint_t, cred_t *,
1010 1012 caller_context_t *);
1011 1013 extern int fop_delmap(vnode_t *, offset_t, struct as *, caddr_t, size_t,
1012 1014 uint_t, uint_t, uint_t, cred_t *,
1013 1015 caller_context_t *);
1014 1016 extern int fop_poll(vnode_t *, short, int, short *, struct pollhead **,
1015 1017 caller_context_t *);
1016 1018 extern int fop_dump(vnode_t *, caddr_t, offset_t, offset_t,
1017 1019 caller_context_t *);
1018 1020 extern int fop_pathconf(vnode_t *, int, ulong_t *, cred_t *,
1019 1021 caller_context_t *);
1020 1022 extern int fop_pageio(vnode_t *, struct page *, u_offset_t, size_t, int,
1021 1023 cred_t *, caller_context_t *);
1022 1024 extern int fop_dumpctl(vnode_t *, int, offset_t *, caller_context_t *);
1023 1025 extern void fop_dispose(vnode_t *, struct page *, int, int, cred_t *,
1024 1026 caller_context_t *);
1025 1027 extern int fop_setsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1026 1028 caller_context_t *);
1027 1029 extern int fop_getsecattr(vnode_t *, vsecattr_t *, int, cred_t *,
1028 1030 caller_context_t *);
1029 1031 extern int fop_shrlock(vnode_t *, int, struct shrlock *, int, cred_t *,
1030 1032 caller_context_t *);
1031 1033 extern int fop_vnevent(vnode_t *, vnevent_t, vnode_t *, char *,
1032 1034 caller_context_t *);
1033 1035 extern int fop_reqzcbuf(vnode_t *, enum uio_rw, xuio_t *, cred_t *,
1034 1036 caller_context_t *);
1035 1037 extern int fop_retzcbuf(vnode_t *, xuio_t *, cred_t *, caller_context_t *);
1036 1038
1037 1039 #endif /* _KERNEL */
1038 1040
1039 1041 #define VOP_OPEN(vpp, mode, cr, ct) \
1040 1042 fop_open(vpp, mode, cr, ct)
1041 1043 #define VOP_CLOSE(vp, f, c, o, cr, ct) \
1042 1044 fop_close(vp, f, c, o, cr, ct)
1043 1045 #define VOP_READ(vp, uiop, iof, cr, ct) \
1044 1046 fop_read(vp, uiop, iof, cr, ct)
1045 1047 #define VOP_WRITE(vp, uiop, iof, cr, ct) \
1046 1048 fop_write(vp, uiop, iof, cr, ct)
1047 1049 #define VOP_IOCTL(vp, cmd, a, f, cr, rvp, ct) \
1048 1050 fop_ioctl(vp, cmd, a, f, cr, rvp, ct)
1049 1051 #define VOP_SETFL(vp, f, a, cr, ct) \
1050 1052 fop_setfl(vp, f, a, cr, ct)
1051 1053 #define VOP_GETATTR(vp, vap, f, cr, ct) \
1052 1054 fop_getattr(vp, vap, f, cr, ct)
1053 1055 #define VOP_SETATTR(vp, vap, f, cr, ct) \
1054 1056 fop_setattr(vp, vap, f, cr, ct)
1055 1057 #define VOP_ACCESS(vp, mode, f, cr, ct) \
1056 1058 fop_access(vp, mode, f, cr, ct)
1057 1059 #define VOP_LOOKUP(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp) \
1058 1060 fop_lookup(vp, cp, vpp, pnp, f, rdir, cr, ct, defp, rpnp)
1059 1061 #define VOP_CREATE(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap) \
1060 1062 fop_create(dvp, p, vap, ex, mode, vpp, cr, flag, ct, vsap)
1061 1063 #define VOP_REMOVE(dvp, p, cr, ct, f) \
1062 1064 fop_remove(dvp, p, cr, ct, f)
1063 1065 #define VOP_LINK(tdvp, fvp, p, cr, ct, f) \
1064 1066 fop_link(tdvp, fvp, p, cr, ct, f)
1065 1067 #define VOP_RENAME(fvp, fnm, tdvp, tnm, cr, ct, f) \
1066 1068 fop_rename(fvp, fnm, tdvp, tnm, cr, ct, f)
1067 1069 #define VOP_MKDIR(dp, p, vap, vpp, cr, ct, f, vsap) \
1068 1070 fop_mkdir(dp, p, vap, vpp, cr, ct, f, vsap)
1069 1071 #define VOP_RMDIR(dp, p, cdir, cr, ct, f) \
1070 1072 fop_rmdir(dp, p, cdir, cr, ct, f)
1071 1073 #define VOP_READDIR(vp, uiop, cr, eofp, ct, f) \
1072 1074 fop_readdir(vp, uiop, cr, eofp, ct, f)
1073 1075 #define VOP_SYMLINK(dvp, lnm, vap, tnm, cr, ct, f) \
1074 1076 fop_symlink(dvp, lnm, vap, tnm, cr, ct, f)
1075 1077 #define VOP_READLINK(vp, uiop, cr, ct) \
1076 1078 fop_readlink(vp, uiop, cr, ct)
1077 1079 #define VOP_FSYNC(vp, syncflag, cr, ct) \
1078 1080 fop_fsync(vp, syncflag, cr, ct)
1079 1081 #define VOP_INACTIVE(vp, cr, ct) \
1080 1082 fop_inactive(vp, cr, ct)
1081 1083 #define VOP_FID(vp, fidp, ct) \
1082 1084 fop_fid(vp, fidp, ct)
1083 1085 #define VOP_RWLOCK(vp, w, ct) \
1084 1086 fop_rwlock(vp, w, ct)
1085 1087 #define VOP_RWUNLOCK(vp, w, ct) \
1086 1088 fop_rwunlock(vp, w, ct)
1087 1089 #define VOP_SEEK(vp, ooff, noffp, ct) \
1088 1090 fop_seek(vp, ooff, noffp, ct)
1089 1091 #define VOP_CMP(vp1, vp2, ct) \
1090 1092 fop_cmp(vp1, vp2, ct)
1091 1093 #define VOP_FRLOCK(vp, cmd, a, f, o, cb, cr, ct) \
1092 1094 fop_frlock(vp, cmd, a, f, o, cb, cr, ct)
1093 1095 #define VOP_SPACE(vp, cmd, a, f, o, cr, ct) \
1094 1096 fop_space(vp, cmd, a, f, o, cr, ct)
1095 1097 #define VOP_REALVP(vp1, vp2, ct) \
1096 1098 fop_realvp(vp1, vp2, ct)
1097 1099 #define VOP_GETPAGE(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct) \
1098 1100 fop_getpage(vp, of, sz, pr, pl, ps, sg, a, rw, cr, ct)
1099 1101 #define VOP_PUTPAGE(vp, of, sz, fl, cr, ct) \
1100 1102 fop_putpage(vp, of, sz, fl, cr, ct)
1101 1103 #define VOP_MAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1102 1104 fop_map(vp, of, as, a, sz, p, mp, fl, cr, ct)
1103 1105 #define VOP_ADDMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1104 1106 fop_addmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1105 1107 #define VOP_DELMAP(vp, of, as, a, sz, p, mp, fl, cr, ct) \
1106 1108 fop_delmap(vp, of, as, a, sz, p, mp, fl, cr, ct)
1107 1109 #define VOP_POLL(vp, events, anyyet, reventsp, phpp, ct) \
1108 1110 fop_poll(vp, events, anyyet, reventsp, phpp, ct)
1109 1111 #define VOP_DUMP(vp, addr, bn, count, ct) \
1110 1112 fop_dump(vp, addr, bn, count, ct)
1111 1113 #define VOP_PATHCONF(vp, cmd, valp, cr, ct) \
1112 1114 fop_pathconf(vp, cmd, valp, cr, ct)
1113 1115 #define VOP_PAGEIO(vp, pp, io_off, io_len, flags, cr, ct) \
1114 1116 fop_pageio(vp, pp, io_off, io_len, flags, cr, ct)
1115 1117 #define VOP_DUMPCTL(vp, action, blkp, ct) \
1116 1118 fop_dumpctl(vp, action, blkp, ct)
1117 1119 #define VOP_DISPOSE(vp, pp, flag, dn, cr, ct) \
1118 1120 fop_dispose(vp, pp, flag, dn, cr, ct)
1119 1121 #define VOP_GETSECATTR(vp, vsap, f, cr, ct) \
1120 1122 fop_getsecattr(vp, vsap, f, cr, ct)
1121 1123 #define VOP_SETSECATTR(vp, vsap, f, cr, ct) \
1122 1124 fop_setsecattr(vp, vsap, f, cr, ct)
1123 1125 #define VOP_SHRLOCK(vp, cmd, shr, f, cr, ct) \
1124 1126 fop_shrlock(vp, cmd, shr, f, cr, ct)
1125 1127 #define VOP_VNEVENT(vp, vnevent, dvp, fnm, ct) \
1126 1128 fop_vnevent(vp, vnevent, dvp, fnm, ct)
1127 1129 #define VOP_REQZCBUF(vp, rwflag, xuiop, cr, ct) \
1128 1130 fop_reqzcbuf(vp, rwflag, xuiop, cr, ct)
1129 1131 #define VOP_RETZCBUF(vp, xuiop, cr, ct) \
1130 1132 fop_retzcbuf(vp, xuiop, cr, ct)
1131 1133
1132 1134 #define VOPNAME_OPEN "open"
1133 1135 #define VOPNAME_CLOSE "close"
1134 1136 #define VOPNAME_READ "read"
1135 1137 #define VOPNAME_WRITE "write"
1136 1138 #define VOPNAME_IOCTL "ioctl"
1137 1139 #define VOPNAME_SETFL "setfl"
1138 1140 #define VOPNAME_GETATTR "getattr"
1139 1141 #define VOPNAME_SETATTR "setattr"
1140 1142 #define VOPNAME_ACCESS "access"
1141 1143 #define VOPNAME_LOOKUP "lookup"
1142 1144 #define VOPNAME_CREATE "create"
1143 1145 #define VOPNAME_REMOVE "remove"
1144 1146 #define VOPNAME_LINK "link"
1145 1147 #define VOPNAME_RENAME "rename"
1146 1148 #define VOPNAME_MKDIR "mkdir"
1147 1149 #define VOPNAME_RMDIR "rmdir"
1148 1150 #define VOPNAME_READDIR "readdir"
1149 1151 #define VOPNAME_SYMLINK "symlink"
1150 1152 #define VOPNAME_READLINK "readlink"
1151 1153 #define VOPNAME_FSYNC "fsync"
1152 1154 #define VOPNAME_INACTIVE "inactive"
1153 1155 #define VOPNAME_FID "fid"
1154 1156 #define VOPNAME_RWLOCK "rwlock"
1155 1157 #define VOPNAME_RWUNLOCK "rwunlock"
1156 1158 #define VOPNAME_SEEK "seek"
1157 1159 #define VOPNAME_CMP "cmp"
1158 1160 #define VOPNAME_FRLOCK "frlock"
1159 1161 #define VOPNAME_SPACE "space"
1160 1162 #define VOPNAME_REALVP "realvp"
1161 1163 #define VOPNAME_GETPAGE "getpage"
1162 1164 #define VOPNAME_PUTPAGE "putpage"
1163 1165 #define VOPNAME_MAP "map"
1164 1166 #define VOPNAME_ADDMAP "addmap"
1165 1167 #define VOPNAME_DELMAP "delmap"
1166 1168 #define VOPNAME_POLL "poll"
1167 1169 #define VOPNAME_DUMP "dump"
1168 1170 #define VOPNAME_PATHCONF "pathconf"
1169 1171 #define VOPNAME_PAGEIO "pageio"
1170 1172 #define VOPNAME_DUMPCTL "dumpctl"
1171 1173 #define VOPNAME_DISPOSE "dispose"
1172 1174 #define VOPNAME_GETSECATTR "getsecattr"
1173 1175 #define VOPNAME_SETSECATTR "setsecattr"
1174 1176 #define VOPNAME_SHRLOCK "shrlock"
1175 1177 #define VOPNAME_VNEVENT "vnevent"
1176 1178 #define VOPNAME_REQZCBUF "reqzcbuf"
1177 1179 #define VOPNAME_RETZCBUF "retzcbuf"
1178 1180
1179 1181 /*
1180 1182 * Flags for VOP_LOOKUP
1181 1183 *
1182 1184 * Defined in file.h, but also possible, FIGNORECASE and FSEARCH
1183 1185 *
1184 1186 */
1185 1187 #define LOOKUP_DIR 0x01 /* want parent dir vp */
1186 1188 #define LOOKUP_XATTR 0x02 /* lookup up extended attr dir */
1187 1189 #define CREATE_XATTR_DIR 0x04 /* Create extended attr dir */
1188 1190 #define LOOKUP_HAVE_SYSATTR_DIR 0x08 /* Already created virtual GFS dir */
1189 1191
1190 1192 /*
1191 1193 * Flags for VOP_READDIR
1192 1194 */
1193 1195 #define V_RDDIR_ENTFLAGS 0x01 /* request dirent flags */
1194 1196 #define V_RDDIR_ACCFILTER 0x02 /* filter out inaccessible dirents */
1195 1197
1196 1198 /*
1197 1199 * Flags for VOP_RWLOCK/VOP_RWUNLOCK
1198 1200 * VOP_RWLOCK will return the flag that was actually set, or -1 if none.
1199 1201 */
1200 1202 #define V_WRITELOCK_TRUE (1) /* Request write-lock on the vnode */
1201 1203 #define V_WRITELOCK_FALSE (0) /* Request read-lock on the vnode */
1202 1204
1203 1205 /*
1204 1206 * Flags for VOP_DUMPCTL
1205 1207 */
1206 1208 #define DUMP_ALLOC 0
1207 1209 #define DUMP_FREE 1
1208 1210 #define DUMP_SCAN 2
1209 1211
1210 1212 /*
1211 1213 * Public vnode manipulation functions.
1212 1214 */
1213 1215 #ifdef _KERNEL
1214 1216
1215 1217 vnode_t *vn_alloc(int);
1216 1218 void vn_reinit(vnode_t *);
1217 1219 void vn_recycle(vnode_t *);
1218 1220 void vn_free(vnode_t *);
1219 1221
1220 1222 int vn_is_readonly(vnode_t *);
1221 1223 int vn_is_opened(vnode_t *, v_mode_t);
1222 1224 int vn_is_mapped(vnode_t *, v_mode_t);
1223 1225 int vn_has_other_opens(vnode_t *, v_mode_t);
1224 1226 void vn_open_upgrade(vnode_t *, int);
1225 1227 void vn_open_downgrade(vnode_t *, int);
1226 1228
1227 1229 int vn_can_change_zones(vnode_t *vp);
1228 1230
1229 1231 int vn_has_flocks(vnode_t *);
1230 1232 int vn_has_mandatory_locks(vnode_t *, int);
1231 1233 int vn_has_cached_data(vnode_t *);
1232 1234
1233 1235 void vn_setops(vnode_t *, vnodeops_t *);
1234 1236 vnodeops_t *vn_getops(vnode_t *);
1235 1237 int vn_matchops(vnode_t *, vnodeops_t *);
1236 1238 int vn_matchopval(vnode_t *, char *, fs_generic_func_p);
1237 1239 int vn_ismntpt(vnode_t *);
1238 1240
1239 1241 struct vfs *vn_mountedvfs(vnode_t *);
1240 1242
1241 1243 int vn_in_dnlc(vnode_t *);
1242 1244
1243 1245 void vn_create_cache(void);
1244 1246 void vn_destroy_cache(void);
1245 1247
1246 1248 void vn_freevnodeops(vnodeops_t *);
1247 1249
1248 1250 int vn_open(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1249 1251 struct vnode **vpp, enum create crwhy, mode_t umask);
1250 1252 int vn_openat(char *pnamep, enum uio_seg seg, int filemode, int createmode,
1251 1253 struct vnode **vpp, enum create crwhy,
1252 1254 mode_t umask, struct vnode *startvp, int fd);
1253 1255 int vn_create(char *pnamep, enum uio_seg seg, struct vattr *vap,
1254 1256 enum vcexcl excl, int mode, struct vnode **vpp,
1255 1257 enum create why, int flag, mode_t umask);
1256 1258 int vn_createat(char *pnamep, enum uio_seg seg, struct vattr *vap,
1257 1259 enum vcexcl excl, int mode, struct vnode **vpp,
1258 1260 enum create why, int flag, mode_t umask, struct vnode *startvp);
1259 1261 int vn_rdwr(enum uio_rw rw, struct vnode *vp, caddr_t base, ssize_t len,
1260 1262 offset_t offset, enum uio_seg seg, int ioflag, rlim64_t ulimit,
1261 1263 cred_t *cr, ssize_t *residp);
1262 1264 void vn_rele(struct vnode *vp);
1263 1265 void vn_rele_async(struct vnode *vp, struct taskq *taskq);
1264 1266 void vn_rele_dnlc(struct vnode *vp);
1265 1267 void vn_rele_stream(struct vnode *vp);
1266 1268 int vn_link(char *from, char *to, enum uio_seg seg);
1267 1269 int vn_linkat(vnode_t *fstartvp, char *from, enum symfollow follow,
1268 1270 vnode_t *tstartvp, char *to, enum uio_seg seg);
1269 1271 int vn_rename(char *from, char *to, enum uio_seg seg);
1270 1272 int vn_renameat(vnode_t *fdvp, char *fname, vnode_t *tdvp, char *tname,
1271 1273 enum uio_seg seg);
1272 1274 int vn_remove(char *fnamep, enum uio_seg seg, enum rm dirflag);
1273 1275 int vn_removeat(vnode_t *startvp, char *fnamep, enum uio_seg seg,
1274 1276 enum rm dirflag);
1275 1277 int vn_compare(vnode_t *vp1, vnode_t *vp2);
1276 1278 int vn_vfswlock(struct vnode *vp);
1277 1279 int vn_vfswlock_wait(struct vnode *vp);
1278 1280 int vn_vfsrlock(struct vnode *vp);
1279 1281 int vn_vfsrlock_wait(struct vnode *vp);
1280 1282 void vn_vfsunlock(struct vnode *vp);
1281 1283 int vn_vfswlock_held(struct vnode *vp);
1282 1284 vnode_t *specvp(struct vnode *vp, dev_t dev, vtype_t type, struct cred *cr);
1283 1285 vnode_t *makespecvp(dev_t dev, vtype_t type);
1284 1286 vn_vfslocks_entry_t *vn_vfslocks_getlock(void *);
1285 1287 void vn_vfslocks_rele(vn_vfslocks_entry_t *);
1286 1288 boolean_t vn_is_reparse(vnode_t *, cred_t *, caller_context_t *);
1287 1289
1288 1290 void vn_copypath(struct vnode *src, struct vnode *dst);
1289 1291 void vn_setpath_str(struct vnode *vp, const char *str, size_t len);
1290 1292 void vn_setpath(vnode_t *rootvp, struct vnode *startvp, struct vnode *vp,
|
↓ open down ↓ |
534 lines elided |
↑ open up ↑ |
1291 1293 const char *path, size_t plen);
1292 1294 void vn_renamepath(vnode_t *dvp, vnode_t *vp, const char *nm, size_t len);
1293 1295
1294 1296 /* Vnode event notification */
1295 1297 void vnevent_rename_src(vnode_t *, vnode_t *, char *, caller_context_t *);
1296 1298 void vnevent_rename_dest(vnode_t *, vnode_t *, char *, caller_context_t *);
1297 1299 void vnevent_remove(vnode_t *, vnode_t *, char *, caller_context_t *);
1298 1300 void vnevent_rmdir(vnode_t *, vnode_t *, char *, caller_context_t *);
1299 1301 void vnevent_create(vnode_t *, caller_context_t *);
1300 1302 void vnevent_link(vnode_t *, caller_context_t *);
1301 -void vnevent_rename_dest_dir(vnode_t *, caller_context_t *ct);
1303 +void vnevent_rename_dest_dir(vnode_t *, vnode_t *, char *,
1304 + caller_context_t *ct);
1302 1305 void vnevent_mountedover(vnode_t *, caller_context_t *);
1303 1306 void vnevent_truncate(vnode_t *, caller_context_t *);
1304 1307 int vnevent_support(vnode_t *, caller_context_t *);
1305 1308 void vnevent_pre_rename_src(vnode_t *, vnode_t *, char *,
1306 1309 caller_context_t *);
1307 1310 void vnevent_pre_rename_dest(vnode_t *, vnode_t *, char *,
1308 1311 caller_context_t *);
1309 1312 void vnevent_pre_rename_dest_dir(vnode_t *, vnode_t *, char *,
1310 1313 caller_context_t *);
1314 +void vnevent_resize(vnode_t *, caller_context_t *);
1311 1315
1312 1316 /* Vnode specific data */
1313 1317 void vsd_create(uint_t *, void (*)(void *));
1314 1318 void vsd_destroy(uint_t *);
1315 1319 void *vsd_get(vnode_t *, uint_t);
1316 1320 int vsd_set(vnode_t *, uint_t, void *);
1317 1321 void vsd_free(vnode_t *);
1318 1322
1319 1323 /*
1320 1324 * Extensible vnode attribute (xva) routines:
1321 1325 * xva_init() initializes an xvattr_t (zero struct, init mapsize, set AT_XATTR)
1322 1326 * xva_getxoptattr() returns a ponter to the xoptattr_t section of xvattr_t
1323 1327 */
1324 1328 void xva_init(xvattr_t *);
1325 1329 xoptattr_t *xva_getxoptattr(xvattr_t *); /* Get ptr to xoptattr_t */
1326 1330
1327 1331 void xattr_init(void); /* Initialize vnodeops for xattrs */
1328 1332
1329 1333 /* GFS tunnel for xattrs */
1330 1334 int xattr_dir_lookup(vnode_t *, vnode_t **, int, cred_t *);
1331 1335
1332 1336 /* Reparse Point */
1333 1337 void reparse_point_init(void);
1334 1338
1335 1339 /* Context identification */
1336 1340 u_longlong_t fs_new_caller_id();
1337 1341
1338 1342 int vn_vmpss_usepageio(vnode_t *);
1339 1343
1340 1344 /*
1341 1345 * Needed for use of IS_VMODSORT() in kernel.
1342 1346 */
1343 1347 extern uint_t pvn_vmodsort_supported;
1344 1348
1345 1349 #define VN_HOLD(vp) { \
1346 1350 mutex_enter(&(vp)->v_lock); \
1347 1351 (vp)->v_count++; \
1348 1352 mutex_exit(&(vp)->v_lock); \
1349 1353 }
1350 1354
1351 1355 #define VN_RELE(vp) { \
1352 1356 vn_rele(vp); \
1353 1357 }
1354 1358
1355 1359 #define VN_RELE_ASYNC(vp, taskq) { \
1356 1360 vn_rele_async(vp, taskq); \
1357 1361 }
1358 1362
1359 1363 #define VN_SET_VFS_TYPE_DEV(vp, vfsp, type, dev) { \
1360 1364 (vp)->v_vfsp = (vfsp); \
1361 1365 (vp)->v_type = (type); \
1362 1366 (vp)->v_rdev = (dev); \
1363 1367 }
1364 1368
1365 1369 /*
1366 1370 * Compare two vnodes for equality. In general this macro should be used
1367 1371 * in preference to calling VOP_CMP directly.
1368 1372 */
1369 1373 #define VN_CMP(VP1, VP2) ((VP1) == (VP2) ? 1 : \
1370 1374 ((VP1) && (VP2) && (vn_getops(VP1) == vn_getops(VP2)) ? \
1371 1375 VOP_CMP(VP1, VP2, NULL) : 0))
1372 1376
1373 1377 /*
1374 1378 * Some well-known global vnodes used by the VM system to name pages.
1375 1379 */
1376 1380 extern struct vnode kvps[];
1377 1381
1378 1382 typedef enum {
1379 1383 KV_KVP, /* vnode for all segkmem pages */
1380 1384 KV_ZVP, /* vnode for all ZFS pages */
1381 1385 #if defined(__sparc)
1382 1386 KV_MPVP, /* vnode for all page_t meta-pages */
1383 1387 KV_PROMVP, /* vnode for all PROM pages */
1384 1388 #endif /* __sparc */
1385 1389 KV_MAX /* total number of vnodes in kvps[] */
1386 1390 } kvps_index_t;
1387 1391
1388 1392 #define VN_ISKAS(vp) ((vp) >= &kvps[0] && (vp) < &kvps[KV_MAX])
1389 1393
1390 1394 #endif /* _KERNEL */
1391 1395
1392 1396 /*
1393 1397 * Flags to VOP_SETATTR/VOP_GETATTR.
1394 1398 */
1395 1399 #define ATTR_UTIME 0x01 /* non-default utime(2) request */
1396 1400 #define ATTR_EXEC 0x02 /* invocation from exec(2) */
1397 1401 #define ATTR_COMM 0x04 /* yield common vp attributes */
1398 1402 #define ATTR_HINT 0x08 /* information returned will be `hint' */
1399 1403 #define ATTR_REAL 0x10 /* yield attributes of the real vp */
1400 1404 #define ATTR_NOACLCHECK 0x20 /* Don't check ACL when checking permissions */
1401 1405 #define ATTR_TRIGGER 0x40 /* Mount first if vnode is a trigger mount */
1402 1406 /*
1403 1407 * Generally useful macros.
1404 1408 */
1405 1409 #define VBSIZE(vp) ((vp)->v_vfsp->vfs_bsize)
1406 1410
1407 1411 #define VTOZONE(vp) ((vp)->v_vfsp->vfs_zone)
1408 1412
1409 1413 #define NULLVP ((struct vnode *)0)
1410 1414 #define NULLVPP ((struct vnode **)0)
1411 1415
1412 1416 #ifdef _KERNEL
1413 1417
1414 1418 /*
1415 1419 * Structure used while handling asynchronous VOP_PUTPAGE operations.
1416 1420 */
1417 1421 struct async_reqs {
1418 1422 struct async_reqs *a_next; /* pointer to next arg struct */
1419 1423 struct vnode *a_vp; /* vnode pointer */
1420 1424 u_offset_t a_off; /* offset in file */
1421 1425 uint_t a_len; /* size of i/o request */
1422 1426 int a_flags; /* flags to indicate operation type */
1423 1427 struct cred *a_cred; /* cred pointer */
1424 1428 ushort_t a_prealloced; /* set if struct is pre-allocated */
1425 1429 };
1426 1430
1427 1431 /*
1428 1432 * VN_DISPOSE() -- given a page pointer, safely invoke VOP_DISPOSE().
1429 1433 * Note that there is no guarantee that the page passed in will be
1430 1434 * freed. If that is required, then a check after calling VN_DISPOSE would
1431 1435 * be necessary to ensure the page was freed.
1432 1436 */
1433 1437 #define VN_DISPOSE(pp, flag, dn, cr) { \
1434 1438 if ((pp)->p_vnode != NULL && !VN_ISKAS((pp)->p_vnode)) \
1435 1439 VOP_DISPOSE((pp)->p_vnode, (pp), (flag), (dn), (cr), NULL); \
1436 1440 else if ((flag) == B_FREE) \
1437 1441 page_free((pp), (dn)); \
1438 1442 else \
1439 1443 page_destroy((pp), (dn)); \
1440 1444 }
1441 1445
1442 1446 #endif /* _KERNEL */
1443 1447
1444 1448 #ifdef __cplusplus
1445 1449 }
1446 1450 #endif
1447 1451
1448 1452 #endif /* _SYS_VNODE_H */
|
↓ open down ↓ |
128 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX