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