#include <sys/mount.h>

sys/mount.h Kernel.framework

includes: sys/appleapiopts.h, sys/cdefs.h, sys/attr.h, os/base.h, sys/kernel_types.h, uuid/uuid.h, Kernel/sys/_types/_fsid_t.h, Kernel/sys/_types/_graftdmg_un.h, Kernel/sys/_types/_mount_t.h, Kernel/sys/_types/_vnode_t.h
69 macros · 49 functions · 12 structs · 2 typedefs · 1 union · 1 enum

macroMNAMELEN

#define MNAMELEN 90
length of buffer for returned name

structstatfs64

size 2168, align 8
uint32_tf_bsizefundamental file system block size
int32_tf_iosizeoptimal transfer block size
uint64_tf_blockstotal data blocks in file system
uint64_tf_bfreefree blocks in fs
uint64_tf_bavailfree blocks avail to non-superuser
uint64_tf_filestotal file nodes in file system
uint64_tf_ffreefree file nodes in fs
fsid_tf_fsidfile system id
uid_tf_owneruser that mounted the filesystem
uint32_tf_typetype of filesystem
uint32_tf_flagscopy of mount exported flags
uint32_tf_fssubtypefs sub-type (flavor)
char[16]f_fstypenamefs type name
char[1024]f_mntonnamedirectory on which mounted
char[1024]f_mntfromnamemounted filesystem
uint32_tf_flags_extextended flags
uint32_t[7]f_reservedFor future use

structstatfs

LP64 - WARNING - must be kept in sync with struct user_statfs in mount_internal.h.
size 336, align 8
shortf_otypeTEMPORARY SHADOW COPY OF f_type
shortf_oflagsTEMPORARY SHADOW COPY OF f_flags
longf_bsizefundamental file system block size
longf_iosizeoptimal transfer block size
longf_blockstotal data blocks in file system
longf_bfreefree blocks in fs
longf_bavailfree blocks avail to non-superuser
longf_filestotal file nodes in file system
longf_ffreefree file nodes in fs
fsid_tf_fsidfile system id
uid_tf_owneruser that mounted the filesystem
shortf_reserved1spare for later
shortf_typetype of filesystem
longf_flagscopy of mount exported flags
long[2]f_reserved2reserved for future use
char[15]f_fstypenamefs type name
char[90]f_mntonnamedirectory on which mounted
char[90]f_mntfromnamemounted filesystem
charf_reserved3For alignment
long[4]f_reserved4For future use

macroVFSATTR_INIT

#define VFSATTR_INIT(s) ((s)->f_supported = (s)->f_active = 0LL)

macroVFSATTR_SET_SUPPORTED

#define VFSATTR_SET_SUPPORTED(s, a) ((s)->f_supported |= VFSATTR_ ## a)

macroVFSATTR_IS_SUPPORTED

#define VFSATTR_IS_SUPPORTED(s, a) ((s)->f_supported & VFSATTR_ ## a)

macroVFSATTR_CLEAR_ACTIVE

#define VFSATTR_CLEAR_ACTIVE(s, a) ((s)->f_active &= ~VFSATTR_ ## a)

macroVFSATTR_IS_ACTIVE

#define VFSATTR_IS_ACTIVE(s, a) ((s)->f_active & VFSATTR_ ## a)

macroVFSATTR_ALL_SUPPORTED

#define VFSATTR_ALL_SUPPORTED(s) (((s)->f_active & (s)->f_supported) == (s)->f_active)

macroVFSATTR_WANTED

#define VFSATTR_WANTED(s, a) ((s)->f_active |= VFSATTR_ ## a)

macroVFSATTR_RETURN

#define VFSATTR_RETURN(s, a, x) do { (s)-> a = (x); VFSATTR_SET_SUPPORTED(s, a);} while(0)

macroVFSATTR_f_objcount

#define VFSATTR_f_objcount (1LL<<  0)

macroVFSATTR_f_filecount

#define VFSATTR_f_filecount (1LL<<  1)

macroVFSATTR_f_dircount

#define VFSATTR_f_dircount (1LL<<  2)

macroVFSATTR_f_maxobjcount

#define VFSATTR_f_maxobjcount (1LL<<  3)

macroVFSATTR_f_bsize

#define VFSATTR_f_bsize (1LL<< 4)

macroVFSATTR_f_iosize

#define VFSATTR_f_iosize (1LL<<  5)

macroVFSATTR_f_blocks

#define VFSATTR_f_blocks (1LL<<  6)

macroVFSATTR_f_bfree

#define VFSATTR_f_bfree (1LL<<  7)

macroVFSATTR_f_bavail

#define VFSATTR_f_bavail (1LL<<  8)

macroVFSATTR_f_bused

#define VFSATTR_f_bused (1LL<<  9)

macroVFSATTR_f_files

#define VFSATTR_f_files (1LL<< 10)

macroVFSATTR_f_ffree

#define VFSATTR_f_ffree (1LL<< 11)

