Handling lseek()
Your resource manager will receive an _IO_LSEEK message when a client calls lseek(), fseek(), or rewinddir().
int io_lseek ( resmgr_context_t *ctp,
io_lseek_t *msg,
RESMGR_OCB_T *ocb )
The default handler, iofunc_lseek_default(), simply calls the iofunc_lseek() helper function.
struct _io_lseek {
uint16_t type;
uint16_t combine_len;
short whence;
uint16_t flags;
uint64_t offset;
};
typedef union {
struct _io_lseek i;
uint64_t o;
} io_lseek_t;
The whence and offset members of the input message are passed from the client's lseek() function. Usually, the routine should adjust the OCB's offset parameter after interpreting the whence and offset parameters. Then, it should return either the new offset in the reply message (for example, using the msg->o field) or an error.
The only currently defined flag is _IO_LSEEK_IGNORE_NON_SEEKABLE. The client sets this flag if it wants the resource manager to ignore the request if lseek operations aren't supported (for example, an aio_read() on a pipe). In this case, the resource manager shouldn't change the offset.
If the _IO_COMBINE_FLAG is set in the combine_len field, the message is part of a combine message. In this case, the handler should just return an error status on failure or EOK on success, and not return the current offset in the reply message.