return value from devctl?

Hi,
Can someone please post a small code snippet that shows how to get a resource manager’s io_devctl function to return a value?
I would like to use it as follows:

...
int status = devctl( fd, cmd, data, ...);

I cannot seem to get my devctl() calls to return anything; i.e. a status value indicating success/failure of the operation as performed by the resource manager. The problem is that this statement does not return the variable to the calling application.
/*
If you wanted to pass something different to the return
field of the devctl() you could do it through this member.
*/
msg->o.ret_val = status;

My resource manager code uses the following framework:

[code]
int io_devctl(resmgr_context_t *ctp, io_devctl_t *msg, RESMGR_OCB_T *ocb) {
int nbytes, status, previous;
union {
data_t data;
int data32;
// … other devctl types you can receive
} *rx_data;

if ((status = iofunc_devctl_default(ctp, msg, ocb)) != _RESMGR_DEFAULT) {
    return(status);
}
status = nbytes = 0;

rx_data = _DEVCTL_DATA(msg->i);


switch (msg->i.dcmd) {
case MY_DEVCTL_SETVAL: 
    global_integer = rx_data->data32;
    nbytes = 0;
    break;

case MY_DEVCTL_GETVAL: 
    rx_data->data32 = global_integer;
    nbytes = sizeof(rx_data->data32);
    break;
    
case MY_DEVCTL_SETGET: 
    previous = global_integer; 
    global_integer = rx_data->data.tx;
    rx_data->data.rx = previous;        //Overwrites tx data
    nbytes = sizeof(rx_data->data.rx);
    break;

default:
    return(ENOSYS); 
}

memset(&msg->o, 0, sizeof(msg->o));

/*
 If you wanted to pass something different to the return
 field of the devctl() you could do it through this member.
*/
msg->o.ret_val = status;


msg->o.nbytes = nbytes;
return(_RESMGR_PTR(ctp, &msg->o, sizeof(msg->o) + nbytes));

}[/code]

Thanks!
EWatz

answered here: openqnx.com/PNphpBB2-viewtopic-t5054-.html