macroVFSATTR_f_fsid

#define VFSATTR_f_fsid (1LL<< 12)

macroVFSATTR_f_owner

#define VFSATTR_f_owner (1LL<< 13)

macroVFSATTR_f_capabilities

#define VFSATTR_f_capabilities (1LL<< 14)

macroVFSATTR_f_attributes

#define VFSATTR_f_attributes (1LL<< 15)

macroVFSATTR_f_create_time

#define VFSATTR_f_create_time (1LL<< 16)

macroVFSATTR_f_modify_time

#define VFSATTR_f_modify_time (1LL<< 17)

macroVFSATTR_f_access_time

#define VFSATTR_f_access_time (1LL<< 18)

macroVFSATTR_f_backup_time

#define VFSATTR_f_backup_time (1LL<< 19)

macroVFSATTR_f_fssubtype

#define VFSATTR_f_fssubtype (1LL<< 20)

macroVFSATTR_f_vol_name

#define VFSATTR_f_vol_name (1LL<< 21)

macroVFSATTR_f_signature

#define VFSATTR_f_signature (1LL<< 22)

macroVFSATTR_f_carbon_fsid

#define VFSATTR_f_carbon_fsid (1LL<< 23)

macroVFSATTR_f_uuid

#define VFSATTR_f_uuid (1LL<< 24)

macroVFSATTR_f_quota

#define VFSATTR_f_quota (1LL<< 25)

macroVFSATTR_f_reserved

#define VFSATTR_f_reserved (1LL<< 26)

structvfs_attr

Note: the size of the vfs_attr structure can change. A kext should only reference the fields that are marked as active; it should not depend on the actual size of the structure or attempt to copy it.
size 304, align 4
uint64_tf_supported
uint64_tf_active
uint64_tf_objcountnumber of filesystem objects in volume
uint64_tf_filecount... files
uint64_tf_dircount... directories
uint64_tf_maxobjcountmaximum number of filesystem objects
uint32_tf_bsizeblock size for the below size values
size_tf_iosizeoptimal transfer block size
uint64_tf_blockstotal data blocks in file system
uint64_tf_bfreefree blocks in fs
uint64_tf_bavailfree blocks avail to non-superuser
uint64_tf_busedblocks in use
uint64_tf_filestotal file nodes in file system
uint64_tf_ffreefree file nodes in fs
fsid_tf_fsidfile system id
uid_tf_owneruser that mounted the filesystem
vol_capabilities_attr_tf_capabilities
vol_attributes_attr_tf_attributes
struct timespecf_create_timecreation time
struct timespecf_modify_timelast modification time
struct timespecf_access_timetime of last access
struct timespecf_backup_timelast backup time
uint32_tf_fssubtypefilesystem subtype
char *f_vol_namevolume name
uint16_tf_signatureused for ATTR_VOL_SIGNATURE, Carbon's FSVolumeInfo.signature
uint16_tf_carbon_fsidsame as Carbon's FSVolumeInfo.filesystemID
uuid_tf_uuidfile system UUID (version 3 or 5), available in 10.6 and later
uint64_tf_quotatotal quota data blocks in file system
uint64_tf_reservedtotal reserved data blocks in file system

macroMNT_VOLUME

only for VFS_SYNC
#define MNT_VOLUME 8
sync on a single mounted filesystem

structuser_vfsidctl

size 80, align 8
intvc_versshould be VFSIDCTL_VERS1 (below)
fsid_tvc_fsidfsid to operate on.
user_addr_tvc_ptrpointer to data structure.
user_size_tvc_lensizeof said structure.
u_int32_t[12]vc_sparespare (must be zero).

structuser32_vfsidctl

size 68, align 4
intvc_versshould be VFSIDCTL_VERS1 (below)
fsid_tvc_fsidfsid to operate on.
user32_addr_tvc_ptrpointer to data structure.
user32_size_tvc_lensizeof said structure.
u_int32_t[12]vc_sparespare (must be zero).

unionunion_vfsidctl

size 80, align 8
struct user32_vfsidctlvc32
struct user_vfsidctlvc64

structvfsioattr

Structure for setting device IO parameters per mount point
size 48, align 8
u_int32_tio_maxreadcntMax. byte count for read
u_int32_tio_maxwritecntMax. byte count for write
u_int32_tio_segreadcntMax. segment count for read
u_int32_tio_segwritecntMax. segment count for write
u_int32_tio_maxsegreadsizeMax. segment read size
u_int32_tio_maxsegwritesizeMax. segment write size
u_int32_tio_devblocksizethe underlying device block size
u_int32_tio_flagsflags for underlying device

macroVFS_IOATTR_FLAGS_FUA

#define VFS_IOATTR_FLAGS_FUA 0x00000001
Write-through cache supported

macroVFS_IOATTR_FLAGS_UNMAP

#define VFS_IOATTR_FLAGS_UNMAP 0x00000002
Unmap (trim) supported

