[PATCH] linux/ioctlent.sh: handle multiple defines per-ioctl
Mike Frysinger
vapier at gentoo.org
Wed Mar 26 23:08:59 UTC 2008
The current sed statement works fine if the ioctl definition only utilizes
one define in it. If it uses two, things fall apart. Such is the case with
linux/dm-ioctl.h:
_IOC(_IOC_NONE,DM_IOCTL,DM_LIST_DEVICES_CMD,....)
Only the last define (DM_LIST_DEVICES_CMD) gets extracted. This tweaks the
sed to handle the two-define case.
I also fixed uniq/sort as doing `... | uniq | sort` wont work, you need to
reverse the steps for uniq to actually work.
Signed-off-by: Mike Frysinger <vapier at gentoo.org>
---
linux/ioctlent.sh | 6 +++++-
1 files changed, 5 insertions(+), 1 deletions(-)
diff --git a/linux/ioctlent.sh b/linux/ioctlent.sh
index 8f3d74b..5245d97 100644
--- a/linux/ioctlent.sh
+++ b/linux/ioctlent.sh
@@ -78,9 +78,13 @@ s/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_
>> ioctls.h
# Some use a special base to offset their ioctls on. Extract that as well.
+# Some use 2 defines: _IOC(_IOC_NONE,DM_IOCTL,DM_LIST_DEVICES_CMD,....)
: > ioctldefs.h
-bases=$(sed -ne 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1/p' ioctls.h | uniq | sort)
+bases=$(sed -n \
+ -e 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]]*,[[:space:]]*\([A-Z][A-Z0-9_]\+\)[[:space:]+,].*/\1\n\2/p' \
+ -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"
regexp="^[[:space:]]*#[[:space:]]*define[[:space:]]\+$base"
--
1.5.4.4
More information about the Strace-devel
mailing list