Resize file I/O function handler

Prototype:

int (*space) ( resmgr_context_t *ctp,
              io_space_t *msg,
              RESMGR_OCB_T *ocb ) 

Classification:

I/O

Default handler:

none

Helper functions:

iofunc_space_verify()

Client functions:

fcntl(), ftruncate(), ltrunc(), posix_fallocate()

Messages:

_IO_SPACE

Data structure:

struct _io_space {
  uint16_t         type;
  uint16_t         combine_len;
  uint16_t         subtype;
  short            whence;
  uint64_t         start;
  uint64_t         len;
};

typedef union {
  struct _io_space i;
  uint64_t         o;
} io_space_t;

Description:

This is used to allocate or free space occupied by the resource. The subtype parameter indicates the type of operation:

F_ALLOCSP
Allocate storage space, fully assigning any physical space (rather than potentially failing later when it's written to). This corresponds to posix_fallocate().
F_FREESP
Free storage space.
F_GROWSP
(QNX Neutrino 7.1 or later) Extend a resource, without necessarily guaranteeing that physical space is available. F_GROWSP is similar to F_ALLOCSP but permits lazy allocation by a sparse file implementation. This corresponds to ftruncate().

Most resource managers can (and should) treat F_ALLOCSP and F_GROWSP identically.

The combination of whence and start give the location where the beginning of the allocation or deallocation should occur; the member len indicates the size of the operation.

Returns:

The number of bytes (size of the resource) via the helper macro _RESMGR_STATUS().

Referenced by:

resmgr_io_funcs_t I/O table

Permission checking:

The iofunc_space_verify() helper function verifies that the file is opened with write permissions and that the filesystem is not read only. If the file is executable and has the set user ID bit set, iofunc_space_verify() only allows the operation if the caller is root. There is no default handler.