Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 1 | #! /bin/sh |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 2 | |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame^] | 3 | dir="/usr/include" |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 4 | files="linux/* asm/* scsi/*" |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 5 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 6 | # Build the list of all ioctls |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame^] | 7 | 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] | 8 | (cd $dir ; grep $regexp $files 2>/dev/null ) | \ |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame^] | 9 | 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 | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 10 | > ioctls.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 11 | |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 12 | # Some use a special base to offset their ioctls on. Extract that as well. |
| 13 | : > ioctldefs.h |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 14 | |
Wichert Akkerman | b50c907 | 2001-08-03 21:49:34 +0000 | [diff] [blame^] | 15 | 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] | 16 | for base in $bases ; do |
| 17 | echo "Looking for $base" |
| 18 | regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base" |
Wichert Akkerman | 29f0d05 | 2001-03-31 16:14:55 +0000 | [diff] [blame] | 19 | (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \ |
| 20 | grep -v '\<_IO' >> ioctldefs.h |
Wichert Akkerman | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 21 | done |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 22 | |
Wichert Akkerman | 76baf7c | 1999-02-19 00:21:36 +0000 | [diff] [blame] | 23 | |