reading IOV in resource manager

Hi all,

i try to read IOVs message in my resource manager. The code for handling the _IO_READ message is as follows:

int io_write(resmgr_context_t *ctp, io_write_t *msg, struct ocb *ocb)
  int   i_ret;
  iov_t iovs[4];

  /* do not support xtype messages */
  if ((msg->i.xtype & _IO_XTYPE_MASK) != _IO_XTYPE_NONE)
    printf("Receive XTYPE message\n");
    return ENOSYS;

  /* Get Data(IOVs) from the client */ 
  i_ret = resmgr_msgreadv(ctp, iovs, 4, sizeof(msg->i));
  if(i_ret == -1)
    printf("Reading IOV from client error, errno=%i-%s\n", 
           errno, strerror(errno));
    return errno;
    printf("Reading IOV from client succeeds\n");

    _IO_SET_WRITE_NBYTES(ctp, i_ret);
    return (_RESMGR_NPARTS (0));

The code of the client which sends the IOV is as follows:

  iov_t              iovs[4];
  SETIOV(&iovs[0],  &data1, sizeof(data1));
  SETIOV(&iovs[1],  &data2, sizeof(data2));
  SETIOV(&iovs[2],  &data3, sizeof(data3));
  SETIOV(&iovs[3],  &data4, sizeof(data4));

  /* write to Resource Manager */
  i_ret = writev(ps_info->fd, iovs, 4);
  if(i_ret == -1)
    printf("Error %i sending DOWNLOAD request - %s\n", errno, strerror(errno));

But i always get ESRVRFAULT on the resource manager side after trying to read the data by calling the resmgr_msgreadv function.

Can anyone tell me what is the problem?


Read the documentation on resmgr_msgreadv. You actually have to setup the iovs and get them to point to valid memory blocks.


thanks for the reply, yes it works as you said. sorry it was my mistake.
the IOVs should be also assigned in the Resource Manager to valid buffers.

but i have another question: is there any means to send IOV messages to QNX Resource Manager and receive also IOV messages as reply from the resource manager? It should be some kind like a devctlv function which is not currenty available of course.

hi all,

after googling for a while i found an interesting thing. There is a source code for devctlv() function in the QNX source: … /devctlv.c

but why is it not avaialble officially in the documentartion. Has someone tested this function?

There is not such thing as IOV messages. There are just messages. IOV are just use to define what is the message being send. You can use IOV to send but a single block to receive, it`s all up to you.

There is not devctlv because POSIX doesn`t have one. Note that the resmgr can do a reply using IOV but the receiver can do a single read or devctl.

Hard to say, could be because they forgot to documented it. Maybe it hasn’t been tested, maybe its still buggy, maybe its obsolete.

Hi mario,

thanks for the answer and sorry for the false used terms, IOVS are IOVs and messages are messages :slight_smile:

i tried the devctlv function and it seems to work quite fine.

on the resource manager side, one can use the resmgr_msgreadv function to read out the request data after setting up the IOVs, and when replying dont forget to set the first IOV of ctp with themsg->o.

The code might look like this:

int io_devctl( resmgr_context_t *ctp, io_devctl_t *msg, struct ocb *ocb)
  int ret;
  iov_t iov[n];
  my_reply_t buffer[MY_SIZE];


  // read the request data
  ret = resmgr_msgreadv(ctp, iov, n, sizeof(msg->i));


  // return the reply data
  msg->o.nbytes = MY_SIZE * sizeof(my_reply_t);
  SET_IOV(ctp->iov[0], &msg->o, sizeof(msg->o));
  SET_IOV(ctp->iov[1], buffer[0], sizeof(my_reply_t));  
  SET_IOV(ctp->iov[2], buffer[1], sizeof(my_reply_t));  
  // return the reply data and the msg->o
  return _RESMGR_NPARTS(MY_SIZE + 1);

so hopefully this will be usefull for someone in the future.

According to some notes that I found about the Neutrino Library Reference, devctlv() is deprecated.