ioctl-number.txt 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194
  1. Ioctl Numbers
  2. 19 October 1999
  3. Michael Elizabeth Chastain
  4. <mec@shout.net>
  5. If you are adding new ioctl's to the kernel, you should use the _IO
  6. macros defined in <linux/ioctl.h>:
  7. _IO an ioctl with no parameters
  8. _IOW an ioctl with write parameters (copy_from_user)
  9. _IOR an ioctl with read parameters (copy_to_user)
  10. _IOWR an ioctl with both write and read parameters.
  11. 'Write' and 'read' are from the user's point of view, just like the
  12. system calls 'write' and 'read'. For example, a SET_FOO ioctl would
  13. be _IOW, although the kernel would actually read data from user space;
  14. a GET_FOO ioctl would be _IOR, although the kernel would actually write
  15. data to user space.
  16. The first argument to _IO, _IOW, _IOR, or _IOWR is an identifying letter
  17. or number from the table below. Because of the large number of drivers,
  18. many drivers share a partial letter with other drivers.
  19. If you are writing a driver for a new device and need a letter, pick an
  20. unused block with enough room for expansion: 32 to 256 ioctl commands.
  21. You can register the block by patching this file and submitting the
  22. patch to Linus Torvalds. Or you can e-mail me at <mec@shout.net> and
  23. I'll register one for you.
  24. The second argument to _IO, _IOW, _IOR, or _IOWR is a sequence number
  25. to distinguish ioctls from each other. The third argument to _IOW,
  26. _IOR, or _IOWR is the type of the data going into the kernel or coming
  27. out of the kernel (e.g. 'int' or 'struct foo'). NOTE! Do NOT use
  28. sizeof(arg) as the third argument as this results in your ioctl thinking
  29. it passes an argument of type size_t.
  30. Some devices use their major number as the identifier; this is OK, as
  31. long as it is unique. Some devices are irregular and don't follow any
  32. convention at all.
  33. Following this convention is good because:
  34. (1) Keeping the ioctl's globally unique helps error checking:
  35. if a program calls an ioctl on the wrong device, it will get an
  36. error rather than some unexpected behaviour.
  37. (2) The 'strace' build procedure automatically finds ioctl numbers
  38. defined with _IO, _IOW, _IOR, or _IOWR.
  39. (3) 'strace' can decode numbers back into useful names when the
  40. numbers are unique.
  41. (4) People looking for ioctls can grep for them more easily when
  42. this convention is used to define the ioctl numbers.
  43. (5) When following the convention, the driver code can use generic
  44. code to copy the parameters between user and kernel space.
  45. This table lists ioctls visible from user land for Linux/i386. It contains
  46. most drivers up to 2.3.14, but I know I am missing some.
  47. Code Seq# Include File Comments
  48. ========================================================
  49. 0x00 00-1F linux/fs.h conflict!
  50. 0x00 00-1F scsi/scsi_ioctl.h conflict!
  51. 0x00 00-1F linux/fb.h conflict!
  52. 0x00 00-1F linux/wavefront.h conflict!
  53. 0x02 all linux/fd.h
  54. 0x03 all linux/hdreg.h
  55. 0x04 all linux/umsdos_fs.h
  56. 0x06 all linux/lp.h
  57. 0x09 all linux/md.h
  58. 0x12 all linux/fs.h
  59. linux/blkpg.h
  60. 0x1b all InfiniBand Subsystem <http://www.openib.org/>
  61. 0x20 all drivers/cdrom/cm206.h
  62. 0x22 all scsi/sg.h
  63. '#' 00-3F IEEE 1394 Subsystem Block for the entire subsystem
  64. '1' 00-1F <linux/timepps.h> PPS kit from Ulrich Windl
  65. <ftp://ftp.de.kernel.org/pub/linux/daemons/ntp/PPS/>
  66. '8' all SNP8023 advanced NIC card
  67. <mailto:mcr@solidum.com>
  68. 'A' 00-1F linux/apm_bios.h
  69. 'B' C0-FF advanced bbus
  70. <mailto:maassen@uni-freiburg.de>
  71. 'C' all linux/soundcard.h
  72. 'D' all asm-s390/dasd.h
  73. 'E' all linux/input.h
  74. 'F' all linux/fb.h
  75. 'H' all linux/hiddev.h
  76. 'I' all linux/isdn.h
  77. 'J' 00-1F drivers/scsi/gdth_ioctl.h
  78. 'K' all linux/kd.h
  79. 'L' 00-1F linux/loop.h
  80. 'L' E0-FF linux/ppdd.h encrypted disk device driver
  81. <http://linux01.gwdg.de/~alatham/ppdd.html>
  82. 'M' all linux/soundcard.h
  83. 'N' 00-1F drivers/usb/scanner.h
  84. 'P' all linux/soundcard.h
  85. 'Q' all linux/soundcard.h
  86. 'R' 00-1F linux/random.h
  87. 'S' all linux/cdrom.h conflict!
  88. 'S' 80-81 scsi/scsi_ioctl.h conflict!
  89. 'S' 82-FF scsi/scsi.h conflict!
  90. 'T' all linux/soundcard.h conflict!
  91. 'T' all asm-i386/ioctls.h conflict!
  92. 'U' 00-EF linux/drivers/usb/usb.h
  93. 'U' F0-FF drivers/usb/auerswald.c
  94. 'V' all linux/vt.h
  95. 'W' 00-1F linux/watchdog.h conflict!
  96. 'W' 00-1F linux/wanrouter.h conflict!
  97. 'X' all linux/xfs_fs.h
  98. 'Y' all linux/cyclades.h
  99. 'a' all ATM on linux
  100. <http://lrcwww.epfl.ch/linux-atm/magic.html>
  101. 'b' 00-FF bit3 vme host bridge
  102. <mailto:natalia@nikhefk.nikhef.nl>
  103. 'c' 00-7F linux/comstats.h conflict!
  104. 'c' 00-7F linux/coda.h conflict!
  105. 'd' 00-FF linux/char/drm/drm/h conflict!
  106. 'd' 00-DF linux/video_decoder.h conflict!
  107. 'd' F0-FF linux/digi1.h
  108. 'e' all linux/digi1.h conflict!
  109. 'e' 00-1F linux/video_encoder.h conflict!
  110. 'e' 00-1F net/irda/irtty.h conflict!
  111. 'f' 00-1F linux/ext2_fs.h
  112. 'h' 00-7F Charon filesystem
  113. <mailto:zapman@interlan.net>
  114. 'i' 00-3F linux/i2o.h
  115. 'j' 00-3F linux/joystick.h
  116. 'l' 00-3F linux/tcfs_fs.h transparent cryptographic file system
  117. <http://mikonos.dia.unisa.it/tcfs>
  118. 'l' 40-7F linux/udf_fs_i.h in development:
  119. <http://sourceforge.net/projects/linux-udf/>
  120. 'm' all linux/mtio.h conflict!
  121. 'm' all linux/soundcard.h conflict!
  122. 'm' all linux/synclink.h conflict!
  123. 'm' 00-1F net/irda/irmod.h conflict!
  124. 'n' 00-7F linux/ncp_fs.h
  125. 'n' E0-FF video/matrox.h matroxfb
  126. 'p' 00-3F linux/mc146818rtc.h
  127. 'p' 40-7F linux/nvram.h
  128. 'p' 80-9F user-space parport
  129. <mailto:tim@cyberelk.net>
  130. 'q' 00-1F linux/serio.h
  131. 'q' 80-FF Internet PhoneJACK, Internet LineJACK
  132. <http://www.quicknet.net>
  133. 'r' 00-1F linux/msdos_fs.h
  134. 's' all linux/cdk.h
  135. 't' 00-7F linux/if_ppp.h
  136. 't' 80-8F linux/isdn_ppp.h
  137. 'u' 00-1F linux/smb_fs.h
  138. 'v' 00-1F linux/ext2_fs.h conflict!
  139. 'v' all linux/videodev.h conflict!
  140. 'w' all CERN SCI driver
  141. 'y' 00-1F packet based user level communications
  142. <mailto:zapman@interlan.net>
  143. 'z' 00-3F CAN bus card
  144. <mailto:hdstich@connectu.ulm.circular.de>
  145. 'z' 40-7F CAN bus card
  146. <mailto:oe@port.de>
  147. 0x80 00-1F linux/fb.h
  148. 0x81 00-1F linux/videotext.h
  149. 0x89 00-06 asm-i386/sockios.h
  150. 0x89 0B-DF linux/sockios.h
  151. 0x89 E0-EF linux/sockios.h SIOCPROTOPRIVATE range
  152. 0x89 F0-FF linux/sockios.h SIOCDEVPRIVATE range
  153. 0x8B all linux/wireless.h
  154. 0x8C 00-3F WiNRADiO driver
  155. <http://www.proximity.com.au/~brian/winradio/>
  156. 0x90 00 drivers/cdrom/sbpcd.h
  157. 0x93 60-7F linux/auto_fs.h
  158. 0x99 00-0F 537-Addinboard driver
  159. <mailto:buk@buks.ipn.de>
  160. 0xA0 all linux/sdp/sdp.h Industrial Device Project
  161. <mailto:kenji@bitgate.com>
  162. 0xA3 80-8F Port ACL in development:
  163. <mailto:tlewis@mindspring.com>
  164. 0xA3 90-9F linux/dtlk.h
  165. 0xAB 00-1F linux/nbd.h
  166. 0xAC 00-1F linux/raw.h
  167. 0xAD 00 Netfilter device in development:
  168. <mailto:rusty@rustcorp.com.au>
  169. 0xB0 all RATIO devices in development:
  170. <mailto:vgo@ratio.de>
  171. 0xB1 00-1F PPPoX <mailto:mostrows@styx.uwaterloo.ca>
  172. 0xCB 00-1F CBM serial IEC bus in development:
  173. <mailto:michael.klein@puffin.lb.shuttle.de>
  174. 0xDD 00-3F ZFCP device driver see drivers/s390/scsi/
  175. <mailto:aherrman@de.ibm.com>
  176. 0xF3 00-3F video/sisfb.h sisfb (in development)
  177. <mailto:thomas@winischhofer.net>
  178. 0xF4 00-1F video/mbxfb.h mbxfb
  179. <mailto:raph@8d.com>