macroVFS_IOATTR_FLAGS_SWAPPIN_SUPPORTED

#define VFS_IOATTR_FLAGS_SWAPPIN_SUPPORTED 0x00000010
Pinning swap file supported

macroVFS_TBLTHREADSAFE

Filesystem Registration information
#define VFS_TBLTHREADSAFE 0x0001
Only threadsafe filesystems are supported

macroVFS_TBLFSNODELOCK

#define VFS_TBLFSNODELOCK 0x0002
Only threadsafe filesystems are supported

macroVFS_TBLNOTYPENUM

#define VFS_TBLNOTYPENUM 0x0008

macroVFS_TBLLOCALVOL

#define VFS_TBLLOCALVOL 0x0010

macroVFS_TBL64BITREADY

#define VFS_TBL64BITREADY 0x0020

macroVFS_TBLNATIVEXATTR

#define VFS_TBLNATIVEXATTR 0x0040

macroVFS_TBLUNMOUNT_PREFLIGHT

#define VFS_TBLUNMOUNT_PREFLIGHT 0x0100
does a preflight check before unmounting

macroVFS_TBLGENERICMNTARGS

#define VFS_TBLGENERICMNTARGS 0x0200
force generic mount args for local fs

macroVFS_TBLREADDIR_EXTENDED

#define VFS_TBLREADDIR_EXTENDED 0x0400

macroVFS_TBLNOMACLABEL

#define VFS_TBLNOMACLABEL 0x1000

macroVFS_TBLVNOP_PAGEINV2

#define VFS_TBLVNOP_PAGEINV2 0x2000

macroVFS_TBLVNOP_PAGEOUTV2

#define VFS_TBLVNOP_PAGEOUTV2 0x4000

macroVFS_TBLVNOP_NOUPDATEID_RENAME

#define VFS_TBLVNOP_NOUPDATEID_RENAME 0x8000
vfs should not call vnode_update_ident on rename

macroVFS_TBLVNOP_SECLUDE_RENAME

#define VFS_TBLVNOP_SECLUDE_RENAME 0x10000

macroVFS_TBLCANMOUNTROOT

#define VFS_TBLCANMOUNTROOT 0x20000

structvfs_fsentry

size 64, align 8
struct vfsops *vfe_vfsopsvfs operations
intvfe_vopcnt# of vnodeopv_desc being registered (reg, spec, fifo ...)
struct vnodeopv_desc **vfe_opvdescsnull terminated;
intvfe_fstypenumhistoric filesystem type number
char[15]vfe_fsnamefilesystem type name
uint32_tvfe_flagsdefines the FS capabilities
void *[2]vfe_reservreserved for future use; set this to zero

structvfsops

