blob: a41aaa293adc8273c60df049567561238184fce3 [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
Wichert Akkermanb50c9072001-08-03 21:49:34 +000031dir="/usr/include"
Wichert Akkerman7b3346b2001-10-09 23:47:38 +000032
33files="asm/ioctls.h /dev/null"
34# Build the list of all ioctls
35regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+0x54..\>'
36(cd $dir ; grep $regexp $files 2>/dev/null ) | \
37 sed -ne 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*\(0x54..\).*/ { "\1", "\2", \3 },/p' \
38 > ioctls.h
39
Roland McGratha4168e52003-01-14 07:53:36 +000040files="linux/* asm/* scsi/* sound/*"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000041
Wichert Akkermana9667852001-03-17 17:26:34 +000042# Build the list of all ioctls
Wichert Akkermanb50c9072001-08-03 21:49:34 +000043regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>'
Wichert Akkerman29f0d052001-03-31 16:14:55 +000044(cd $dir ; grep $regexp $files 2>/dev/null ) | \
Wichert Akkermanb50c9072001-08-03 21:49:34 +000045 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 +000046 >> ioctls.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000047
Wichert Akkermana9667852001-03-17 17:26:34 +000048# Some use a special base to offset their ioctls on. Extract that as well.
49: > ioctldefs.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050
Wichert Akkermanb50c9072001-08-03 21:49:34 +000051bases=$(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 +000052for base in $bases ; do
53 echo "Looking for $base"
54 regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
Wichert Akkerman29f0d052001-03-31 16:14:55 +000055 (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
56 grep -v '\<_IO' >> ioctldefs.h
Wichert Akkermana9667852001-03-17 17:26:34 +000057done