[Tutor] Passing nested structures to fcntl.ioctl

Noufal Ibrahim noufal at nibrahim.net.in
Mon Mar 8 07:27:35 CET 2010


Hello everyone,
    I have some code that's calling fcntl.ioctl. I need to pass a nested
structure as the 3rd argument of the function. Something like this

typedef struct coordinates{
  int x;
  int y;
} coordinates;

typedef struct point{
  int amp;
  coordinates* coord;
} point;

   How would I do this? I need to allocate a point structure and then a
coordinate structure and link them up together via the coord member of
point, fill them up with values and pass it to the fcntl.ioctl. The
actual IOCTL implementation will do the indirection to read out the
data.

   I can't use ctypes since I'm working on an embedded system with an ARM
core that doesn't have ctypes. The struct module doesn't seem to help
due to the indirection.

   Any ideas? I'm personally planning to write a small C extension that
creates the structure based on a specification in memory and then
passes that to the IOCTL call directly but that looks like some work. I
was also told to take a look at Cython which basically seems to be an
easy way of doing what I'm planning. Is there a quicker/easier way?

Thanks.



More information about the Tutor mailing list