iofunc_open_default(), iofunc_open_default_cinfo()
Default handler for _IO_CONNECT messages
Synopsis:
#include <sys/iofunc.h>
int iofunc_open_default( resmgr_context_t *ctp,
io_open_t *msg,
iofunc_attr_t *attr,
void *extra );
int iofunc_open_default_cinfo( resmgr_context_t *ctp,
io_open_t *msg,
iofunc_attr_t *attr,
void *extra,
struct _client_info *cinfo );
Arguments:
- ctp
- A pointer to a resmgr_context_t structure that the resource-manager library uses to pass context information between functions.
- msg
- A pointer to the io_open_t structure that contains the message that the resource manager received. For more information, see the documentation for iofunc_open().
- attr
- A pointer to the iofunc_attr_t structure that defines the characteristics of the device that the resource manager is controlling.
- extra
- Extra information from the library. If you're calling iofunc_open_default() from a resource manager's open() function (see resmgr_connect_funcs_t), simply pass the extra argument that's passed to open().
- cinfo
- (iofunc_open_default_cinfo() only) NULL or a pointer to the client information structure for the client (refer to iofunc_client_infor_ext()). Passing NULL is the equivalent of calling iofunc_client_info_default(), which allocates and frees the client information structure.
Library:
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
Description:
The iofunc_open_default() and iofunc_open_default_cinfo() functions implement the default actions for the _IO_CONNECT message in a resource manager. These functions call:
- iofunc_open() to check the client's open mode against the resources attributes to see if the client can open the resource in that mode
- iofunc_ocb_calloc() to allocate an Open Control Block (OCB)
- iofunc_ocb_attach() to initialize the OCB. This function calls resmgr_open_bind() to bind the newly created OCB to the request.
You can place the iofunc_open_default() function directly into the connect_funcs table passed to resmgr_attach(), at the open position, or you can call iofunc_func_init() to initialize all of the functions to their default values.
If you've already allocated a client information structure, call iofunc_open_default_cinfo() and pass it the client information structure. This avoids allocating and freeing the structure, which calling iofunc_open() from iofunc_open_default() would do.
For an outline of what these functions do, refer to
Writing the entire function yourself
in the Fleshing Out the Skeleton chapter of Writing a Resource Manager.
Returns:
- EOK
- Successful completion.
- EINVAL
- The requested synchronized modes (O_SYNC, O_DSYNC, O_RSYNC) aren't supported (i.e, IOFUNC_PC_SYNC_IO isn't set in the device's mount configuration).
- ENOSPC
- There's insufficient memory to allocate the OCB.
- ENOMEM
- There's insufficient memory to allocate an internal data structure required by resmgr_open_bind().
Classification:
Safety: | |
---|---|
Cancellation point | No |
Signal handler | Yes |
Thread | Yes |