blob: 1fadff1cec84f296825fb669cbd6fc73445be6fe [file] [log] [blame]
Wichert Akkermana9667852001-03-17 17:26:34 +00001#! /bin/sh
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00002
Wichert Akkerman29f0d052001-03-31 16:14:55 +00003dir="/tmp/include"
Wichert Akkermana9667852001-03-17 17:26:34 +00004files="linux/* asm/* scsi/*"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00005
Wichert Akkermana9667852001-03-17 17:26:34 +00006# Build the list of all ioctls
7regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_\(IO\|IOW\|IOR\|IOWR\)\>'
Wichert Akkerman29f0d052001-03-31 16:14:55 +00008(cd $dir ; grep $regexp $files 2>/dev/null ) | \
Wichert Akkermana9667852001-03-17 17:26:34 +00009 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 Akkerman76baf7c1999-02-19 00:21:36 +000011
Wichert Akkermana9667852001-03-17 17:26:34 +000012# Some use a special base to offset their ioctls on. Extract that as well.
13: > ioctldefs.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000014
Wichert Akkermana9667852001-03-17 17:26:34 +000015bases=$(sed -ne 's/.*_IOC_NONE,\([A-Z][A-Z0-9_]\+\),.*/\1/p' ioctls.h | uniq | sort)
16for base in $bases ; do
17 echo "Looking for $base"
18 regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
Wichert Akkerman29f0d052001-03-31 16:14:55 +000019 (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
20 grep -v '\<_IO' >> ioctldefs.h
Wichert Akkermana9667852001-03-17 17:26:34 +000021done
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000022
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000023