File locking I/O function handler

Prototype:

int (*lock) ( resmgr_context_t *ctp,
              io_lock_t *msg,
              RESMGR_OCB_T *ocb ) 

Classification:

I/O

Default handler:

iofunc_lock_default()

Helper functions:

iofunc_lock()

Client functions:

fcntl(), lockf(), flock()

Messages:

_IO_LOCK

Data structure:

struct _io_lock {
  uint16_t              type;
  uint16_t              combine_len;
  uint32_t              subtype;
  uint32_t              nbytes;
};

struct _io_lock_reply {
  uint32_t              zero [3];
};

typedef union {
  struct _io_lock       i;
  struct _io_lock_reply o;
} io_lock_t;

Description:

This provides advisory range-based file locking for a device. The default function is most likely sufficient for most resource managers.

Returns:

The status via the helper macro _RESMGR_STATUS().

Referenced by:

resmgr_io_funcs_t I/O table

Permission checking:

The default implementation iofunc_lock_default() calls the helper function iofunc_lock().The helper function ensures that write locks can only be set if you opened the file for writing, read locks can only be set if you opened the file for reading, and exclusive locks can only be set if you opened the file for reading or writing.