blob: 9bc0a335d8d12fef0cad3618a445b5703db6ceb7 [file] [log] [blame]
Wichert Akkermana9667852001-03-17 17:26:34 +00001#! /bin/sh
Wichert Akkermanb2c12f32001-08-03 21:53:26 +00002#
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 Akkerman76baf7c1999-02-19 00:21:36 +000030
Roland McGrath1e1b61d2003-03-31 01:03:34 +000031# Validate arg count.
32if [ $# -ne 1 ]
33then
34 echo "usage: $0 include-directory" >&2
35 exit 1
36fi
37
38dir=$1
Wichert Akkerman7b3346b2001-10-09 23:47:38 +000039
40files="asm/ioctls.h /dev/null"
41# Build the list of all ioctls
42regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x54..\>'
43(cd $dir ; grep $regexp $files 2>/dev/null ) | \
44 sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x54..\).*/ { "\1", "\2", \3 },/p' \
45 > ioctls.h
46
Roland McGratha4168e52003-01-14 07:53:36 +000047files="linux/* asm/* scsi/* sound/*"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000048
Wichert Akkermana9667852001-03-17 17:26:34 +000049# Build the list of all ioctls
Wichert Akkermanb50c9072001-08-03 21:49:34 +000050regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>'
Wichert Akkerman29f0d052001-03-31 16:14:55 +000051(cd $dir ; grep $regexp $files 2>/dev/null ) | \
Wichert Akkermanb50c9072001-08-03 21:49:34 +000052 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 Akkerman7b3346b2001-10-09 23:47:38 +000053 >> ioctls.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000054
Wichert Akkermana9667852001-03-17 17:26:34 +000055# Some use a special base to offset their ioctls on. Extract that as well.
56: > ioctldefs.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000057
Wichert Akkermanb50c9072001-08-03 21:49:34 +000058bases=$(sed -ne 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1/p' ioctls.h | uniq | sort)
Wichert Akkermana9667852001-03-17 17:26:34 +000059for base in $bases ; do
60 echo "Looking for $base"
61 regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
Wichert Akkerman29f0d052001-03-31 16:14:55 +000062 (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
63 grep -v '\<_IO' >> ioctldefs.h
Wichert Akkermana9667852001-03-17 17:26:34 +000064done