1*04950071SJonathan Corbet============================== 2*04950071SJonathan CorbetDecoding an IOCTL Magic Number 3*04950071SJonathan Corbet============================== 4*04950071SJonathan Corbet 5*04950071SJonathan CorbetTo decode a hex IOCTL code: 6*04950071SJonathan Corbet 7*04950071SJonathan CorbetMost architectures use this generic format, but check 8*04950071SJonathan Corbetinclude/ARCH/ioctl.h for specifics, e.g. powerpc 9*04950071SJonathan Corbetuses 3 bits to encode read/write and 13 bits for size. 10*04950071SJonathan Corbet 11*04950071SJonathan Corbet ====== ================================== 12*04950071SJonathan Corbet bits meaning 13*04950071SJonathan Corbet ====== ================================== 14*04950071SJonathan Corbet 31-30 00 - no parameters: uses _IO macro 15*04950071SJonathan Corbet 10 - read: _IOR 16*04950071SJonathan Corbet 01 - write: _IOW 17*04950071SJonathan Corbet 11 - read/write: _IOWR 18*04950071SJonathan Corbet 19*04950071SJonathan Corbet 29-16 size of arguments 20*04950071SJonathan Corbet 21*04950071SJonathan Corbet 15-8 ascii character supposedly 22*04950071SJonathan Corbet unique to each driver 23*04950071SJonathan Corbet 24*04950071SJonathan Corbet 7-0 function # 25*04950071SJonathan Corbet ====== ================================== 26*04950071SJonathan Corbet 27*04950071SJonathan Corbet 28*04950071SJonathan CorbetSo for example 0x82187201 is a read with arg length of 0x218, 29*04950071SJonathan Corbetcharacter 'r' function 1. Grepping the source reveals this is:: 30*04950071SJonathan Corbet 31*04950071SJonathan Corbet #define VFAT_IOCTL_READDIR_BOTH _IOR('r', 1, struct dirent [2]) 32