size 160, align 8
int (*)(struct mount *, vnode_t, user_addr_t, vfs_context_t)vfs_mount@field vfs_mount @abstract Perform filesystem-specific operations required for mounting. @discussion Typical operations include setting the mount-specific data with vfs_setfsprivate(). Note that if a mount call fails, the filesystem must clean up any state it has constructed, because vfs-level mount code will not clean it up. @param mp Mount structure for the newly mounted filesystem. @param devvp Device that the filesystem is mounted from. @param data Filesystem-specific data passed down from userspace. @param context Context to authenticate for mount. @return 0 for success, else an error code. Once success is returned, the filesystem should be ready to go active; VFS will not ask again.
int (*)(struct mount *, int, vfs_context_t)vfs_start@field vfs_start @abstract Mark a mount as ready to be used. @discussion After receiving this calldown, a filesystem will be hooked into the mount list and should expect calls down from the VFS layer. @param mp Mount structure being activated. @param flags Unused. @param context Context to authenticate for mount. @return Return value is ignored.
int (*)(struct mount *, int, vfs_context_t)vfs_unmount@field vfs_unmount @abstract Perform filesystem-specific cleanup as part of unmount. @discussion If the unmount downcall succeeds, VFS considers itself authorized to destroy all state related to the mount. @param mp Mount structure to unmount. @param mntflags MNT_FORCE indicates that we wish to unmount even if there are active vnodes. @param context Context to authenticate for unmount. @return 0 for success, else an error code.
int (*)(struct mount *, struct vnode **, vfs_context_t)vfs_root@field vfs_root @abstract Get the root vnode of a filesystem. @discussion Upon success, should return with an iocount held on the root vnode which the caller will drop with vnode_put(). @param mp Mount for which to get the root. @param vpp Destination for root vnode. @param context Context to authenticate for getting the root. @return 0 for success, else an error code.
int (*)(struct mount *, int, uid_t, caddr_t, vfs_context_t)vfs_quotactl@field vfs_quotactl @abstract Manipulate quotas for a volume. @param mp Mount for which to manipulate quotas. @param cmds Detailed in "quotactl" manual page. @param uid Detailed in "quotactl" manual page. @param arg Detailed in "quotactl" manual page. @param context Context to authenticate for changing quotas. @return 0 for success, else an error code.
int (*)(struct mount *, struct vfs_attr *, vfs_context_t)vfs_getattr@field vfs_getattr @abstract Get filesystem attributes. @discussion See VFSATTR_RETURN, VFSATTR_ACTIVE, VFSATTR_SET_SUPPORTED, VFSATTR_WANTED macros. @param mp Mount for which to get parameters. @param vfa Container for specifying which attributes are desired and which attributes the filesystem supports, as well as for returning results. @param context Context to authenticate for getting filesystem attributes. @return 0 for success, else an error code.
int (*)(struct mount *, int, vfs_context_t)vfs_sync@field vfs_sync @abstract Flush all filesystem data to backing store. @discussion vfs_sync will be called as part of the sync() system call and during unmount. @param mp Mountpoint to sync. @param waitfor MNT_WAIT: flush synchronously, waiting for all data to be written before returning. MNT_NOWAIT: start I/O but do not wait for it. @param context Context to authenticate for the sync. @return 0 for success, else an error code.
int (*)(struct mount *, ino64_t, struct vnode **, vfs_context_t)vfs_vget@field vfs_vget @abstract Get a vnode by file id (inode number). @discussion This routine is chiefly used to build paths to vnodes. Result should be turned with an iocount that the caller will drop with vnode_put(). @param mp Mount against which to look up inode number. @param ino File ID for desired file, as found through a readdir. @param vpp Destination for vnode. @return 0 for success, else an error code.
int (*)(struct mount *, int, unsigned char *, struct vnode **, vfs_context_t)vfs_fhtovp@field vfs_fhtovp @abstract Get the vnode corresponding to a file handle. @discussion Filesystems can return handles to files which are independent of their (transient) vnode identities. vfs_thtovp converts that persistent handle back to a vnode. The vnode should be returned with an iocount which the caller will drop with vnode_put(). @param mp Mount against which to look up file handle. @param fhlen Size of file handle structure, as returned by vfs_vptofh. @param fhp Pointer to handle. @param vpp Destination for vnode. @param context Context against which to authenticate the file-handle conversion. @return 0 for success, else an error code.
int (*)(struct vnode *, int *, unsigned char *, vfs_context_t)vfs_vptofh@field vfs_vptofh @abstract Get a persistent handle corresponding to a vnode. @param vp Vnode against which to obtain the file-handle @param fhlen Size of buffer provided for handle; set to size of actual handle returned. @param fhp Pointer to buffer in which to place handle data. @param context Context against which to authenticate the file-handle request. @return 0 for success, else an error code.
int (*)(struct vfsconf *)vfs_init@field vfs_init @abstract Prepare a filesystem for having instances mounted. @discussion This routine is called once, before any particular instance of a filesystem is mounted; it allows the filesystem to initialize whatever global data structures are shared across all mounts. If this returns successfully, a filesystem should be ready to have instances mounted. @param vfsc Configuration information. Currently, the only useful data are the filesystem name, typenum, and flags. The flags field will be either 0 or MNT_LOCAL. Many filesystems ignore this parameter. @return 0 for success, else an error code.
int (*)(int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t)vfs_sysctl@field vfs_sysctl @abstract Broad interface for querying and controlling filesystem. @discussion VFS defines VFS_CTL_QUERY as a generic status request which is answered with the VQ_* macros in a "struct vfsquery." A filesystem may also define implementation-specific commands. See "man 3 sysctl" for the meaning of sysctl parameters. @param context Context against which to authenticate command. @return 0 for success, else an error code.
int (*)(struct mount *, struct vfs_attr *, vfs_context_t)vfs_setattr@field vfs_setattr @abstract Set filesystem attributes. @discussion The other side of the vfs_getattr coin. Currently only called to set volume name. @param mp Mount on which to set attributes. @param vfa VFS attribute structure containing requested attributes to set and their values. Currently will only be called with f_vol_name set. @param context Context against which to authenticate attribute change. @return 0 for success, else an error code.
int (*)(struct mount *, u_long, caddr_t, int, vfs_context_t)vfs_ioctl@field vfs_ioctl @abstract File system control operations. @discussion Unlike vfs_sysctl, this is specific to a particular volume. @param mp The mount to execute the command on. @param command Identifier for action to take. The command used here should be in the same namespace as VNOP ioctl commands. @param data Pointer to data; this can be an integer constant (of 32 bits only) or an address to be read from or written to, depending on "command." If it is an address, it is valid and resides in the kernel; callers of VFS_IOCTL() are responsible for copying to and from userland. @param flags Reserved for future use, set to zero @param context Context against which to authenticate ioctl request. @return 0 for success, else an error code.
int (*)(struct mount *, struct vnode **, vfs_context_t)vfs_vget_snapdir@field vfs_vget_snapdir @abstract Get the vnode for the snapshot directory of a filesystem. @discussion Upon success, should return with an iocount held on the root vnode which the caller will drop with vnode_put(). @param mp Mount for which to get the root. @param vpp Destination for snapshot directory vnode. @param context Context to authenticate for getting the snapshot directory. @return 0 for success, else an error code.
void *vfs_reserved5
void *vfs_reserved4
void *vfs_reserved3
void *vfs_reserved2
void *vfs_reserved1

