Print this page
fsh webrev (August 24th)
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/vfs.h
+++ new/usr/src/uts/common/sys/vfs.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
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 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
23 23 */
24 24
25 25 /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
26 26 /* All Rights Reserved */
27 27
28 28 /*
29 29 * Portions of this source code were derived from Berkeley 4.3 BSD
30 30 * under license from the Regents of the University of California.
31 31 */
32 32
33 33 #ifndef _SYS_VFS_H
34 34 #define _SYS_VFS_H
35 35
36 36 #include <sys/zone.h>
37 37 #include <sys/types.h>
38 38 #include <sys/t_lock.h>
39 39 #include <sys/cred.h>
40 40 #include <sys/vnode.h>
41 41 #include <sys/statvfs.h>
42 42 #include <sys/refstr.h>
43 43 #include <sys/avl.h>
44 44 #include <sys/time.h>
45 45
46 46 #ifdef __cplusplus
47 47 extern "C" {
48 48 #endif
49 49
50 50 /*
51 51 * Data associated with mounted file systems.
52 52 */
53 53
54 54 /*
55 55 * Operations vector. This is used internal to the kernel; file systems
56 56 * supply their list of operations via vfs_setfsops().
57 57 */
58 58
59 59 typedef struct vfsops vfsops_t;
60 60
61 61 /*
62 62 * File system identifier. Should be unique (at least per machine).
63 63 */
64 64 typedef struct {
65 65 int val[2]; /* file system id type */
66 66 } fsid_t;
67 67
68 68 /*
69 69 * File identifier. Should be unique per filesystem on a single
70 70 * machine. This is typically called by a stateless file server
71 71 * in order to generate "file handles".
72 72 *
73 73 * Do not change the definition of struct fid ... fid_t without
74 74 * letting the CacheFS group know about it! They will have to do at
75 75 * least two things, in the same change that changes this structure:
76 76 * 1. change CFSVERSION in usr/src/uts/common/sys/fs/cachefs_fs.h
77 77 * 2. put the old version # in the canupgrade array
78 78 * in cachfs_upgrade() in usr/src/cmd/fs.d/cachefs/fsck/fsck.c
79 79 * This is necessary because CacheFS stores FIDs on disk.
80 80 *
81 81 * Many underlying file systems cast a struct fid into other
82 82 * file system dependent structures which may require 4 byte alignment.
83 83 * Because a fid starts with a short it may not be 4 byte aligned, the
84 84 * fid_pad will force the alignment.
85 85 */
86 86 #define MAXFIDSZ 64
87 87 #define OLD_MAXFIDSZ 16
88 88
89 89 typedef struct fid {
90 90 union {
91 91 long fid_pad;
92 92 struct {
93 93 ushort_t len; /* length of data in bytes */
94 94 char data[MAXFIDSZ]; /* data (variable len) */
95 95 } _fid;
96 96 } un;
97 97 } fid_t;
98 98
99 99 #ifdef _SYSCALL32
100 100 /*
101 101 * Solaris 64 - use old-style cache format with 32-bit aligned fid for on-disk
102 102 * struct compatibility.
103 103 */
104 104 typedef struct fid32 {
105 105 union {
106 106 int32_t fid_pad;
107 107 struct {
108 108 uint16_t len; /* length of data in bytes */
109 109 char data[MAXFIDSZ]; /* data (variable len) */
110 110 } _fid;
111 111 } un;
112 112 } fid32_t;
113 113 #else /* not _SYSCALL32 */
114 114 #define fid32 fid
115 115 typedef fid_t fid32_t;
116 116 #endif /* _SYSCALL32 */
117 117
118 118 #define fid_len un._fid.len
119 119 #define fid_data un._fid.data
120 120
121 121 /*
122 122 * Structure defining a mount option for a filesystem.
123 123 * option names are found in mntent.h
124 124 */
125 125 typedef struct mntopt {
126 126 char *mo_name; /* option name */
127 127 char **mo_cancel; /* list of options cancelled by this one */
128 128 char *mo_arg; /* argument string for this option */
129 129 int mo_flags; /* flags for this mount option */
130 130 void *mo_data; /* filesystem specific data */
131 131 } mntopt_t;
132 132
133 133 /*
134 134 * Flags that apply to mount options
135 135 */
136 136
137 137 #define MO_SET 0x01 /* option is set */
138 138 #define MO_NODISPLAY 0x02 /* option not listed in mnttab */
139 139 #define MO_HASVALUE 0x04 /* option takes a value */
140 140 #define MO_IGNORE 0x08 /* option ignored by parser */
141 141 #define MO_DEFAULT MO_SET /* option is on by default */
142 142 #define MO_TAG 0x10 /* flags a tag set by user program */
143 143 #define MO_EMPTY 0x20 /* empty space in option table */
144 144
145 145 #define VFS_NOFORCEOPT 0x01 /* honor MO_IGNORE (don't set option) */
146 146 #define VFS_DISPLAY 0x02 /* Turn off MO_NODISPLAY bit for opt */
147 147 #define VFS_NODISPLAY 0x04 /* Turn on MO_NODISPLAY bit for opt */
148 148 #define VFS_CREATEOPT 0x08 /* Create the opt if it's not there */
149 149
150 150 /*
151 151 * Structure holding mount option strings for the mounted file system.
152 152 */
153 153 typedef struct mntopts {
154 154 uint_t mo_count; /* number of entries in table */
155 155 mntopt_t *mo_list; /* list of mount options */
156 156 } mntopts_t;
157 157
158 158 /*
159 159 * The kstat structures associated with the vopstats are kept in an
160 160 * AVL tree. This is to avoid the case where a file system does not
161 161 * use a unique fsid_t for each vfs (e.g., namefs). In order to do
162 162 * this, we need a structure that the AVL tree can use that also
163 163 * references the kstat.
164 164 * Note that the vks_fsid is generated from the value reported by
165 165 * VFS_STATVFS().
166 166 */
167 167 typedef struct vskstat_anchor {
168 168 avl_node_t vsk_node; /* Required for use by AVL routines */
169 169 kstat_t *vsk_ksp; /* kstat structure for vopstats */
170 170 ulong_t vsk_fsid; /* fsid associated w/this FS */
171 171 } vsk_anchor_t;
172 172
173 173 extern avl_tree_t vskstat_tree;
174 174 extern kmutex_t vskstat_tree_lock;
175 175
176 176 /*
177 177 * Structure per mounted file system. Each mounted file system has
178 178 * an array of operations and an instance record.
179 179 *
180 180 * The file systems are kept on a doubly linked circular list headed by
181 181 * "rootvfs".
182 182 * File system implementations should not access this list;
183 183 * it's intended for use only in the kernel's vfs layer.
184 184 *
185 185 * Each zone also has its own list of mounts, containing filesystems mounted
186 186 * somewhere within the filesystem tree rooted at the zone's rootpath. The
187 187 * list is doubly linked to match the global list.
188 188 *
189 189 * mnttab locking: the in-kernel mnttab uses the vfs_mntpt, vfs_resource and
190 190 * vfs_mntopts fields in the vfs_t. mntpt and resource are refstr_ts that
↓ open down ↓ |
190 lines elided |
↑ open up ↑ |
191 191 * are set at mount time and can only be modified during a remount.
192 192 * It is safe to read these fields if you can prevent a remount on the vfs,
193 193 * or through the convenience funcs vfs_getmntpoint() and vfs_getresource().
194 194 * The mntopts field may only be accessed through the provided convenience
195 195 * functions, as it is protected by the vfs list lock. Modifying a mount
196 196 * option requires grabbing the vfs list write lock, which can be a very
197 197 * high latency lock.
198 198 */
199 199 struct zone; /* from zone.h */
200 200 struct fem_head; /* from fem.h */
201 +struct fsh_fsrecord; /* from fsh_impl.h */
201 202
202 203 typedef struct vfs {
203 204 struct vfs *vfs_next; /* next VFS in VFS list */
204 205 struct vfs *vfs_prev; /* prev VFS in VFS list */
205 206
206 207 /* vfs_op should not be used directly. Accessor functions are provided */
207 208 vfsops_t *vfs_op; /* operations on VFS */
208 209
209 210 struct vnode *vfs_vnodecovered; /* vnode mounted on */
210 211 uint_t vfs_flag; /* flags */
211 212 uint_t vfs_bsize; /* native block size */
212 213 int vfs_fstype; /* file system type index */
213 214 fsid_t vfs_fsid; /* file system id */
214 215 void *vfs_data; /* private data */
215 216 dev_t vfs_dev; /* device of mounted VFS */
216 217 ulong_t vfs_bcount; /* I/O count (accounting) */
217 218 struct vfs *vfs_list; /* sync list pointer */
218 219 struct vfs *vfs_hash; /* hash list pointer */
219 220 ksema_t vfs_reflock; /* mount/unmount/sync lock */
220 221 uint_t vfs_count; /* vfs reference count */
221 222 mntopts_t vfs_mntopts; /* options mounted with */
222 223 refstr_t *vfs_resource; /* mounted resource name */
223 224 refstr_t *vfs_mntpt; /* mount point name */
224 225 time_t vfs_mtime; /* time we were mounted */
225 226 struct vfs_impl *vfs_implp; /* impl specific data */
226 227 /*
227 228 * Zones support. Note that the zone that "owns" the mount isn't
↓ open down ↓ |
17 lines elided |
↑ open up ↑ |
228 229 * necessarily the same as the zone in which the zone is visible.
229 230 * That is, vfs_zone and (vfs_zone_next|vfs_zone_prev) may refer to
230 231 * different zones.
231 232 */
232 233 struct zone *vfs_zone; /* zone that owns the mount */
233 234 struct vfs *vfs_zone_next; /* next VFS visible in zone */
234 235 struct vfs *vfs_zone_prev; /* prev VFS visible in zone */
235 236
236 237 struct fem_head *vfs_femhead; /* fs monitoring */
237 238 minor_t vfs_lofi_minor; /* minor if lofi mount */
239 +
240 + struct fsh_fsrecord *volatile
241 + vfs_fshrecord; /* fs hooking */
238 242 } vfs_t;
239 243
240 244 #define vfs_featureset vfs_implp->vi_featureset
241 245 #define vfs_vskap vfs_implp->vi_vskap
242 246 #define vfs_fstypevsp vfs_implp->vi_fstypevsp
243 247 #define vfs_vopstats vfs_implp->vi_vopstats
244 248 #define vfs_hrctime vfs_implp->vi_hrctime
245 249
246 250 /*
247 251 * VFS flags.
248 252 */
249 253 #define VFS_RDONLY 0x01 /* read-only vfs */
250 254 #define VFS_NOMNTTAB 0x02 /* vfs not seen in mnttab */
251 255 #define VFS_NOSETUID 0x08 /* setuid disallowed */
252 256 #define VFS_REMOUNT 0x10 /* modify mount options only */
253 257 #define VFS_NOTRUNC 0x20 /* does not truncate long file names */
254 258 #define VFS_UNLINKABLE 0x40 /* unlink(2) can be applied to root */
255 259 #define VFS_PXFS 0x80 /* clustering: global fs proxy vfs */
256 260 #define VFS_UNMOUNTED 0x100 /* file system has been unmounted */
257 261 #define VFS_NBMAND 0x200 /* allow non-blocking mandatory locks */
258 262 #define VFS_XATTR 0x400 /* fs supports extended attributes */
259 263 #define VFS_NODEVICES 0x800 /* device-special files disallowed */
260 264 #define VFS_NOEXEC 0x1000 /* executables disallowed */
261 265 #define VFS_STATS 0x2000 /* file system can collect stats */
262 266 #define VFS_XID 0x4000 /* file system supports extended ids */
263 267
264 268 #define VFS_NORESOURCE "unspecified_resource"
265 269 #define VFS_NOMNTPT "unspecified_mountpoint"
266 270
267 271 /*
268 272 * VFS features are implemented as bits set in the vfs_t.
269 273 * The vfs_feature_t typedef is a 64-bit number that will translate
270 274 * into an element in an array of bitmaps and a bit in that element.
271 275 * Developers must not depend on the implementation of this and
272 276 * need to use vfs_has_feature()/vfs_set_feature() routines.
273 277 */
274 278 typedef uint64_t vfs_feature_t;
275 279
276 280 #define VFSFT_XVATTR 0x100000001 /* Supports xvattr for attrs */
277 281 #define VFSFT_CASEINSENSITIVE 0x100000002 /* Supports case-insensitive */
278 282 #define VFSFT_NOCASESENSITIVE 0x100000004 /* NOT case-sensitive */
279 283 #define VFSFT_DIRENTFLAGS 0x100000008 /* Supports dirent flags */
280 284 #define VFSFT_ACLONCREATE 0x100000010 /* Supports ACL on create */
281 285 #define VFSFT_ACEMASKONACCESS 0x100000020 /* Can use ACEMASK for access */
282 286 #define VFSFT_SYSATTR_VIEWS 0x100000040 /* Supports sysattr view i/f */
283 287 #define VFSFT_ACCESS_FILTER 0x100000080 /* dirents filtered by access */
284 288 #define VFSFT_REPARSE 0x100000100 /* Supports reparse point */
285 289 #define VFSFT_ZEROCOPY_SUPPORTED 0x100000200
286 290 /* Support loaning /returning cache buffer */
287 291 /*
288 292 * Argument structure for mount(2).
289 293 *
290 294 * Flags are defined in <sys/mount.h>.
291 295 *
292 296 * Note that if the MS_SYSSPACE bit is set in flags, the pointer fields in
293 297 * this structure are to be interpreted as kernel addresses. File systems
294 298 * should be prepared for this possibility.
295 299 */
296 300 struct mounta {
297 301 char *spec;
298 302 char *dir;
299 303 int flags;
300 304 char *fstype;
301 305 char *dataptr;
302 306 int datalen;
303 307 char *optptr;
304 308 int optlen;
305 309 };
306 310
307 311 /*
308 312 * Reasons for calling the vfs_mountroot() operation.
309 313 */
310 314 enum whymountroot { ROOT_INIT, ROOT_REMOUNT, ROOT_UNMOUNT};
311 315 typedef enum whymountroot whymountroot_t;
312 316
313 317 /*
314 318 * Reasons for calling the VFS_VNSTATE():
315 319 */
316 320 enum vntrans {
317 321 VNTRANS_EXISTS,
318 322 VNTRANS_IDLED,
319 323 VNTRANS_RECLAIMED,
320 324 VNTRANS_DESTROYED
321 325 };
322 326 typedef enum vntrans vntrans_t;
323 327
324 328 /*
325 329 * VFS_OPS defines all the vfs operations. It is used to define
326 330 * the vfsops structure (below) and the fs_func_p union (vfs_opreg.h).
327 331 */
328 332 #define VFS_OPS \
329 333 int (*vfs_mount)(vfs_t *, vnode_t *, struct mounta *, cred_t *); \
330 334 int (*vfs_unmount)(vfs_t *, int, cred_t *); \
331 335 int (*vfs_root)(vfs_t *, vnode_t **); \
332 336 int (*vfs_statvfs)(vfs_t *, statvfs64_t *); \
333 337 int (*vfs_sync)(vfs_t *, short, cred_t *); \
334 338 int (*vfs_vget)(vfs_t *, vnode_t **, fid_t *); \
335 339 int (*vfs_mountroot)(vfs_t *, enum whymountroot); \
336 340 void (*vfs_freevfs)(vfs_t *); \
337 341 int (*vfs_vnstate)(vfs_t *, vnode_t *, vntrans_t) /* NB: No ";" */
338 342
339 343 /*
340 344 * Operations supported on virtual file system.
341 345 */
342 346 struct vfsops {
343 347 VFS_OPS; /* Signature of all vfs operations (vfsops) */
344 348 };
345 349
346 350 extern int fsop_mount(vfs_t *, vnode_t *, struct mounta *, cred_t *);
347 351 extern int fsop_unmount(vfs_t *, int, cred_t *);
348 352 extern int fsop_root(vfs_t *, vnode_t **);
349 353 extern int fsop_statfs(vfs_t *, statvfs64_t *);
350 354 extern int fsop_sync(vfs_t *, short, cred_t *);
351 355 extern int fsop_vget(vfs_t *, vnode_t **, fid_t *);
352 356 extern int fsop_mountroot(vfs_t *, enum whymountroot);
353 357 extern void fsop_freefs(vfs_t *);
354 358 extern int fsop_sync_by_kind(int, short, cred_t *);
355 359 extern int fsop_vnstate(vfs_t *, vnode_t *, vntrans_t);
356 360
357 361 #define VFS_MOUNT(vfsp, mvp, uap, cr) fsop_mount(vfsp, mvp, uap, cr)
358 362 #define VFS_UNMOUNT(vfsp, flag, cr) fsop_unmount(vfsp, flag, cr)
359 363 #define VFS_ROOT(vfsp, vpp) fsop_root(vfsp, vpp)
360 364 #define VFS_STATVFS(vfsp, sp) fsop_statfs(vfsp, sp)
361 365 #define VFS_SYNC(vfsp, flag, cr) fsop_sync(vfsp, flag, cr)
362 366 #define VFS_VGET(vfsp, vpp, fidp) fsop_vget(vfsp, vpp, fidp)
363 367 #define VFS_MOUNTROOT(vfsp, init) fsop_mountroot(vfsp, init)
364 368 #define VFS_FREEVFS(vfsp) fsop_freefs(vfsp)
365 369 #define VFS_VNSTATE(vfsp, vn, ns) fsop_vnstate(vfsp, vn, ns)
366 370
367 371 #define VFSNAME_MOUNT "mount"
368 372 #define VFSNAME_UNMOUNT "unmount"
369 373 #define VFSNAME_ROOT "root"
370 374 #define VFSNAME_STATVFS "statvfs"
371 375 #define VFSNAME_SYNC "sync"
372 376 #define VFSNAME_VGET "vget"
373 377 #define VFSNAME_MOUNTROOT "mountroot"
374 378 #define VFSNAME_FREEVFS "freevfs"
375 379 #define VFSNAME_VNSTATE "vnstate"
376 380 /*
377 381 * Filesystem type switch table.
378 382 */
379 383
380 384 typedef struct vfssw {
381 385 char *vsw_name; /* type name -- max len _ST_FSTYPSZ */
382 386 int (*vsw_init) (int, char *);
383 387 /* init routine (for non-loadable fs only) */
384 388 int vsw_flag; /* flags */
385 389 mntopts_t vsw_optproto; /* mount options table prototype */
386 390 uint_t vsw_count; /* count of references */
387 391 kmutex_t vsw_lock; /* lock to protect vsw_count */
388 392 vfsops_t vsw_vfsops; /* filesystem operations vector */
389 393 } vfssw_t;
390 394
391 395 /*
392 396 * Filesystem type definition record. All file systems must export a record
393 397 * of this type through their modlfs structure. N.B., changing the version
394 398 * number requires a change in sys/modctl.h.
395 399 */
396 400
397 401 typedef struct vfsdef_v5 {
398 402 int def_version; /* structure version, must be first */
399 403 char *name; /* filesystem type name */
400 404 int (*init) (int, char *); /* init routine */
401 405 int flags; /* filesystem flags */
402 406 mntopts_t *optproto; /* mount options table prototype */
403 407 } vfsdef_v5;
404 408
405 409 typedef struct vfsdef_v5 vfsdef_t;
406 410
407 411 enum {
408 412 VFSDEF_VERSION = 5
409 413 };
410 414
411 415 /*
412 416 * flags for vfssw and vfsdef
413 417 */
414 418 #define VSW_HASPROTO 0x01 /* struct has a mount options prototype */
415 419 #define VSW_CANRWRO 0x02 /* file system can transition from rw to ro */
416 420 #define VSW_CANREMOUNT 0x04 /* file system supports remounts */
417 421 #define VSW_NOTZONESAFE 0x08 /* zone_enter(2) should fail for these files */
418 422 #define VSW_VOLATILEDEV 0x10 /* vfs_dev can change each time fs is mounted */
419 423 #define VSW_STATS 0x20 /* file system can collect stats */
420 424 #define VSW_XID 0x40 /* file system supports extended ids */
421 425 #define VSW_CANLOFI 0x80 /* file system supports lofi mounts */
422 426 #define VSW_ZMOUNT 0x100 /* file system always allowed in a zone */
423 427
424 428 #define VSW_INSTALLED 0x8000 /* this vsw is associated with a file system */
425 429
426 430 /*
427 431 * A flag for vfs_setpath().
428 432 */
429 433 #define VFSSP_VERBATIM 0x1 /* do not prefix the supplied path */
430 434
431 435 #if defined(_KERNEL)
432 436
433 437 /*
434 438 * Private vfs data, NOT to be used by a file system implementation.
435 439 */
436 440
437 441 #define VFS_FEATURE_MAXSZ 4
438 442
439 443 typedef struct vfs_impl {
440 444 /* Counted array - Bitmap of vfs features */
441 445 uint32_t vi_featureset[VFS_FEATURE_MAXSZ];
442 446 /*
443 447 * Support for statistics on the vnode operations
444 448 */
445 449 vsk_anchor_t *vi_vskap; /* anchor for vopstats' kstat */
446 450 vopstats_t *vi_fstypevsp; /* ptr to per-fstype vopstats */
447 451 vopstats_t vi_vopstats; /* per-mount vnode op stats */
448 452
449 453 timespec_t vi_hrctime; /* High-res creation time */
450 454
451 455 zone_ref_t vi_zone_ref; /* reference to zone */
452 456 } vfs_impl_t;
453 457
454 458 /*
455 459 * Public operations.
456 460 */
457 461 struct umounta;
458 462 struct statvfsa;
459 463 struct fstatvfsa;
460 464
461 465 void vfs_freevfsops(vfsops_t *);
462 466 int vfs_freevfsops_by_type(int);
463 467 void vfs_setops(vfs_t *, vfsops_t *);
464 468 vfsops_t *vfs_getops(vfs_t *vfsp);
465 469 int vfs_matchops(vfs_t *, vfsops_t *);
466 470 int vfs_can_sync(vfs_t *vfsp);
467 471 vfs_t *vfs_alloc(int);
468 472 void vfs_free(vfs_t *);
469 473 void vfs_init(vfs_t *vfsp, vfsops_t *, void *);
470 474 void vfsimpl_setup(vfs_t *vfsp);
471 475 void vfsimpl_teardown(vfs_t *vfsp);
472 476 void vn_exists(vnode_t *);
473 477 void vn_idle(vnode_t *);
474 478 void vn_reclaim(vnode_t *);
475 479 void vn_invalid(vnode_t *);
476 480
477 481 int rootconf(void);
478 482 int svm_rootconf(void);
479 483 int domount(char *, struct mounta *, vnode_t *, struct cred *,
480 484 struct vfs **);
481 485 int dounmount(struct vfs *, int, cred_t *);
482 486 int vfs_lock(struct vfs *);
483 487 int vfs_rlock(struct vfs *);
484 488 void vfs_lock_wait(struct vfs *);
485 489 void vfs_rlock_wait(struct vfs *);
486 490 void vfs_unlock(struct vfs *);
487 491 int vfs_lock_held(struct vfs *);
488 492 struct _kthread *vfs_lock_owner(struct vfs *);
489 493 void sync(void);
490 494 void vfs_sync(int);
491 495 void vfs_mountroot(void);
492 496 void vfs_add(vnode_t *, struct vfs *, int);
493 497 void vfs_remove(struct vfs *);
494 498
495 499 /* VFS feature routines */
496 500 void vfs_set_feature(vfs_t *, vfs_feature_t);
497 501 void vfs_clear_feature(vfs_t *, vfs_feature_t);
498 502 int vfs_has_feature(vfs_t *, vfs_feature_t);
499 503 void vfs_propagate_features(vfs_t *, vfs_t *);
500 504
501 505 /* The following functions are not for general use by filesystems */
502 506
503 507 void vfs_createopttbl(mntopts_t *, const char *);
504 508 void vfs_copyopttbl(const mntopts_t *, mntopts_t *);
505 509 void vfs_mergeopttbl(const mntopts_t *, const mntopts_t *, mntopts_t *);
506 510 void vfs_freeopttbl(mntopts_t *);
507 511 void vfs_parsemntopts(mntopts_t *, char *, int);
508 512 int vfs_buildoptionstr(const mntopts_t *, char *, int);
509 513 struct mntopt *vfs_hasopt(const mntopts_t *, const char *);
510 514 void vfs_mnttab_modtimeupd(void);
511 515
512 516 void vfs_clearmntopt(struct vfs *, const char *);
513 517 void vfs_setmntopt(struct vfs *, const char *, const char *, int);
514 518 void vfs_setresource(struct vfs *, const char *, uint32_t);
515 519 void vfs_setmntpoint(struct vfs *, const char *, uint32_t);
516 520 refstr_t *vfs_getresource(const struct vfs *);
517 521 refstr_t *vfs_getmntpoint(const struct vfs *);
518 522 int vfs_optionisset(const struct vfs *, const char *, char **);
519 523 int vfs_settag(uint_t, uint_t, const char *, const char *, cred_t *);
520 524 int vfs_clrtag(uint_t, uint_t, const char *, const char *, cred_t *);
521 525 void vfs_syncall(void);
522 526 void vfs_syncprogress(void);
523 527 void vfsinit(void);
524 528 void vfs_unmountall(void);
525 529 void vfs_make_fsid(fsid_t *, dev_t, int);
526 530 void vfs_addmip(dev_t, struct vfs *);
527 531 void vfs_delmip(struct vfs *);
528 532 int vfs_devismounted(dev_t);
529 533 int vfs_devmounting(dev_t, struct vfs *);
530 534 int vfs_opsinuse(vfsops_t *);
531 535 struct vfs *getvfs(fsid_t *);
532 536 struct vfs *vfs_dev2vfsp(dev_t);
533 537 struct vfs *vfs_mntpoint2vfsp(const char *);
534 538 struct vfssw *allocate_vfssw(const char *);
535 539 struct vfssw *vfs_getvfssw(const char *);
536 540 struct vfssw *vfs_getvfsswbyname(const char *);
537 541 struct vfssw *vfs_getvfsswbyvfsops(vfsops_t *);
538 542 void vfs_refvfssw(struct vfssw *);
539 543 void vfs_unrefvfssw(struct vfssw *);
540 544 uint_t vf_to_stf(uint_t);
541 545 void vfs_mnttab_modtime(timespec_t *);
542 546 void vfs_mnttab_poll(timespec_t *, struct pollhead **);
543 547
544 548 void vfs_list_lock(void);
545 549 void vfs_list_read_lock(void);
546 550 void vfs_list_unlock(void);
547 551 void vfs_list_add(struct vfs *);
548 552 void vfs_list_remove(struct vfs *);
549 553 void vfs_hold(vfs_t *vfsp);
550 554 void vfs_rele(vfs_t *vfsp);
551 555 void fs_freevfs(vfs_t *);
552 556 void vfs_root_redev(vfs_t *vfsp, dev_t ndev, int fstype);
553 557
554 558 int vfs_zone_change_safe(vfs_t *);
555 559
556 560 int vfs_get_lofi(vfs_t *, vnode_t **);
557 561
558 562 #define VFSHASH(maj, min) (((int)((maj)+(min))) & (vfshsz - 1))
559 563 #define VFS_ON_LIST(vfsp) \
560 564 ((vfsp)->vfs_next != (vfsp) && (vfsp)->vfs_next != NULL)
561 565
562 566 /*
563 567 * Globals.
564 568 */
565 569
566 570 extern struct vfssw vfssw[]; /* table of filesystem types */
567 571 extern krwlock_t vfssw_lock;
568 572 extern char rootfstype[]; /* name of root fstype */
569 573 extern const int nfstype; /* # of elements in vfssw array */
570 574 extern vfsops_t *EIO_vfsops; /* operations for vfs being torn-down */
571 575
572 576 /*
573 577 * The following variables are private to the the kernel's vfs layer. File
574 578 * system implementations should not access them.
575 579 */
576 580 extern struct vfs *rootvfs; /* ptr to root vfs structure */
577 581 typedef struct {
578 582 struct vfs *rvfs_head; /* head vfs in chain */
579 583 kmutex_t rvfs_lock; /* mutex protecting this chain */
580 584 uint32_t rvfs_len; /* length of this chain */
581 585 } rvfs_t;
582 586 extern rvfs_t *rvfs_list;
583 587 extern int vfshsz; /* # of elements in rvfs_head array */
584 588 extern const mntopts_t vfs_mntopts; /* globally recognized options */
585 589
586 590 #endif /* defined(_KERNEL) */
587 591
588 592 #define VFS_HOLD(vfsp) { \
589 593 vfs_hold(vfsp); \
590 594 }
591 595
592 596 #define VFS_RELE(vfsp) { \
593 597 vfs_rele(vfsp); \
594 598 }
595 599
596 600 #define VFS_INIT(vfsp, op, data) { \
597 601 vfs_init((vfsp), (op), (data)); \
598 602 }
599 603
600 604
601 605 #define VFS_INSTALLED(vfsswp) (((vfsswp)->vsw_flag & VSW_INSTALLED) != 0)
602 606 #define ALLOCATED_VFSSW(vswp) ((vswp)->vsw_name[0] != '\0')
603 607 #define RLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_READER))
604 608 #define RUNLOCK_VFSSW() (rw_exit(&vfssw_lock))
605 609 #define WLOCK_VFSSW() (rw_enter(&vfssw_lock, RW_WRITER))
606 610 #define WUNLOCK_VFSSW() (rw_exit(&vfssw_lock))
607 611 #define VFSSW_LOCKED() (RW_LOCK_HELD(&vfssw_lock))
608 612 #define VFSSW_WRITE_LOCKED() (RW_WRITE_HELD(&vfssw_lock))
609 613 /*
610 614 * VFS_SYNC flags.
611 615 */
612 616 #define SYNC_ATTR 0x01 /* sync attributes only */
613 617 #define SYNC_CLOSE 0x02 /* close open file */
614 618 #define SYNC_ALL 0x04 /* force to sync all fs */
615 619
616 620 #ifdef __cplusplus
617 621 }
618 622 #endif
619 623
620 624 #endif /* _SYS_VFS_H */
↓ open down ↓ |
373 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX