Updated: October 28, 2024 |
Associate an OCB with an open request
#include <sys/iofunc.h> #include <sys/resmgr.h> int resmgr_open_bind( resmgr_context_t* ctp, void* ocb, const resmgr_io_funcs_t* iofuncs );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The resmgr_open_bind() function is the lowest-level call in the resource manager library used for handling open messages. It associates the Open Control Block (OCB) with a process identified by the id and info members of ctp.
An internal data structure is allocated that maintains the number of links to the OCB. On a file descriptor dup(), the link count is incremented and on a close() it's decremented. When the count reaches zero, the close_ocb() callout specified in io_funcs is called.
The OCB is a structure that contains at least the members as defined by the typedef iofunc_ocb_t. This typedef defines a common OCB structure that can then be used by the POSIX layer helper functions (all functions beginning with the name iofunc_*). You can extend it if you need to store additional information; see the POSIX-Layer Data Structures chapter of Writing a Resource Manager.
The attr argument to the open() callout is also typically saved in the OCB. The iofunc_ocb_t structure has a member called attr where you must store the value of the attr argument. This lets the POSIX helper functions access information about the current open session (as stored in the OCB) as well as information about the device itself (as stored in the attributes structure, ocb->attr).
For a detailed discussion, including several examples, see Writing a Resource Manager.
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | No |
Thread | Yes |