structfs_snapshot_mount_args

Commands for vfs_ioctl. While they are encoded the same way as for ioctl(2), there is no generic interface for them from userspace like ioctl(2).
size 16, align 8
mount_tsm_mp
struct componentname *sm_cnp

macroVFSIOC_MOUNT_SNAPSHOT

#define VFSIOC_MOUNT_SNAPSHOT _IOW('V', 1, struct fs_snapshot_mount_args)

structfs_snapshot_revert_args

size 8, align 8
struct componentname *sr_cnp

macroVFSIOC_REVERT_SNAPSHOT

#define VFSIOC_REVERT_SNAPSHOT _IOW('V', 2, struct fs_snapshot_revert_args)

structfs_snapshot_root_args

size 8, align 8
struct componentname *sr_cnp

macroVFSIOC_ROOT_SNAPSHOT

#define VFSIOC_ROOT_SNAPSHOT _IOW('V', 3, struct fs_snapshot_root_args)

structfs_role_mount_args

size 16, align 8
mount_troot_mp
uint32_tmount_role

typedeffs_role_mount_args_t

typedef struct fs_role_mount_args fs_role_mount_args_t;

enumvfs_roles_t

underlying type uint32_t
VFS_SYSTEM_ROLE1
VFS_RECOVERY_ROLE4
VFS_VM_ROLE8
VFS_PREBOOT_ROLE16
VFS_DATA_ROLE64

typedefvfs_roles_t

typedef enum vfs_roles_t vfs_roles_t;

macroVFSIOC_MOUNT_BYROLE

#define VFSIOC_MOUNT_BYROLE _IOW('V', 4, fs_role_mount_args_t)

macroVFSIOC_MOUNT_BYROLE_has_recovery

When this is defined, it is safe to use VFS_RECOVERY_ROLE and VFS_PREBOOT_ROLE.
#define VFSIOC_MOUNT_BYROLE_has_recovery 1

macroVFS_RETURNED

return values from callback
#define VFS_RETURNED 0
done with vnode, reference can be dropped

macroVFS_RETURNED_DONE

#define VFS_RETURNED_DONE 1
done with vnode, reference can be dropped, terminate iteration

macroVFS_CLAIMED

#define VFS_CLAIMED 2
don't drop reference

macroVFS_CLAIMED_DONE

#define VFS_CLAIMED_DONE 3
don't drop reference, terminate iteration

functionvfs_fsadd

int vfs_fsadd(struct vfs_fsentry *vfe, vfstable_t *handle)
@function vfs_fsadd @abstract Register a filesystem with VFS. @discussion Typically called by a filesystem Kernel Extension when it is loaded. @param vfe Filesystem information: table of vfs operations, list of vnode operation tables, filesystem type number (can be omitted with VFS_TBLNOTYPENUM flag), name, flags. @param handle Opaque handle which will be passed to vfs_fsremove. @return 0 for success, else an error code.

functionvfs_fsremove

int vfs_fsremove(vfstable_t handle)
@function vfs_fsremove @abstract Unregister a filesystem with VFS. @discussion Typically called by a filesystem Kernel Extension when it is unloaded. @param handle Handle which was returned by vfs_fsadd. @return 0 for success, else an error code.

functionvfs_iterate

int vfs_iterate(int flags, int (*callout)(struct mount *, void *), void *arg)
@function vfs_iterate @abstract Iterate over all mountpoints with a callback. Used, for example, by sync(). @param flags Unused. @param callout Function which takes a mount and arbitrary passed-in "arg," and returns one of VFS_RETURNED_DONE or VFS_CLAIMED_DONE: end iteration and return success. VFS_RETURNED or VFS_CLAIMED: continue iterating. Anything else: continue iterating. @param arg Arbitrary data to pass to callback. @return 0 for success, else an error code.

functionvfs_init_io_attributes

int vfs_init_io_attributes(vnode_t devvp, mount_t mp)
@function vfs_init_io_attributes @abstract Set I/O attributes on a mountpoint based on device properties. @param devvp Block device vnode from which a filesystem is being mounted. @param mp Mountpoint whose I/O parameters to initialize. @return 0 for success, else an error code.

functionvfs_flags

uint64_t vfs_flags(mount_t mp)
@function vfs_flags @abstract Retrieve mount flags. @discussion Results will be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS. @param mp Mount whose flags to grab. @return Flags.

functionvfs_setflags

void vfs_setflags(mount_t mp, uint64_t flags)
@function vfs_setflags @abstract Set flags on a mount. @discussion Sets mount flags to the bitwise "OR" of their current value and the specified bits. Often used by a filesystem as part of the mount process. @param mp Mount whose flags to set. @param flags Flags to activate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS.

