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