Import 2.2.8pre2
[davej-history.git] / Documentation / ioctl-number.txt
blobac2af6e3fadc04f947133cf5bdd784acd9d08e6f
1 Ioctl Numbers
2 18 Feb 1998
3 Michael Chastain
4 <mec@shout.net>
6 If you are adding new ioctl's to the kernel, you should use the _IO
7 macros defined in <linux/ioctl.h>:
9     _IO    an ioctl with no parameters
10     _IOW   an ioctl with write parameters (from user's point of view)
11     _IOR   an ioctl with read parameters (from user's point of view)
12     _IOWR  an ioctl with both write and read parameters.
14 'Write' and 'read' are from the user's point of view.  This is like the
15 system calls 'write' and 'read'.  For example, a SET_FOO ioctl would be
16 _IOW, although the kernel would actually read data from user space; a
17 GET_FOO ioctl would be _IOR, although the kernel would actually write
18 data to user space.
20 The first argument to _IO, _IOW, _IOR, or _IOWR is an identifying letter
21 or number from the table below.  If you are writing a driver for a new
22 device and need a letter, pick an unused letter.  You can register the
23 letter by patching this file and submitting the patch to Linus Torvalds.
24 Or you can e-mail me at <mec@shout.net> and I'll register one for you.
26 The second argument to _IO, _IOW, _IOR, or _IOWR is a sequence number
27 to distinguish ioctls from each other.  The third argument is the size
28 of the structure going into the kernel or coming out of the kernel.
30 Some devices use their major number as the identifier; this is not
31 recommended.  Some devices are even more irregular and don't follow
32 the convention at all.
34 Following the convention is good because:
36 (1) Keeping the ioctl's globally unique helps error checking:
37     if a program calls an ioctl on the wrong device, it will get an
38     error rather than some unexpected behaviour.
40 (2) The 'strace' build procedure automatically finds ioctl numbers
41     defined with _IO, _IOW, _IOR, or _IOWR.
43 (3) 'strace' can decode numbers back into useful names when the
44     numbers are unique.
46 (4) People looking for ioctls can grep for them more easily when
47     the convention is used to define the ioctl numbers.
49 (5) When following the convention, the driver code can use generic
50     code to call verify_area to validate parameters.
52 This table lists ioctls visible from user land for Linux/i386.  It is
53 current to Linux 2.1.15.
55 Code    Seq#    Include File            Comments
56 ========================================================
57 0x00    01-02   linux/fs.h              conflict!
58 0x00    01-04   scsi/scsi_ioctl.h       conflict!
59 0x02    all     linux/fd.h
60 0x03    all     linux/hdreg.h
61 0x04    all     linux/umsdos_fs.h
62 0x06    all     linux/lp.h
63 0x09    all     linux/md.h
64 0x12    all     linux/fs.h
65 0x20    all     linux/cm206.h
66 0x22    all     scsi/sg.h
67 'A'     all     linux/apm_bios.h
68 'C'     all     linux/soundcard.h
69 'F'     all     linux/fb.h
70 'I'     all     linux/isdn.h
71 'K'     all     linux/kd.h
72 'L'     all     linux/loop.h
73 'M'     all     linux/soundcard.h
74 'P'     all     linux/soundcard.h
75 'Q'     all     linux/soundcard.h
76 'R'     all     linux/random.h
77 'S'     00-7F   linux/cdrom.h
78 'S'     80-81   scsi/scsi_ioctl.h
79 'S'     82-FF   scsi/scsi.h
80 'T'     all     linux/soundcard.h       conflict!
81 'T'     all     asm-i386/ioctls.h       conflict!
82 'V'     all     linux/vt.h
83 'W'     00-1F   linux/router.h          conflict [Please reallocate]
84 'W'     00-1F   linux/watchdog.h
85 'W'     20-27   linux/octal-relay.h     in development
86 'W'     28-2F   linux/iso16-relay.h     in development
87 'Y'     all     linux/cyclades.h
88 'a'     all     various, see http://lrcwww.epfl.ch/linux-atm/magic.html
89 'b'     00-FF   bit3 vme host bridge    in development:
90                                         <mailto:natalia@nikhefk.nikhef.nl>
91 'c'     all     linux/comstats.h
92 'f'     all     linux/ext2_fs.h
93 'j'     00-3F   linux/joystick.h
94 'k'     all     asm-sparc/kbio.h, asm-sparc64/kbio.h
95 'l'     00-3F   linux/tcfs_fs.h         in development:
96                                         <http://mikonos.dia.unisa.it/tcfs>
97 'm'     all     linux/mtio.h            conflict!
98 'm'     all     linux/soundcard.h       conflict!
99 'n'     all     linux/ncp_fs.h
100 'p'     00-3F   linux/mc146818rtc.h
101 'p'     40-7F   linux/nvram.h
102 'p'     80-9F   user-space parport      in development:
103                                         <tim@cyberelk.demon.co.uk>
104 'r'     all     linux/msdos_fs.h
105 's'     all     linux/cdk.h
106 't'     00-7F   linux/if_ppp.h
107 't'     80-8F   linux/isdn_ppp.h
108 'u'     all     linux/smb_fs.h
109 'v'     all     linux/ext2_fs.h
110 'w'     all     CERN SCI driver         in development
111 'z'     00-3F   CAN bus card            in development:
112                                         <mailto:hdstich@connectu.ulm.circular.de>
113 'z'     40-7F   CAN bas card            in development:
114                                         <mailto:oe@port.de>
115 0x89    00-0F   asm-i386/sockios.h
116 0x89    10-DF   linux/sockios.h
117 0x89    E0-EF   linux/sockios.h         SIOCPROTOPRIVATE range
118 0x89    F0-FF   linux/sockios.h         SIOCDEVPRIVATE range
119 0x8B    all     linux/wireless.h
120 0x8C    00-3F   WiNRADiO driver         in development:
121                                         <http://www.proximity.com.au/~brian/winradio/>
122 0x90    00      linux/sbpcd.h
123 0x93    60-7F   linux/auto_fs.h
124 0x99    00-0F   537-Addinboard driver   in development:
125                                         <mailto:b.kohl@ipn-b.comlink.apc.org>
126 0xA0    all     Small Device Project    in development:
127                                         <mailto:khollis@northwest.com>
128 0xA3    80-8F   Port ACL                in development:
129                                         <mailto:tlewis@mindspring.com>
130 0xA3    90-9F   DoubleTalk driver       in development:
131                                         <mailto:jrv@vanzandt.mv.com>
132 0xAB    00-06   Network block device