mount.h |
Includes: |
<sys/appleapiopts.h> <sys/cdefs.h> <sys/attr.h> <sys/kernel_types.h> <uuid/uuid.h> |
Use the links in the table of contents to the left to access the documentation.
Check if the filesystem associated with a mountpoint is marked ready for interaction with 64-bit user processes.
Determine the time-to-live of cached authorized credentials for files in this filesystem.
Determine if a filesystem's authorization decisions occur remotely.
Check if a filesystem is marked as having reliable remote VNOP_ACCESS support.
"Busy" a mountpoint.
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.
Mark a filesystem as not having remote authorization decisions.
Mark a filesystem as not having remote VNOP_ACCESS support.
Mark a filesystem as not having remote VNOP_ACCESS support.
Mark a filesystem as NOT supporting security controls beyond POSIX permissions.
Clear flags on a mount.
Get the block size of the device underlying a mount.
This function should not be called by kexts.
Post a kqueue-style event on a filesystem (EVFILT_FS).
Get the vnode corresponding to a file handle.
Retrieve mount flags.
Register a filesystem with VFS.
Get filesystem-private mount data.
Unregister a filesystem with VFS.
Get filesystem attributes.
Generate a unique filesystem ID for a mount and store it in the mount structure.
Given a filesystem ID, look up a mount structure.
Prepare a filesystem for having instances mounted.
Set I/O attributes on a mountpoint based on device properties.
Get I/O attributes associated with a mounpoint.
Determine if a forced unmount is in progress.
Determine if a filesystem is mounted read-only.
Determine if a filesystem is mounted with writes enabled.
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.
Determine if writes to a filesystem occur synchronously.
Determine if an unmount is in progress.
Determine if a mount update is in progress.
Determine if a filesystem is mounted read-only but a request has been made to upgrade to read-write.
Iterate over all mountpoints with a callback. Used, for example, by sync().
Get the maximum length of a symbolic link on a filesystem.
Perform filesystem-specific operations required for mounting.
Check whether a given block device has a filesystem mounted on it.
Copy filesystem name into a buffer.
Manipulate quotas for a volume.
Get the root vnode of a filesystem.
Set filesystem attributes.
Enable credential caching and set time-to-live of cached authorized credentials for files in this filesystem.
Mark a filesystem as having authorization decisions controlled remotely.
Mark a filesystem as having remote VNOP_ACCESS support.
Mark a filesystem as supporting security controls beyond POSIX permissions.
Set flags on a mount.
Set filesystem-private mount data.
Set I/O attributes associated with a mounpoint.
Mark a filesystem as using VFS-level advisory locking support.
Set the maximum length of a symbolic link on a filesystem.
Mark a mount as ready to be used.
Get information about filesystem status.
Flush all filesystem data to backing store.
Broad interface for querying and controlling filesystem.
Get (archaic) filesystem type number.
"Unbusy" a mountpoint by releasing its read-write lock.
Perform filesystem-specific cleanup as part of unmount.
Find a filesystem by ID and unmount it.
Update cached filesystem status information in the VFS mount structure.
Get a vnode by file id (inode number).
Get a persistent handle corresponding to a vnode.
vfs_64bitready |
Check if the filesystem associated with a mountpoint is marked ready for interaction with 64-bit user processes.
int vfs_64bitready( mount_t);
mp
Mount to test.
Nonzero if filesystem is ready for 64-bit; 0 otherwise.
vfs_authcache_ttl |
Determine the time-to-live of cached authorized credentials for files in this filesystem.
int vfs_authcache_ttl( mount_t);
mp
Mount for which to check cache lifetime.
Cache lifetime in seconds. CACHED_RIGHT_INFINITE_TTL indicates that credentials never expire.
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).
vfs_authopaque |
Determine if a filesystem's authorization decisions occur remotely.
int vfs_authopaque( mount_t);
mp
Mount to test.
Nonzero if filesystem authorization is controlled remotely, else 0.
vfs_authopaqueaccess |
Check if a filesystem is marked as having reliable remote VNOP_ACCESS support.
int vfs_authopaqueaccess( mount_t);
mp
Mount to test.
Nonzero if VNOP_ACCESS is supported remotely, else 0.
vfs_busy |
"Busy" a mountpoint.
int vfs_busy( mount_t, int);
mp
Mount to busy.
flags
LK_NOWAIT: fail with ENOENT if an unmount is in progress.
0 for success, with a lock held; an error code otherwise, with no lock held.
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.
vfs_clearauthcache_ttl |
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.
void vfs_clearauthcache_ttl( mount_t);
mp
Mount for which to clear cache lifetime.
void.
vfs_clearauthopaque(mount_t) |
Mark a filesystem as not having remote authorization decisions.
void vfs_clearauthopaque( mount_t);
mp
Mount to mark.
void.
vfs_clearauthopaque(mount_t) |
Mark a filesystem as not having remote VNOP_ACCESS support.
void vfs_clearauthopaqueaccess( mount_t);
mp
Mount to mark.
void.
vfs_clearauthopaqueaccess |
Mark a filesystem as not having remote VNOP_ACCESS support.
void vfs_clearauthopaqueaccess( mount_t);
mp
Mount to mark.
void.
vfs_clearextendedsecurity |
Mark a filesystem as NOT supporting security controls beyond POSIX permissions.
void vfs_clearextendedsecurity( mount_t);
mp
Mount to test.
void.
Specific controls include ACLs, file owner UUIDs, and group UUIDs.
vfs_clearflags |
Clear flags on a mount.
void vfs_clearflags( mount_t, uint64_t);
mp
Mount whose flags to set.
flags
Flags to deactivate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS.
void.
Sets mount flags to the bitwise "AND" of their current value and the complement of the specified bits.
vfs_devblocksize |
Get the block size of the device underlying a mount.
int vfs_devblocksize( mount_t);
mp
Mount for which to get block size.
Block size.
vfs_event_init |
This function should not be called by kexts.
void vfs_event_init( void); /* XXX We should not export this */
vfs_event_signal |
Post a kqueue-style event on a filesystem (EVFILT_FS).
void vfs_event_signal( fsid_t *, u_int32_t, intptr_t);
fsid
Unused.
event
Events to post.
data
Unused.
void.
vfs_fhtovp |
Get the vnode corresponding to a file handle.
int ( *vfs_fhtovp)( struct mount *mp, int fhlen, unsigned char *fhp, struct vnode **vpp, vfs_context_t context);
mp
Mount against which to look up file handle.
fhlen
Size of file handle structure, as returned by vfs_vptofh.
fhp
Pointer to handle.
vpp
Destination for vnode.
ctx
Context against which to authenticate the file-handle conversion.
0 for success, else an error code.
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().
vfs_flags |
Retrieve mount flags.
uint64_t vfs_flags( mount_t);
mp
Mount whose flags to grab.
Flags.
Results will be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS.
vfs_fsadd |
Register a filesystem with VFS.
int vfs_fsadd( struct vfs_fsentry *, vfstable_t *);
vfe
Filesystem information: table of vfs operations, list of vnode operation tables, filesystem type number (can be omitted with VFS_TBLNOTYPENUM flag), name, flags.
handle
Opaque handle which will be passed to vfs_fsremove.
0 for success, else an error code.
Typically called by a filesystem Kernel Extension when it is loaded.
vfs_fsprivate |
Get filesystem-private mount data.
void * vfs_fsprivate( mount_t);
mp
Mount for which to get private data.
Private data.
A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure as part of the mounting process.
vfs_fsremove |
Unregister a filesystem with VFS.
int vfs_fsremove( vfstable_t);
handle
Handle which was returned by vfs_fsadd.
0 for success, else an error code.
Typically called by a filesystem Kernel Extension when it is unloaded.
vfs_getattr |
Get filesystem attributes.
int ( *vfs_getattr)( struct mount *mp, struct vfs_attr *, vfs_context_t context);
mp
Mount for which to get parameters.
vfa
Container for specifying which attributes are desired and which attributes the filesystem supports, as well as for returning results.
ctx
Context to authenticate for getting filesystem attributes.
0 for success, else an error code.
See VFSATTR_RETURN, VFSATTR_ACTIVE, VFSATTR_SET_SUPPORTED, VFSATTR_WANTED macros.
vfs_getnewfsid |
Generate a unique filesystem ID for a mount and store it in the mount structure.
void vfs_getnewfsid( struct mount *);
mp
Mount to set an ID for.
void.
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).
vfs_getvfs |
Given a filesystem ID, look up a mount structure.
mount_t vfs_getvfs( fsid_t *);
fsid
Filesystem ID to look up.
Mountpoint if found, else NULL. Note unmounting mountpoints can be returned.
vfs_init |
Prepare a filesystem for having instances mounted.
int ( *vfs_init)( struct vfsconf *);
vfsconf
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.
0 for success, else an error code.
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.
vfs_init_io_attributes |
Set I/O attributes on a mountpoint based on device properties.
int vfs_init_io_attributes( vnode_t, mount_t);
devvp
Block device vnode from which a filesystem is being mounted.
mp
Mountpoint whose I/O parameters to initialize.
0 for success, else an error code.
vfs_ioattr |
Get I/O attributes associated with a mounpoint.
void vfs_ioattr( mount_t, struct vfsioattr *);
mp
Mount for which to get attributes. If NULL, system defaults are filled into ioattrp.
ioattrp
Destination for results.
void.
vfs_isforce |
Determine if a forced unmount is in progress.
int vfs_isforce( mount_t);
mp
Mount to test.
Nonzero if a request has been made to forcibly unmount, else 0.
A forced unmount invalidates open files.
vfs_isrdonly |
Determine if a filesystem is mounted read-only.
int vfs_isrdonly( mount_t);
mp
Mount to test.
Nonzero if filesystem is mounted read-only, else 0.
vfs_isrdwr |
Determine if a filesystem is mounted with writes enabled.
int vfs_isrdwr( mount_t);
mp
Mount to test.
Nonzero if filesystem is mounted read-write, else 0.
vfs_isreload |
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.
int vfs_isreload( mount_t);
mp
Mount to test.
Nonzero if a request has been made to reload data, else 0.
vfs_issynchronous |
Determine if writes to a filesystem occur synchronously.
int vfs_issynchronous( mount_t);
mp
Mount to test.
Nonzero if writes occur synchronously, else 0.
vfs_isunmount |
Determine if an unmount is in progress.
int vfs_isunmount( mount_t mp);
mp
Mount to test.
Nonzero if an unmount is in progress, else zero.
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.
vfs_isupdate |
Determine if a mount update is in progress.
int vfs_isupdate( mount_t);
mp
Mount to test.
Nonzero if a mount update is in progress, 0 otherwise.
vfs_iswriteupgrade |
Determine if a filesystem is mounted read-only but a request has been made to upgrade to read-write.
int vfs_iswriteupgrade( mount_t);
mp
Mount to test.
Nonzero if a request has been made to update from read-only to read-write, else 0.
vfs_iterate |
Iterate over all mountpoints with a callback. Used, for example, by sync().
int vfs_iterate( int, int (*)( struct mount *, void *), void *);
flags
Unused.
callback
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.
arg
Arbitrary data to pass to callback.
0 for success, else an error code.
vfs_maxsymlen |
Get the maximum length of a symbolic link on a filesystem.
uint32_t vfs_maxsymlen( mount_t);
mp
Mount from which to get symlink length cap.
Max symlink length.
vfs_mount |
Perform filesystem-specific operations required for mounting.
int ( *vfs_mount)( struct mount *mp, vnode_t devvp, user_addr_t data, vfs_context_t context);
mp
Mount structure for the newly mounted filesystem.
devvp
Device that the filesystem is mounted from.
data
Filesystem-specific data passed down from userspace.
context
Context to authenticate for mount.
0 for success, else an error code. Once success is returned, the filesystem should be ready to go active; VFS will not ask again.
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.
vfs_mountedon |
Check whether a given block device has a filesystem mounted on it.
int vfs_mountedon( struct vnode *);
vp
The vnode to test.
EBUSY if vnode is indeed the source of a filesystem; 0 if it is not.
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.
vfs_name |
Copy filesystem name into a buffer.
mp
Mount for which to get name.
buffer
Destination for name; length should be at least MFSNAMELEN.
void.
Get filesystem name; this refers to the filesystem type of which a mount is an instantiation, rather than a name specific to the mountpoint.
vfs_quotactl |
Manipulate quotas for a volume.
int ( *vfs_quotactl)( struct mount *mp, int cmds, uid_t uid, caddr_t arg, vfs_context_t context);
mp
Mount for which to manipulate quotas.
cmds
Detailed in "quotactl" manual page.
uid
Detailed in "quotactl" manual page.
arg
Detailed in "quotactl" manual page.
context
Context to authenticate for changing quotas.
0 for success, else an error code.
vfs_root |
Get the root vnode of a filesystem.
int ( *vfs_root)( struct mount *mp, struct vnode **vpp, vfs_context_t context);
mp
Mount for which to get the root.
vpp
Destination for root vnode.
context
Context to authenticate for getting the root.
0 for success, else an error code.
Upon success, should return with an iocount held on the root vnode which the caller will drop with vnode_put().
vfs_setattr |
Set filesystem attributes.
int ( *vfs_setattr)( struct mount *mp, struct vfs_attr *, vfs_context_t context);
mp
Mount on which to set attributes.
vfa
VFS attribute structure containing requested attributes to set and their values. Currently will only be called with f_vol_name set.
context
Context against which to authenticate attribute change.
0 for success, else an error code.
The other side of the vfs_getattr coin. Currently only called to set volume name.
vfs_setauthcache_ttl |
Enable credential caching and set time-to-live of cached authorized credentials for files in this filesystem.
void vfs_setauthcache_ttl( mount_t, int);
mp
Mount for which to set cache lifetime.
void.
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).
vfs_setauthopaque |
Mark a filesystem as having authorization decisions controlled remotely.
void vfs_setauthopaque( mount_t);
mp
Mount to mark.
void.
vfs_setauthopaqueaccess |
Mark a filesystem as having remote VNOP_ACCESS support.
void vfs_setauthopaqueaccess( mount_t);
mp
Mount to mark.
void.
vfs_setextendedsecurity |
Mark a filesystem as supporting security controls beyond POSIX permissions.
void vfs_setextendedsecurity( mount_t);
mp
Mount to test.
void.
Specific controls include ACLs, file owner UUIDs, and group UUIDs.
vfs_setflags |
Set flags on a mount.
void vfs_setflags( mount_t, uint64_t);
mp
Mount whose flags to set.
flags
Flags to activate. Must be in the bitwise "OR" of MNT_VISFLAGMASK and MNT_CMDFLAGS.
Flags.
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.
vfs_setfsprivate |
Set filesystem-private mount data.
void vfs_setfsprivate( mount_t, void *mntdata);
mp
Mount for which to set private data.
Void.
A filesystem generally has an internal mount structure which it attaches to the VFS-level mount structure as part of the mounting process.
vfs_setioattr |
Set I/O attributes associated with a mounpoint.
void vfs_setioattr( mount_t, struct vfsioattr *);
mp
Mount for which to set attributes.
ioattrp
Structure containing I/O parameters; all fields must be filled in.
void.
vfs_setlocklocal |
Mark a filesystem as using VFS-level advisory locking support.
void vfs_setlocklocal( mount_t);
mp
Mount to mark.
void.
Advisory locking operations will not call down to the filesystem if this flag is set.
vfs_setmaxsymlen |
Set the maximum length of a symbolic link on a filesystem.
void vfs_setmaxsymlen( mount_t, uint32_t);
mp
Mount on which to set symlink length cap.
symlen
Length to set.
Max symlink length.
vfs_start |
Mark a mount as ready to be used.
int ( *vfs_start)( struct mount *mp, int flags, vfs_context_t context);
mp
Mount structure being activated.
flags
Unused.
context
Context to authenticate for mount.
Return value is ignored.
After receiving this calldown, a filesystem will be hooked into the mount list and should expect calls down from the VFS layer.
vfs_statfs |
Get information about filesystem status.
struct vfsstatfs * vfs_statfs( mount_t);
mp
Mount for which to get vfsstatfs pointer.
Pointer to vfsstatfs.
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 of vfs_update_vfsstat has not been called recently.
vfs_sync |
Flush all filesystem data to backing store.
int ( *vfs_sync)( struct mount *mp, int waitfor, vfs_context_t context);
mp
Mountpoint to sync.
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.
ctx
Context to authenticate for the sync.
0 for success, else an error code.
vfs_sync will be called as part of the sync() system call and during unmount.
vfs_sysctl |
Broad interface for querying and controlling filesystem.
int ( *vfs_sysctl)( int *, u_int, user_addr_t, size_t *, user_addr_t, size_t, vfs_context_t context);
context
Context against which to authenticate command.
0 for success, else an error code.
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.
vfs_typenum |
Get (archaic) filesystem type number.
int vfs_typenum( mount_t);
mp
Mount for which to get type number.
Type number.
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.
vfs_unbusy |
"Unbusy" a mountpoint by releasing its read-write lock.
void vfs_unbusy( mount_t);
mp
Mount to unbusy.
void.
A successful vfs_busy() must be followed by a vfs_unbusy() to release the lock on the mount.
vfs_unmount |
Perform filesystem-specific cleanup as part of unmount.
int ( *vfs_unmount)( struct mount *mp, int mntflags, vfs_context_t context);
mp
Mount structure to unmount.
mntflags
MNT_FORCE indicates that we wish to unmount even if there are active vnodes.
context
Context to authenticate for unmount.
0 for success, else an error code.
If the unmount downcall succeeds, VFS considers itself authorized to destroy all state related to the mount.
vfs_unmountbyfsid |
Find a filesystem by ID and unmount it.
int vfs_unmountbyfsid( fsid_t *, int, vfs_context_t);
fsid
ID of filesystem to unmount, as found through (for example) statfs.
flags
MNT_FORCE: forcibly invalidate files open on the mount (though in-flight I/O operations will be allowed to complete).
ctx
Context against which to authenticate unmount operation.
0 for succcess, nonero for failure.
vfs_update_vfsstat |
Update cached filesystem status information in the VFS mount structure.
int vfs_update_vfsstat( mount_t, vfs_context_t, int eventtype);
mp
Mount for which to update cached status information.
ctx
Context to authenticate against for call down to filesystem.
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.
0 for success, or an error code for authentication failure or problem with call to filesystem to request information.
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.
vfs_vget |
Get a vnode by file id (inode number).
int ( *vfs_vget)( struct mount *mp, ino64_t ino, struct vnode **vpp, vfs_context_t context);
mp
Mount against which to look up inode number.
ino
File ID for desired file, as found through a readdir.
vpp
Destination for vnode.
0 for success, else an error code.
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().
vfs_vptofh |
Get a persistent handle corresponding to a vnode.
int ( *vfs_vptofh)( struct vnode *vp, int *fhlen, unsigned char *fhp, vfs_context_t context);
mp
Mount against which to convert the vnode to a handle.
fhlen
Size of buffer provided for handle; set to size of actual handle returned.
fhp
Pointer to buffer in which to place handle data.
ctx
Context against which to authenticate the file-handle request.
0 for success, else an error code.
Last Updated: 2010-07-29