Open Control Block structure
#include <sys/iofunc.h> typedef struct _iofunc_ocb { IOFUNC_ATTR_T *attr; int32_t ioflag; #if !defined(_IOFUNC_OFFSET_BITS) || _IOFUNC_OFFSET_BITS == 64 #if _FILE_OFFSET_BITS - 0 == 64 off_t offset; #else off64_t offset; #endif #elif _IOFUNC_OFFSET_BITS - 0 == 32 #if !defined(_FILE_OFFSET_BITS) || _FILE_OFFSET_BITS == 32 #if defined(__LITTLEENDIAN__) off_t offset; off_t offset_hi; #elif defined(__BIGENDIAN__) off_t offset_hi; off_t offset; #else #error endian not configured for system #endif #else #if defined(__LITTLEENDIAN__) int32_t offset; int32_t offset_hi; #elif defined(__BIGENDIAN__) int32_t offset_hi; int32_t offset; #else #error endian not configured for system #endif #endif #else #error _IOFUNC_OFFSET_BITS value is unsupported #endif uint16_t sflag; uint16_t flags; void *reserved; } iofunc_ocb_t;
The iofunc_ocb_t structure is an Open Control Block, a block of data that's established by a resource manager during its handling of the client's open() function.
A resource manager creates an instance of this structure whenever a client opens a resource. For example, iofunc_open_default() calls iofunc_ocb_calloc() to allocate an OCB. The OCB exists until the client closes the file descriptor associated with the open operation. The resource manager passes this structure to all of the functions that implement the I/O operations for the file descriptor.
The iofunc_ocb_t structure includes the following members:
Open mode | ioflag value |
---|---|
O_RDONLY | _IO_FLAG_RD |
O_RDWR | _IO_FLAG_RD | _IO_FLAG_WR |
O_WRONLY | _IO_FLAG_WR |
This information is inherited from the io_connect_t structure that's available in the message passed to the open handler.
Additionally, you can use flags in the range defined by IOFUNC_OCB_FLAGS_PRIVATE (see <sys/iofunc.h>) for your own purposes. Your resource manager can modify these flags.