Handling devtl() messages


I have big problems understanding how to handle devctl() messages. This is definition of devctl() messages:

"struct _io_devctl {
uint16_t type;
uint16_t combine_len;
int32_t dcmd;
int32_t nbytes;
int32_t zero;
/* char data[nbytes]; */

struct _io_devctl_reply {
uint32_t zero;
int32_t ret_val;
int32_t nbytes;
int32_t zero2;
/* char data[nbytes]; */
} ;

typedef union {
struct _io_devctl i;
struct _io_devctl_reply o;
} io_devctl_t;

Now lets take a look what programmers guide claims:
“The data to be passed follows directly after the io_devctl_t structure.”
Did I missed something? How to understand this? I can’t see any data bytes in io_devctl_t structure definition. So what are these data bytes in _io_devctl and _io_devctl_reply structure definitions? As I can see from the definition, data bytes comes after _io_devctl header for reading and data bytes after _io_devctl_reply header for writing, but I cant see any data bytes in _io_devctl_t definition. What is wrong here?


The secret lies in the commented out char data[] arrays. This is where the devctl mesasge data payload resides. There is an macro you can use to get to that data: _DEVCTL_DATA( msg->i).