1Ioctl Numbers 218 Feb 1998 3Michael 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 (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. 13 14'Write' and 'read' are from the user's point of view. This is like the 15system 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 17GET_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. If you are writing a driver for a new 22device and need a letter, pick an unused letter. You can register the 23letter by patching this file and submitting the patch to Linus Torvalds. 24Or you can e-mail me at <mec@shout.net> and I'll register one for you. 25 26The second argument to _IO, _IOW, _IOR, or _IOWR is a sequence number 27to distinguish ioctls from each other. The third argument is the size 28of the structure going into the kernel or coming out of the kernel. 29 30Some devices use their major number as the identifier; this is not 31recommended. Some devices are even more irregular and don't follow 32the convention at all. 33 34Following the convention is good because: 35 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. 39 40(2) The 'strace' build procedure automatically finds ioctl numbers 41 defined with _IO, _IOW, _IOR, or _IOWR. 42 43(3) 'strace' can decode numbers back into useful names when the 44 numbers are unique. 45 46(4) People looking for ioctls can grep for them more easily when 47 the convention is used to define the ioctl numbers. 48 49(5) When following the convention, the driver code can use generic 50 code to call verify_area to validate parameters. 51 52This table lists ioctls visible from user land for Linux/i386. It is 53current to Linux 2.1.15. 54 55Code Seq# Include File Comments 56======================================================== 570x00 01-02 linux/fs.h conflict! 580x00 01-04 scsi/scsi_ioctl.h conflict! 590x02 all linux/fd.h 600x03 all linux/hdreg.h 610x04 all linux/umsdos_fs.h 620x06 all linux/lp.h 630x09 all linux/md.h 640x12 all linux/fs.h 650x20 all linux/cm206.h 660x22 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> 1150x89 00-0F asm-i386/sockios.h 1160x89 10-DF linux/sockios.h 1170x89 E0-EF linux/sockios.h SIOCPROTOPRIVATE range 1180x89 F0-FF linux/sockios.h SIOCDEVPRIVATE range 1190x8B all linux/wireless.h 1200x8C 00-3F WiNRADiO driver in development: 121 <http://www.proximity.com.au/~brian/winradio/> 1220x90 00 linux/sbpcd.h 1230x93 60-7F linux/auto_fs.h 1240x99 00-0F 537-Addinboard driver in development: 125 <mailto:b.kohl@ipn-b.comlink.apc.org> 1260xA0 all Small Device Project in development: 127 <mailto:khollis@northwest.com> 1280xA3 80-8F Port ACL in development: 129 <mailto:tlewis@mindspring.com> 1300xA3 90-9F DoubleTalk driver in development: 131 <mailto:jrv@vanzandt.mv.com> 1320xAB 00-06 Network block device 133

