[PATCH 1/5] Add parsing support for named ioctls APIs

Gabriel Laskar gabriel at lse.epita.fr
Thu Jan 15 19:32:26 UTC 2015


Some ioctls APIs (drm, omapfb, and hsi_char) have an intermediate define
for their definitions. ioctlent.sh is now able to find them correctly.

* linux/ioctlent.sh: Add decoding support for drm, omapfb and hsi_char ioctls

Signed-off-by: Gabriel Laskar <gabriel at lse.epita.fr>
---
It should be possible to have only on set of regex for all the apis, but the
code seemed simpler like this.

 linux/ioctlent.sh | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/linux/ioctlent.sh b/linux/ioctlent.sh
index e283069..3c7d3fc 100755
--- a/linux/ioctlent.sh
+++ b/linux/ioctlent.sh
@@ -94,6 +94,21 @@ regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*[[:space:]]\
 	-e 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*_S\?I.*(\([^[,]*\)[[:space:]]*,[[:space:]]*\([^,)]*\).*/	{ "\1",	"\2",	_IOC(_IOC_NONE,\3,\4,0)	},/p' \
 	>> ioctls.h
 
+lookup_named_ioctls() {
+	api_name=$1
+
+	regexp='^[[:space:]]*#[[:space:]]*define[[:space:]]\+[A-Z][A-Z0-9_]*\(([a-z,]*)\)\?[[:space:]]\+'$api_name'_\(IOR\|IOW\|IO\|IOWR\)[[:space:]]*'
+	(cd $dir && grep $regexp $files 2>/dev/null) | \
+		sed -n \
+		-e "s,$asm/,asm/,g" \
+		-e 's/^\(.*\):[[:space:]]*#[[:space:]]*define[[:space:]]*\([A-Z0-9_]*\)[[:space:]]*'$api_name'_IO.*(\([^[,]*\)[[:space:]]*,.*/	{ "\1",	"\2",	_IOC(_IOC_NONE,DRM_IOCTL_BASE,\3,0)	},/p' \
+		>> ioctls.h
+}
+
+lookup_named_ioctls DRM
+lookup_named_ioctls OMAP
+lookup_named_ioctls HSC
+
 # Strip uapi/ prefix
 sed -i 's|"uapi/|"|' ioctls.h
 
@@ -105,10 +120,12 @@ sort -u -o ioctls.h ioctls.h
 # Collect potential ioctl names. ('bases' is a bad name. Sigh)
 # 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,....)
-bases=$(sed -n \
+bases=$((sed -n \
        -e 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Za-z0-9_]\+\)[[:space:]]*,[[:space:]]*\([A-Z][A-Za-z0-9_]\+\)[[:space:]+,].*/\1\n\2/p' \
        -e 's/.*_IOC_NONE.*,[[:space:]]*\([A-Z][A-Za-z0-9_]\+\)[[:space:]+,].*/\1/p' \
-       ioctls.h | sort -u)
+       ioctls.h ; \
+       sed -n -e 's/.*_IOC_NONE.*,[[:space:]]*[A-Z][A-Za-z0-9_]\+[[:space:]+,]\+[A-Z][A-Za-z0-9_]\+[[:space:]]*+[[:space:]]*\([A-Z][A-Za-z0-9_]*\).*/\1/p' \
+       ioctls.h) | sort -u)
 
 for base in $bases; do
 	echo "Looking for $base"
-- 
2.2.2





More information about the Strace-devel mailing list