VNOP_IOCTL
Call down to a filesystem or device driver to execute various control operations on or request data about a file.
Declaration
errno_t VNOP_IOCTL(vnode_t vp, u_long command, caddr_t data, int fflag, vfs_context_t ctx);Parameters
- vp:
The vnode to execute the command on.
- command:
Identifier for action to take.
- 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 VNOP_IOCTL() are responsible for copying to and from userland.
- ctx:
Context against which to authenticate ioctl request.
Return Value
0 for success or a filesystem-specific error.
Discussion
Ioctl controls are typically associated with devices, but they can in fact be passed down for any file; they are used to implement any of a wide range of controls and information requests. fcntl() calls VNOP_IOCTL for several commands, and will attempt a VNOP_IOCTL if it is passed an unknown command, though no copyin or copyout of arguments can occur in this case--the "arg" must be an integer value. Filesystems can define their own fcntls using this mechanism. How ioctl commands are structured is slightly complicated; see the manual page for ioctl(2).
See Also
Support
nop_accessnop_advlocknop_allocatenop_blktooffnop_blockmapnop_bwritenop_closenop_copyfilenop_createnop_exchangenop_fsyncnop_getattrnop_inactivenop_ioctlnop_linknop_mkdirnop_mknodnop_mmapnop_offtoblknop_opennop_pageinnop_pageoutnop_pathconfnop_readnop_readdirnop_readdirattrnop_readlinknop_reclaimnop_removenop_renamenop_revokenop_rmdirnop_searchfsnop_selectnop_setattrnop_strategynop_symlinknop_whiteoutnop_writeerr_accesserr_advlockerr_allocateerr_blktoofferr_blockmaperr_bwriteerr_closeerr_copyfileerr_createerr_exchangeerr_fsyncerr_getattrerr_inactiveerr_ioctlerr_linkerr_mkdirerr_mknoderr_mmaperr_offtoblkerr_openerr_pageinerr_pageouterr_pathconferr_readerr_readdirerr_readdirattrerr_readlinkerr_reclaimerr_removeerr_renameerr_revokeerr_rmdirerr_searchfserr_selecterr_setattrerr_strategyerr_symlinkerr_whiteouterr_writeadvisory_readadvisory_read_extVNOP_BWRITEVNOP_FSYNCVNOP_GETXATTRVNOP_READVNOP_SETXATTRVNOP_STRATEGYVNOP_WRITEcache_entercache_lookupcache_purgecache_purge_negatives