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