Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | Ioctl Numbers |
2 | 19 October 1999 | |
3 | Michael Elizabeth Chastain | |
4 | <mec@shout.net> | |
5 | ||
6 | If you are adding new ioctl's to the kernel, you should use the _IO | |
7 | macros 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 | |
15 | system calls 'write' and 'read'. For example, a SET_FOO ioctl would | |
16 | be _IOW, although the kernel would actually read data from user space; | |
17 | a GET_FOO ioctl would be _IOR, although the kernel would actually write | |
18 | data to user space. | |
19 | ||
20 | The first argument to _IO, _IOW, _IOR, or _IOWR is an identifying letter | |
21 | or number from the table below. Because of the large number of drivers, | |
22 | many drivers share a partial letter with other drivers. | |
23 | ||
24 | If you are writing a driver for a new device and need a letter, pick an | |
25 | unused block with enough room for expansion: 32 to 256 ioctl commands. | |
26 | You can register the block by patching this file and submitting the | |
27 | patch to Linus Torvalds. Or you can e-mail me at <mec@shout.net> and | |
28 | I'll register one for you. | |
29 | ||
30 | The second argument to _IO, _IOW, _IOR, or _IOWR is a sequence number | |
31 | to 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 | |
33 | out of the kernel (e.g. 'int' or 'struct foo'). NOTE! Do NOT use | |
34 | sizeof(arg) as the third argument as this results in your ioctl thinking | |
35 | it passes an argument of type size_t. | |
36 | ||
37 | Some devices use their major number as the identifier; this is OK, as | |
38 | long as it is unique. Some devices are irregular and don't follow any | |
39 | convention at all. | |
40 | ||
41 | Following 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 | ||
59 | This table lists ioctls visible from user land for Linux/i386. It contains | |
60 | most drivers up to 2.3.14, but I know I am missing some. | |
61 | ||
62 | Code Seq# Include File Comments | |
63 | ======================================================== | |
64 | 0x00 00-1F linux/fs.h conflict! | |
65 | 0x00 00-1F scsi/scsi_ioctl.h conflict! | |
66 | 0x00 00-1F linux/fb.h conflict! | |
67 | 0x00 00-1F linux/wavefront.h conflict! | |
68 | 0x02 all linux/fd.h | |
69 | 0x03 all linux/hdreg.h | |
d5298802 | 70 | 0x04 D2-DC linux/umsdos_fs.h Dead since 2.6.11, but don't reuse these. |
1da177e4 LT |
71 | 0x06 all linux/lp.h |
72 | 0x09 all linux/md.h | |
73 | 0x12 all linux/fs.h | |
74 | linux/blkpg.h | |
75 | 0x1b all InfiniBand Subsystem <http://www.openib.org/> | |
76 | 0x20 all drivers/cdrom/cm206.h | |
77 | 0x22 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/> | |
1da177e4 LT |
81 | '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 | |
07983f0e | 87 | 'D' all arch/s390/include/asm/dasd.h |
cb259f07 | 88 | 'E' all linux/input.h |
1da177e4 | 89 | 'F' all linux/fb.h |
cb259f07 | 90 | 'H' all linux/hiddev.h |
1da177e4 LT |
91 | '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 | |
cbc30118 | 95 | 'L' 20-2F driver/usb/misc/vstusb.h |
1da177e4 LT |
96 | 'L' E0-FF linux/ppdd.h encrypted disk device driver |
97 | <http://linux01.gwdg.de/~alatham/ppdd.html> | |
765d94c1 | 98 | 'M' all linux/soundcard.h |
1da177e4 | 99 | 'N' 00-1F drivers/usb/scanner.h |
8e26e1d7 | 100 | 'O' 00-02 include/mtd/ubi-user.h UBI |
1da177e4 LT |
101 | 'P' all linux/soundcard.h |
102 | 'Q' all linux/soundcard.h | |
103 | 'R' 00-1F linux/random.h | |
104 | 'S' all linux/cdrom.h conflict! | |
105 | 'S' 80-81 scsi/scsi_ioctl.h conflict! | |
106 | 'S' 82-FF scsi/scsi.h conflict! | |
107 | 'T' all linux/soundcard.h conflict! | |
07983f0e | 108 | 'T' all arch/x86/include/asm/ioctls.h conflict! |
1da177e4 | 109 | 'U' 00-EF linux/drivers/usb/usb.h |
1da177e4 LT |
110 | 'V' all linux/vt.h |
111 | 'W' 00-1F linux/watchdog.h conflict! | |
112 | 'W' 00-1F linux/wanrouter.h conflict! | |
113 | 'X' all linux/xfs_fs.h | |
114 | 'Y' all linux/cyclades.h | |
5b775f67 GKH |
115 | '[' 00-07 linux/usb/usbtmc.h USB Test and Measurement Devices |
116 | <mailto:gregkh@suse.de> | |
1da177e4 LT |
117 | 'a' all ATM on linux |
118 | <http://lrcwww.epfl.ch/linux-atm/magic.html> | |
119 | 'b' 00-FF bit3 vme host bridge | |
120 | <mailto:natalia@nikhefk.nikhef.nl> | |
121 | 'c' 00-7F linux/comstats.h conflict! | |
122 | 'c' 00-7F linux/coda.h conflict! | |
07983f0e | 123 | 'c' 80-9F arch/s390/include/asm/chsc.h |
ff55df53 | 124 | 'c' A0-AF arch/x86/include/asm/msr.h |
1da177e4 | 125 | 'd' 00-FF linux/char/drm/drm/h conflict! |
1da177e4 LT |
126 | 'd' F0-FF linux/digi1.h |
127 | 'e' all linux/digi1.h conflict! | |
1da177e4 LT |
128 | 'e' 00-1F net/irda/irtty.h conflict! |
129 | 'f' 00-1F linux/ext2_fs.h | |
130 | 'h' 00-7F Charon filesystem | |
131 | <mailto:zapman@interlan.net> | |
132 | 'i' 00-3F linux/i2o.h | |
133 | 'j' 00-3F linux/joystick.h | |
1da177e4 LT |
134 | 'l' 00-3F linux/tcfs_fs.h transparent cryptographic file system |
135 | <http://mikonos.dia.unisa.it/tcfs> | |
136 | 'l' 40-7F linux/udf_fs_i.h in development: | |
98766fbe | 137 | <http://sourceforge.net/projects/linux-udf/> |
fbd8ae10 | 138 | 'm' 00-09 linux/mmtimer.h |
1da177e4 LT |
139 | 'm' all linux/mtio.h conflict! |
140 | 'm' all linux/soundcard.h conflict! | |
141 | 'm' all linux/synclink.h conflict! | |
142 | 'm' 00-1F net/irda/irmod.h conflict! | |
143 | 'n' 00-7F linux/ncp_fs.h | |
1392e3b3 | 144 | 'n' 80-8F linux/nilfs2_fs.h NILFS2 |
1da177e4 | 145 | 'n' E0-FF video/matrox.h matroxfb |
7f68fc28 | 146 | 'o' 00-1F fs/ocfs2/ocfs2_fs.h OCFS2 |
8e26e1d7 AB |
147 | 'o' 00-03 include/mtd/ubi-user.h conflict! (OCFS2 and UBI overlaps) |
148 | 'o' 40-41 include/mtd/ubi-user.h UBI | |
149 | 'o' 01-A1 include/linux/dvb/*.h DVB | |
cef2cf07 JS |
150 | 'p' 00-0F linux/phantom.h conflict! (OpenHaptics needs this) |
151 | 'p' 00-3F linux/mc146818rtc.h conflict! | |
1da177e4 LT |
152 | 'p' 40-7F linux/nvram.h |
153 | 'p' 80-9F user-space parport | |
154 | <mailto:tim@cyberelk.net> | |
eae9d2ba RG |
155 | 'p' a1-a4 linux/pps.h LinuxPPS |
156 | <mailto:giometti@linux.it> | |
1da177e4 LT |
157 | 'q' 00-1F linux/serio.h |
158 | 'q' 80-FF Internet PhoneJACK, Internet LineJACK | |
159 | <http://www.quicknet.net> | |
160 | 'r' 00-1F linux/msdos_fs.h | |
161 | 's' all linux/cdk.h | |
162 | 't' 00-7F linux/if_ppp.h | |
163 | 't' 80-8F linux/isdn_ppp.h | |
164 | 'u' 00-1F linux/smb_fs.h | |
165 | 'v' 00-1F linux/ext2_fs.h conflict! | |
166 | 'v' all linux/videodev.h conflict! | |
167 | 'w' all CERN SCI driver | |
168 | 'y' 00-1F packet based user level communications | |
169 | <mailto:zapman@interlan.net> | |
170 | 'z' 00-3F CAN bus card | |
171 | <mailto:hdstich@connectu.ulm.circular.de> | |
172 | 'z' 40-7F CAN bus card | |
173 | <mailto:oe@port.de> | |
174 | 0x80 00-1F linux/fb.h | |
175 | 0x81 00-1F linux/videotext.h | |
07983f0e | 176 | 0x89 00-06 arch/x86/include/asm/sockios.h |
1da177e4 LT |
177 | 0x89 0B-DF linux/sockios.h |
178 | 0x89 E0-EF linux/sockios.h SIOCPROTOPRIVATE range | |
179 | 0x89 F0-FF linux/sockios.h SIOCDEVPRIVATE range | |
180 | 0x8B all linux/wireless.h | |
181 | 0x8C 00-3F WiNRADiO driver | |
182 | <http://www.proximity.com.au/~brian/winradio/> | |
183 | 0x90 00 drivers/cdrom/sbpcd.h | |
184 | 0x93 60-7F linux/auto_fs.h | |
185 | 0x99 00-0F 537-Addinboard driver | |
186 | <mailto:buk@buks.ipn.de> | |
187 | 0xA0 all linux/sdp/sdp.h Industrial Device Project | |
188 | <mailto:kenji@bitgate.com> | |
189 | 0xA3 80-8F Port ACL in development: | |
190 | <mailto:tlewis@mindspring.com> | |
191 | 0xA3 90-9F linux/dtlk.h | |
192 | 0xAB 00-1F linux/nbd.h | |
193 | 0xAC 00-1F linux/raw.h | |
194 | 0xAD 00 Netfilter device in development: | |
195 | <mailto:rusty@rustcorp.com.au> | |
258ac8e0 | 196 | 0xAE all linux/kvm.h Kernel-based Virtual Machine |
0aaeb3b1 | 197 | <mailto:kvm@vger.kernel.org> |
1da177e4 LT |
198 | 0xB0 all RATIO devices in development: |
199 | <mailto:vgo@ratio.de> | |
200 | 0xB1 00-1F PPPoX <mailto:mostrows@styx.uwaterloo.ca> | |
201 | 0xCB 00-1F CBM serial IEC bus in development: | |
202 | <mailto:michael.klein@puffin.lb.shuttle.de> | |
203 | 0xDD 00-3F ZFCP device driver see drivers/s390/scsi/ | |
204 | <mailto:aherrman@de.ibm.com> | |
205 | 0xF3 00-3F video/sisfb.h sisfb (in development) | |
206 | <mailto:thomas@winischhofer.net> | |
1ce4d390 RA |
207 | 0xF4 00-1F video/mbxfb.h mbxfb |
208 | <mailto:raph@8d.com> |