Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 1 | #! /bin/sh |
Wichert Akkerman | b2c12f3 | 2001-08-03 21:53:26 +0000 | [diff] [blame] | 2 | # |
| 3 | # Copyright (c) 2001 Wichert Akkerman <wichert@cistron.nl> |
| 4 | # All rights reserved. |
| 5 | # |
| 6 | # Redistribution and use in source and binary forms, with or without |
| 7 | # modification, are permitted provided that the following conditions |
| 8 | # are met: |
| 9 | # 1. Redistributions of source code must retain the above copyright |
| 10 | # notice, this list of conditions and the following disclaimer. |
| 11 | # 2. Redistributions in binary form must reproduce the above copyright |
| 12 | # notice, this list of conditions and the following disclaimer in the |
| 13 | # documentation and/or other materials provided with the distribution. |
| 14 | # 3. The name of the author may not be used to endorse or promote products |
| 15 | # derived from this software without specific prior written permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
| 18 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
| 19 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
| 20 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 21 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
| 22 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 23 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 24 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
| 26 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | # |
| 28 | # $Id$ |
| 29 | # |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 30 | |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 31 | dir="/usr/include" |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 32 | |
| 33 | files="asm/ioctls.h /dev/null" |
| 34 | # Build the list of all ioctls |
| 35 | regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x54..\>' |
| 36 | (cd $dir ; grep $regexp $files 2>/dev/null ) | \ |
| 37 | sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x54..\).*/ { "\1", "\2", \3 },/p' \ |
| 38 | > ioctls.h |
| 39 | |
Roland McGrath | a4168e5 | 2003-01-14 07:53:36 +0000 | [diff] [blame] | 40 | files="linux/* asm/* scsi/* sound/*" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 41 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 42 | # Build the list of all ioctls |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 43 | regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>' |
Wichert Akkerman | 29f0d05 | 2001-03-31 16:14:55 +0000 | [diff] [blame] | 44 | (cd $dir ; grep $regexp $files 2>/dev/null ) | \ |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 45 | sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_S\?I.*(\([^[,]*\)[[:space:]]*,[[:space:]]*\([^,)]*\).*/ { "\1", "\2", _IOC(_IOC_NONE,\3,\4,0) },/p' \ |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 46 | >> ioctls.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 47 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 48 | # Some use a special base to offset their ioctls on. Extract that as well. |
| 49 | : > ioctldefs.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 50 | |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 51 | bases=$(sed -ne 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1/p' ioctls.h | uniq | sort) |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 52 | for base in $bases ; do |
| 53 | echo "Looking for $base" |
| 54 | regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base" |
Wichert Akkerman | 29f0d05 | 2001-03-31 16:14:55 +0000 | [diff] [blame] | 55 | (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \ |
| 56 | grep -v '\<_IO' >> ioctldefs.h |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 57 | done |