functionvfs_clearflags

void vfs_clearflags(mount_t mp, uint64_t flags)
@function vfs_clearflags @abstract Clear flags on a mount. @discussion Sets mount flags to the bitwise "AND" of their current value and the complement of the specified bits. @param mp Mount whose flags to set. @param flags Flags to deactivate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS.

functionvfs_issynchronous

int vfs_issynchronous(mount_t mp)
@function vfs_issynchronous @abstract Determine if writes to a filesystem occur synchronously. @param mp Mount to test. @return Nonzero if writes occur synchronously, else 0.

functionvfs_iswriteupgrade

int vfs_iswriteupgrade(mount_t mp)
@function vfs_iswriteupgrade @abstract Determine if a filesystem is mounted read-only but a request has been made to upgrade to read-write. @param mp Mount to test. @return Nonzero if a request has been made to update from read-only to read-write, else 0.

functionvfs_isupdate

int vfs_isupdate(mount_t mp)
@function vfs_isupdate @abstract Determine if a mount update is in progress. @param mp Mount to test. @return Nonzero if a mount update is in progress, 0 otherwise.

functionvfs_isreload

int vfs_isreload(mount_t mp)
@function vfs_isreload @abstract Determine if a reload of filesystem data is in progress. This can only be the case for a read-only filesystem; all data is brought in from secondary storage. @param mp Mount to test. @return Nonzero if a request has been made to reload data, else 0.

functionvfs_isforce

int vfs_isforce(mount_t mp)
@function vfs_isforce @abstract Determine if a forced unmount is in progress. @discussion A forced unmount invalidates open files. @param mp Mount to test. @return Nonzero if a request has been made to forcibly unmount, else 0.

functionvfs_isunmount

int vfs_isunmount(mount_t mp)
@function vfs_isunmount @abstract Determine if an unmount is in progress. @discussion This is an unsynchronized snapshot of the mount state. It should only be called if the mount is known to be valid, e.g. there are known to be live files on that volume. @param mp Mount to test. @return Nonzero if an unmount is in progress, else zero.

functionvfs_isrdonly

int vfs_isrdonly(mount_t mp)
@function vfs_isrdonly @abstract Determine if a filesystem is mounted read-only. @param mp Mount to test. @return Nonzero if filesystem is mounted read-only, else 0.

functionvfs_isrdwr

int vfs_isrdwr(mount_t mp)
@function vfs_isrdwr @abstract Determine if a filesystem is mounted with writes enabled. @param mp Mount to test. @return Nonzero if filesystem is mounted read-write, else 0.

functionvfs_authopaque

int vfs_authopaque(mount_t mp)
@function vfs_authopaque @abstract Determine if a filesystem's authorization decisions occur remotely. @param mp Mount to test. @return Nonzero if filesystem authorization is controlled remotely, else 0.

functionvfs_authopaqueaccess

int vfs_authopaqueaccess(mount_t mp)
@function vfs_authopaqueaccess @abstract Check if a filesystem is marked as having reliable remote VNOP_ACCESS support. @param mp Mount to test. @return Nonzero if VNOP_ACCESS is supported remotely, else 0.

functionvfs_setauthopaque

void vfs_setauthopaque(mount_t mp)
@function vfs_setauthopaque @abstract Mark a filesystem as having authorization decisions controlled remotely. @param mp Mount to mark.

functionvfs_setauthopaqueaccess

void vfs_setauthopaqueaccess(mount_t mp)
@function vfs_setauthopaqueaccess @abstract Mark a filesystem as having remote VNOP_ACCESS support. @param mp Mount to mark.

functionvfs_clearauthopaque

void vfs_clearauthopaque(mount_t mp)
@function vfs_clearauthopaque @abstract Mark a filesystem as not having remote authorization decisions. @param mp Mount to mark.

functionvfs_clearauthopaqueaccess

void vfs_clearauthopaqueaccess(mount_t mp)
@function vfs_clearauthopaque @abstract Mark a filesystem as not having remote VNOP_ACCESS support. @param mp Mount to mark.

functionvfs_setextendedsecurity

void vfs_setextendedsecurity(mount_t mp)
@function vfs_setextendedsecurity @abstract Mark a filesystem as supporting security controls beyond POSIX permissions. @discussion Specific controls include ACLs, file owner UUIDs, and group UUIDs. @param mp Mount to test.

functionvfs_clearextendedsecurity

void vfs_clearextendedsecurity(mount_t mp)
@function vfs_clearextendedsecurity @abstract Mark a filesystem as NOT supporting security controls beyond POSIX permissions. @discussion Specific controls include ACLs, file owner UUIDs, and group UUIDs. @param mp Mount to test.

functionvfs_setlocklocal

void vfs_setlocklocal(mount_t mp)
@function vfs_setlocklocal @abstract Mark a filesystem as using VFS-level advisory locking support. @discussion Advisory locking operations will not call down to the filesystem if this flag is set. @param mp Mount to mark.

