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 | 29f0d05 | 2001-03-31 16:14:55 +0000 | [diff] [blame] | 3 | dir="/tmp/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 |
| 7 | regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_\(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 | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 9 | sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_I.*(\([^[,]*\),\([^,)]*\).*/ { "\1", "\2", _IOC(_IOC_NONE,\3,\4,0) },/p' \ |
| 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 | a966785 | 2001-03-17 17:26:34 +0000 | [diff] [blame] | 15 | bases=$(sed -ne 's/.*_IOC_NONE,\([A-Z][A-Z0-9_]\+\),.*/\1/p' ioctls.h | uniq | sort) |
| 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 | |