[PATCH 3/3] linux/ioctlent.sh: handle enum values in ioctls
Mike Frysinger
vapier at gentoo.org
Fri Feb 20 17:56:51 UTC 2009
Some ioctl's (like the DM_* ones) are not defines, but rather enums. That
means we need need to figure out their value and extract it ourself since
they do not show up as defines in ioctldefs.h.
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
linux/ioctlent.sh | 35 ++++++++++++++++++++++++++++++++++-
1 files changed, 34 insertions(+), 1 deletions(-)
diff --git a/linux/ioctlent.sh b/linux/ioctlent.sh
index 0258967..1448e37 100644
--- a/linux/ioctlent.sh
+++ b/linux/ioctlent.sh
@@ -98,8 +98,41 @@ bases=$(sed -n \
-e 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1/p' \
ioctls.h | sort -u)
for base in $bases ; do
- echo "Looking for $base"
+ printf "Looking for $base"
regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
(cd $dir ; grep -h $regexp 2>/dev/null $files ) | \
grep -v '\<_IO' >> ioctldefs.h
+
+ if ! grep -qs "\<$base\>" ioctldefs.h ; then
+ # Not all ioctl's are defines ... some (like the DM_* stuff)
+ # use an enums, so we have to extract that crap ourself
+ (
+ cd $dir
+ ${CPP:-cpp} -E -dD -P $(grep -l $base $files 2>/dev/null) | sed '/^$/d' | \
+ awk -v base="$base" '{
+ if ($1 == "enum") {
+ val = 0
+ while ($NF != "};") {
+ if (!getline)
+ exit
+ gsub(/,/, "")
+ if ($0 ~ /=/)
+ val = $NF
+ if ($1 == base) {
+ print "#define " base " " val
+ exit
+ }
+ val++
+ }
+ }
+ }'
+ ) >> ioctldefs.h
+ if ! grep -qs "\<$base\>" ioctldefs.h ; then
+ echo ": FAIL"
+ else
+ echo " (enum!)"
+ fi
+ else
+ echo
+ fi
done
--
1.6.1.3
More information about the Strace-devel
mailing list