ioctl in python

Michael P. Reilly arcege at shore.net
Thu Jul 1 11:37:34 EDT 1999


Angus MacKay <amackay at starvision.com> wrote:
: hun?

: why is this expecting a 4 byte buffer? my C version uses an int*
: and it works no problem.

: as for 80 being a input I think you have it backwards (for linux-i386 at least):
: 0x80046601  EXT2_IOC_GETFLAGS      int *
: 0x40046602  EXT2_IOC_SETFLAGS      const int *
: 0x80047601  EXT2_IOC_GETVERSION         int *
: 0x40047602  EXT2_IOC_SETVERSION         const int *

: cheers, Angus.

The four bytes is the sizeof(int *), but also (according to some linux
headers I was looking at) it is expecting a pointer to a long, not an
int.  A long is a 4 byte value (not to mention that an int is also a
long on most systems).

But, the ioctl call takes some 4 byte value, it could be cast from a
char, short, pointer or whatever; it is up to the called request to
interpret the value (int *, in this case) given.  In your original
(Python) program, you gave ioctl() a fairly short character string
(three bytes if I remember correctly), which would not be the size of a
long.

  -Arcege





More information about the Python-list mailing list