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 | |
Roland McGrath | 1e1b61d | 2003-03-31 01:03:34 +0000 | [diff] [blame] | 31 | # Validate arg count. |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 32 | case $# in |
| 33 | 1) |
| 34 | dir="$1" |
| 35 | asm=asm |
| 36 | ;; |
| 37 | 2) |
| 38 | dir="$1" |
| 39 | asm="$2" |
| 40 | ;; |
| 41 | *) |
| 42 | echo "usage: $0 include-directory [asm-subdirectory]" >&2 |
Roland McGrath | 1e1b61d | 2003-03-31 01:03:34 +0000 | [diff] [blame] | 43 | exit 1 |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 44 | ;; |
| 45 | esac |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 46 | |
Roland McGrath | 718f9a6 | 2004-06-04 02:03:06 +0000 | [diff] [blame] | 47 | lookup_ioctls() |
| 48 | { |
| 49 | type="$1" |
| 50 | shift |
| 51 | |
| 52 | # Build the list of all ioctls |
| 53 | regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x'"$type"'..\>' |
| 54 | (cd "$dir" ; grep "$regexp" "$@" /dev/null 2>/dev/null ) | |
Roland McGrath | 61e0beb | 2004-07-12 06:11:16 +0000 | [diff] [blame] | 55 | sed -ne "s,$asm/,asm/,g"' |
| 56 | s/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x'"$type"'..\).*/ { "\1", "\2", \3 },/p' \ |
Roland McGrath | 718f9a6 | 2004-06-04 02:03:06 +0000 | [diff] [blame] | 57 | >> ioctls.h |
| 58 | } |
| 59 | |
| 60 | : > ioctls.h |
Roland McGrath | 7166bb0 | 2004-10-06 22:31:38 +0000 | [diff] [blame] | 61 | lookup_ioctls 22 scsi/sg.h |
Roland McGrath | 718f9a6 | 2004-06-04 02:03:06 +0000 | [diff] [blame] | 62 | lookup_ioctls 46 linux/fb.h |
| 63 | lookup_ioctls 4B linux/kd.h |
Roland McGrath | 7166bb0 | 2004-10-06 22:31:38 +0000 | [diff] [blame] | 64 | lookup_ioctls 53 linux/cdrom.h scsi/scsi.h scsi/scsi_ioctl.h |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 65 | lookup_ioctls 54 $asm/ioctls.h |
Roland McGrath | 718f9a6 | 2004-06-04 02:03:06 +0000 | [diff] [blame] | 66 | lookup_ioctls 56 linux/vt.h |
| 67 | lookup_ioctls '7[12]' linux/videotext.h |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 68 | lookup_ioctls 89 $asm/sockios.h linux/sockios.h |
Roland McGrath | 718f9a6 | 2004-06-04 02:03:06 +0000 | [diff] [blame] | 69 | lookup_ioctls 8B linux/wireless.h |
Wichert Akkerman | 7b3346b | 2001-10-09 23:47:38 +0000 | [diff] [blame] | 70 | |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 71 | files="linux/* $asm/* scsi/* sound/*" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 72 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 73 | # Build the list of all ioctls |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 74 | 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] | 75 | (cd $dir ; grep $regexp $files 2>/dev/null ) | \ |
Roland McGrath | 61e0beb | 2004-07-12 06:11:16 +0000 | [diff] [blame] | 76 | sed -ne "s,$asm/,asm/,g"' |
Roland McGrath | d265669 | 2004-07-08 19:01:28 +0000 | [diff] [blame] | 77 | 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] | 78 | >> ioctls.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 79 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 80 | # Some use a special base to offset their ioctls on. Extract that as well. |
| 81 | : > ioctldefs.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 82 | |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame] | 83 | 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] | 84 | for base in $bases ; do |
| 85 | echo "Looking for $base" |
| 86 | regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base" |
Wichert Akkerman | 29f0d05 | 2001-03-31 16:14:55 +0000 | [diff] [blame] | 87 | (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \ |
| 88 | grep -v '\<_IO' >> ioctldefs.h |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 89 | done |