functionvfs_authcache_ttl

int vfs_authcache_ttl(mount_t mp)
@function vfs_authcache_ttl @abstract Determine the time-to-live of cached authorized credentials for files in this filesystem. @discussion If a filesystem is set to allow caching credentials, the VFS layer can authorize previously-authorized actions from the same vfs_context_t without calling down to the filesystem (though it will not deny based on the cache). @param mp Mount for which to check cache lifetime. @return Cache lifetime in seconds. CACHED_RIGHT_INFINITE_TTL indicates that credentials never expire.

functionvfs_setauthcache_ttl

void vfs_setauthcache_ttl(mount_t mp, int ttl)
@function vfs_setauthcache_ttl @abstract Enable credential caching and set time-to-live of cached authorized credentials for files in this filesystem. @discussion If a filesystem is set to allow caching credentials, the VFS layer can authorize previously-authorized actions from the same vfs_context_t without calling down to the filesystem (though it will not deny based on the cache). @param mp Mount for which to set cache lifetime.

functionvfs_clearauthcache_ttl

void vfs_clearauthcache_ttl(mount_t mp)
@function vfs_clearauthcache_ttl @abstract Remove time-to-live controls for cached credentials on a filesytem. Filesystems with remote authorization decisions (opaque) will still have KAUTH_VNODE_SEARCH rights cached for a default of CACHED_LOOKUP_RIGHT_TTL seconds. @param mp Mount for which to clear cache lifetime.

macroCACHED_RIGHT_INFINITE_TTL

return value from vfs_cachedrights_ttl if neither MNTK_AUTH_OPAQUE | MNTK_AUTH_CACHE_TTL is set in mnt_kern_flag.. it indicates that no TTL is being applied to the vnode rights cache
#define CACHED_RIGHT_INFINITE_TTL ~0

functionvfs_maxsymlen

uint32_t vfs_maxsymlen(mount_t mp)
@function vfs_maxsymlen @abstract Get the maximum length of a symbolic link on a filesystem. @param mp Mount from which to get symlink length cap. @return Max symlink length.

functionvfs_setmaxsymlen

void vfs_setmaxsymlen(mount_t mp, uint32_t symlen)
@function vfs_setmaxsymlen @abstract Set the maximum length of a symbolic link on a filesystem. @param mp Mount on which to set symlink length cap. @param symlen Length to set.

functionvfs_fsprivate

void * vfs_fsprivate(mount_t mp)
@function vfs_fsprivate @abstract Get filesystem-private mount data. @discussion A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure as part of the mounting process. @param mp Mount for which to get private data. @return Private data.

functionvfs_setfsprivate

void vfs_setfsprivate(mount_t mp, void *mntdata)
@function vfs_setfsprivate @abstract Set filesystem-private mount data. @discussion A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure as part of the mounting process. @param mp Mount for which to set private data.

functionvfs_statfs

struct vfsstatfs * vfs_statfs(mount_t mp)
@function vfs_statfs @abstract Get information about filesystem status. @discussion Each filesystem has a struct vfsstatfs associated with it which is updated as events occur; this function returns a pointer to it. Note that the data in the structure will continue to change over time and also that it may be quite stale if vfs_update_vfsstat has not been called recently. @param mp Mount for which to get vfsstatfs pointer. @return Pointer to vfsstatfs.

macroVFS_USER_EVENT

#define VFS_USER_EVENT 0

macroVFS_KERNEL_EVENT

#define VFS_KERNEL_EVENT 1

functionvfs_update_vfsstat

int vfs_update_vfsstat(mount_t mp, vfs_context_t ctx, int eventtype)
@function vfs_update_vfsstat @abstract Update cached filesystem status information in the VFS mount structure. @discussion Each filesystem has a struct vfsstatfs associated with it which is updated as events occur; this function updates it so that the structure pointer returned by vfs_statfs() returns a pointer to fairly recent data. @param mp Mount for which to update cached status information. @param ctx Context to authenticate against for call down to filesystem. @param eventtype VFS_USER_EVENT: need for update is driven by user-level request; perform additional authentication. VFS_KERNEL_EVENT: need for update is driven by in-kernel events. Skip extra authentication. @return 0 for success, or an error code for authentication failure or problem with call to filesystem to request information.

functionvfs_typenum

int vfs_typenum(mount_t mp)
@function vfs_typenum @abstract Get (archaic) filesystem type number. @discussion Filesystem type numbers are an old construct; most filesystems just get a number assigned based on the order in which they are registered with the system. @param mp Mount for which to get type number. @return Type number.

functionvfs_name

void vfs_name(mount_t mp, char *buffer)
@function vfs_name @abstract Copy filesystem name into a buffer. @discussion Get filesystem name; this refers to the filesystem type of which a mount is an instantiation, rather than a name specific to the mountpoint. @param mp Mount for which to get name. @param buffer Destination for name; length should be at least MFSNAMELEN.

