Message10770
I'm doing some USB user-space driver programming
in Python 2.1.3 under Linux 2.4.
When using a particular ioctl (HIDIOCGNAME), the
return value as well as the (copy_to_user) binary data
is significant.
Here is the code from line 547 of hiddev.c (kernel
2.4.19-pre7):
if (_IOC_NR(cmd) == _IOC_NR(HIDIOCGNAME(0))) {
int len;
if (!hid->name) return 0;
len = strlen(hid->name) + 1;
if (len > _IOC_SIZE(cmd)) len = _IOC_SIZE(cmd);
return copy_to_user((char *) arg, hid->name, len) ?
-EFAULT : len;
}
So here is the problem: fcntl.ioctl() will only give me
one or the other value, but not both.
I can work around this by initialising the input buffer to
all chr(0), and then strip them off after. But there will
be a time when an ioctl call *requires* both values.
Until now I have appreciated the simple ioctl interface,
but now it is shown to be an oversimplification.
It may be that POSIX, or some standard somewhere
says that ioctl should not be used to do this, but
maybe Python should support it anyway.
I suggest either:
1. A new function ioctl2(fd, op, arg) that returns a
2-tuple of (return_value, binary_buffer) and does not
try to interpret the return value.
2. An optional 4th parameter whose presence (but
not value) requests the 2-tuple mentioned in (1).
Gotta love Python! |
|
Date |
User |
Action |
Args |
2007-08-23 14:01:20 | admin | link | issue555817 messages |
2007-08-23 14:01:20 | admin | create | |
|