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