[PATCH v4] Add decoding for evdev ioctls.

Dmitry V. Levin ldv at altlinux.org
Tue Feb 17 22:32:37 UTC 2015


On Tue, Feb 17, 2015 at 08:04:06PM +0100, Etienne Gemsa wrote:
> This patch introduces decoding for evdev ioctls. For EVIOCSFF the five
> first members are decoded, the union is not. The code was compiled and
> tested on x86_64 with Linux 3.13.
[...]
> +static int evdev_write_ioctl(struct tcb *tcp, const unsigned int code, long arg)
> +{
> +	if(exiting(tcp))
> +		return 1;
> +
> +	unsigned int val[2];
> +
> +	if ((_IOC_NR(code) & ~ABS_MAX) == _IOC_NR(EVIOCSABS(0)))
> +		return abs_ioctl(tcp, arg);
> +
> +	switch (code) {
> +		case EVIOCSREP:
> +			if (!verbose(tcp) || umove(tcp, arg, (char *)val) < 0)
> +				return 0;
> +
> +			tprintf(", [delay=%" PRIu32 ", period=%" PRIu32 "]",
> +					val[0], val[1]);
> +			return 1;
> +		case EVIOCSKEYCODE:
> +			return keycode_ioctl(tcp, arg);
> +		case EVIOCSKEYCODE_V2:
> +			return keycode_V2_ioctl(tcp, arg);
> +		case EVIOCSFF:
> +			return ff_effect_ioctl(tcp, arg);

If you decode on entering and always return 1 on exiting, which is the
right thing to do for _IOC_WRITE ioctls, you cannot return 0, that is,
you have to implement fallback decoding yourself.

Just test your parser with the following ioctl commands:
        ioctl(-1, EVIOCSABS(0), 1);
        ioctl(-1, EVIOCSREP, 1);
        ioctl(-1, EVIOCSKEYCODE, 1);
        ioctl(-1, EVIOCSKEYCODE_V2, 1);
        ioctl(-1, EVIOCSFF, 1);


-- 
ldv
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.strace.io/pipermail/strace-devel/attachments/20150218/0950fde9/attachment.bin>


More information about the Strace-devel mailing list