module IOCTL

Included Modules

Extended Modules

Defined in:

asm-generic/ioctl.cr
ioctl.cr

Constant Summary

DIRBITS = 2
IOC_DIRMASK = (1 << IOC_DIRBITS) - 1
IOC_DIRSHIFT = IOC_SIZESHIFT + IOC_SIZEBITS
IOC_IN = IOC_WRITE << IOC_DIRSHIF

for the drivers/sound files...

IOC_INOUT = (IOC_WRITE | IOC_READ) << IOC_DIRSHIFT
IOC_NRBITS = 8

The following is for compatibility across the various Linux platforms. The generic ioctl numbering scheme doesn't really enforce a type field. De facto, however, the top 8 bits of the lower 16 bits are indeed used as a type field, so we might just as well make this explicit here. Please be sure to use the decoding macros below from now on.

IOC_NRMASK = (1 << IOC_NRBITS) - 1
IOC_NRSHIFT = 0
IOC_OUT = IOC_READ << IOC_DIRSHIFT
IOC_SIZEBITS = 14

Let any architecture override either of the following before including this file.

IOC_SIZEMASK = (1 << IOC_SIZEBITS) - 1
IOC_SIZESHIFT = IOC_TYPESHIFT + IOC_TYPEBITS
IOC_TYPEBITS = 8
IOC_TYPEMASK = (1 << IOC_TYPEBITS) - 1
IOC_TYPESHIFT = IOC_NRSHIFT + IOC_NRBITS
IOCSIZE_MASK = IOC_SIZEMASK << IOC_SIZESHIFT
IOCSIZE_SHIFT = IOC_SIZESHIFT
VERSION = "0.1.0"

Instance Method Summary

Instance Method Detail

def _IO(type : Char | Int, nr : Int) : UInt32 #

[View source]
def _IOC(dir : IOC, type : Int | Char, nr : Int, size : Int) : UInt32 #

Used to create numbers.


[View source]
def _IOC_DIR(dir : IOC) #

Decodes ioctl dir number.


[View source]
def _IOC_NR(nr : Int) #

Decodes ioctl nr number.


[View source]
def _IOC_SIZE(size : Int) #

Decodes ioctl size number.


[View source]
def _IOC_TYPE(type : Char | Int) #

Decodes ioctl type number.


[View source]
def _IOR(type : Char | Int, nr : Int, size : T.class) : UInt32 forall T #

_IOR means userland is reading and kernel is writing.


[View source]
def _IOW(type : Char | Int, nr : Int, size : T.class) : UInt32 forall T #

_IOW means userland is writing and kernel is reading.


[View source]
def _IOWR(type : Char | Int, nr : Int, size : T.class) : UInt32 forall T #

[View source]
def ioctl(fd : LibC::Int, request : UInt32, *arguments) : Nil #

Executes an #ioctl call, and raises in case of an error


[View source]
def ioctl?(fd : LibC::Int, request : UInt32, *arguments) : Errno | Nil #

Executes an #ioctl call, and returns an Errno in case of an error.


[View source]