functionvfs_devblocksize

int vfs_devblocksize(mount_t mp)
@function vfs_devblocksize @abstract Get the block size of the device underlying a mount. @param mp Mount for which to get block size. @return Block size.

functionvfs_ioattr

void vfs_ioattr(mount_t mp, struct vfsioattr *ioattrp)
@function vfs_ioattr @abstract Get I/O attributes associated with a mounpoint. @param mp Mount for which to get attributes. If NULL, system defaults are filled into ioattrp. @param ioattrp Destination for results.

functionvfs_setioattr

void vfs_setioattr(mount_t mp, struct vfsioattr *ioattrp)
@function vfs_setioattr @abstract Set I/O attributes associated with a mounpoint. @param mp Mount for which to set attributes. @param ioattrp Structure containing I/O parameters; all fields must be filled in.

functionvfs_64bitready

int vfs_64bitready(mount_t mp)
@function vfs_64bitready @abstract Check if the filesystem associated with a mountpoint is marked ready for interaction with 64-bit user processes. @param mp Mount to test. @return Nonzero if filesystem is ready for 64-bit; 0 otherwise.

macroLK_NOWAIT

#define LK_NOWAIT 1

functionvfs_busy

int vfs_busy(mount_t mp, int flags)
@function vfs_busy @abstract "Busy" a mountpoint. @discussion vfs_busy() will "busy" a mountpoint, preventing unmounts from taking off, by taking its reader-writer lock in a shared manner. If a mount is dead, it will fail; if an unmount is in progress, depending on flags, it will either fail immediately or block until the unmount completes (then failing if the unmount has succeeded, or potentially succeeding if unmounting failed). A successful vfs_busy() must be followed by a vfs_unbusy() to release the lock on the mount. @param mp Mount to busy. @param flags LK_NOWAIT: fail with ENOENT if an unmount is in progress. @return 0 for success, with a lock held; an error code otherwise, with no lock held.

functionvfs_unbusy

void vfs_unbusy(mount_t mp)
@function vfs_unbusy @abstract "Unbusy" a mountpoint by releasing its read-write lock. @discussion A successful vfs_busy() must be followed by a vfs_unbusy() to release the lock on the mount. @param mp Mount to unbusy.

functionvfs_getnewfsid

void vfs_getnewfsid(struct mount *mp)
@function vfs_getnewfsid @abstract Generate a unique filesystem ID for a mount and store it in the mount structure. @discussion Filesystem IDs are returned as part of "struct statfs." This function is typically called as part of file-system specific mount code (i.e. through VFS_MOUNT). @param mp Mount to set an ID for.

functionvfs_getvfs

mount_t vfs_getvfs(fsid_t *fsid)
@function vfs_getvfs @abstract Given a filesystem ID, look up a mount structure. @param fsid Filesystem ID to look up. @return Mountpoint if found, else NULL. Note unmounting mountpoints can be returned.

functionvfs_getvfs_with_vfsops

mount_t vfs_getvfs_with_vfsops(fsid_t *fsid, const struct vfsops *ops)
@function vfs_getvfs_with_vfsops @abstract Given a filesystem ID, look up a mount structure, verify the vfsops @param fsid Filesystem ID to look up. @return Mountpoint if found and the vfsops matches the expected value, else NULL. Note unmounting mountpoints can be returned.

functionvfs_mountedon

int vfs_mountedon(struct vnode *vp)
@function vfs_mountedon @abstract Check whether a given block device has a filesystem mounted on it. @discussion Note that this is NOT a check for a covered vnode (the directory upon which a filesystem is mounted)--it is a test for whether a block device is being used as the source of a filesystem. Note that a block device marked as being mounted on cannot be opened. @param vp The vnode to test. @return EBUSY if vnode is indeed the source of a filesystem; 0 if it is not.

functionvfs_unmountbyfsid

int vfs_unmountbyfsid(fsid_t *fsid, int flags, vfs_context_t ctx)
@function vfs_unmountbyfsid @abstract Find a filesystem by ID and unmount it. @param fsid ID of filesystem to unmount, as found through (for example) statfs. @param flags MNT_FORCE: forcibly invalidate files open on the mount (though in-flight I/O operations will be allowed to complete). @param ctx Context against which to authenticate unmount operation. @return 0 for succcess, nonero for failure.

functionvfs_event_signal

void vfs_event_signal(fsid_t *fsid, u_int32_t event, intptr_t data)
@function vfs_event_signal @abstract Post a kqueue-style event on a filesystem (EVFILT_FS). @param fsid Unused. @param event Events to post. @param data Unused.

functionvfs_event_init

void vfs_event_init(void)
@function vfs_event_init @abstract This function should not be called by kexts.
XXX We should not export this

functionvfs_set_root_unmounted_cleanly

void vfs_set_root_unmounted_cleanly(void)
@function vfs_set_root_unmount_cleanly @abstract This function should be called by the root file system when it is being mounted if the file system state is consistent.