Set file position I/O function handler

Prototype:

int (*lseek) ( resmgr_context_t *ctp,
               io_lseek_t *msg,
               RESMGR_OCB_T *ocb ) 

Classification:

I/O

Default handler:

iofunc_lseek_default()

Helper functions:

iofunc_lseek()

Client functions:

lseek(), fseek(), rewinddir()

Messages:

_IO_LSEEK

Data structure:

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;

Description:

Handles the client's lseek() function. Note that a resource manager that handles directories will also need to interpret the _IO_LSEEK message for directory operations. The whence and offset parameters are passed from the client's lseek() function. The routine should adjust the OCB's offset parameter after interpreting the whence and offset parameters from the message and should return the new offset 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.

Returns:

The status via the helper macro _RESMGR_STATUS(), and optionally (if no error and if not part of a combine message) the current offset.

Referenced by:

resmgr_io_funcs_t I/O table

Permission checking:

The default implementation iofunc_lseek_default() and helper function iofunc_iofunc_lseek() do not perform permission checking. They allow the client to adjust the current offset in the OCB even if the file was not opened for reading or writing. It is up to subsequent read and write operations on the OCB to perform all check operations related to the offset.