blob: b1aa02636a4091b02764556c91f2135728ed0904 [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 Akkermana9667852001-03-17 17:26:34 +000032files="linux/* asm/* scsi/*"
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000033
Wichert Akkermana9667852001-03-17 17:26:34 +000034# Build the list of all ioctls
Wichert Akkermanb50c9072001-08-03 21:49:34 +000035regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\+_S\?\(IO\|IOW\|IOR\|IOWR\)\>'
Wichert Akkerman29f0d052001-03-31 16:14:55 +000036(cd $dir ; grep $regexp $files 2>/dev/null ) | \
Wichert Akkermanb50c9072001-08-03 21:49:34 +000037 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 Akkermana9667852001-03-17 17:26:34 +000038 > ioctls.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000039
Wichert Akkermana9667852001-03-17 17:26:34 +000040# Some use a special base to offset their ioctls on. Extract that as well.
41: > ioctldefs.h
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000042
Wichert Akkermanb50c9072001-08-03 21:49:34 +000043bases=$(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 +000044for base in $bases ; do
45 echo "Looking for $base"
46 regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
Wichert Akkerman29f0d052001-03-31 16:14:55 +000047 (cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
48 grep -v '\<_IO' >> ioctldefs.h
Wichert Akkermana9667852001-03-17 17:26:34 +000049done
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000050
Wichert Akkerman76baf7c1999-02-19 00:21:36 +000051