Message10774
Logged In: YES
user_id=543663
Re Loewis:
Not sure what you mean, perhaps an example of the
problem from me would help:
In C:
char buf[256], strbuf[256];
int ret, fd;
fd = open(...)
ret = ioctl(fd, IOCTL_NUMBER, buf);
strncpy(strbuf, buf, ret);
This is impossible with the current fcntl module:
buf = "X" * struct.calcsize("256s")
buf = fcntl.ioctl(fd, IOCTL_NUMBER, buf)
# The positive ioctl() return value is lost, and
# hence I dont know how much of buf is significant
Extract from asm/unistd.h:
#define __syscall_return(type, res) \
do { \
if ((unsigned long)(res) >= (unsigned long)(-125)) { \
errno = -(res); \
res = -1; \
} \
return (type) (res); \
} while (0)
So positive values are valid, but are being lost.
Anthony's patch looks good (thanks, I have not had a
chance to test it myself yet), and the above example would
be:
buf = "X" * struct.calcsize("256s")
ret, buf = fcntl.ioctl2(fd, IOCTL_NUMBER, buf)
strbuf = buf[:ret] # Result!
Now, to test my understanding of your last comment about
array objects Loewis, do you mean:
- pass in a mutable list that gets changed in place to [ret,
buf]
- return (ret, buf) if called like this: ioctl(fd, IOC, [buf])
- or something else - please give example.
Thanks people. |
|
Date |
User |
Action |
Args |
2007-08-23 14:01:20 | admin | link | issue555817 messages |
2007-08-23 14:01:20 | admin | create | |
|