iofunc_openfd()

Increment count and locking flags

Synopsis:

#include <sys/iofunc.h>

int iofunc_openfd( resmgr_context_t *ctp,
                   io_openfd_t *msg,
                   iofunc_ocb_t *ocb,
                   iofunc_attr_t *attr );

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_openfd_t structure that contains the message that the resource manager received; see below.
ocb
A pointer to the iofunc_ocb_t structure for the Open Control Block that was created when the client opened the resource.
attr
A pointer to the iofunc_attr_t structure that describes the characteristics of the device that's associated with your resource manager.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

The iofunc_openfd() helper function examines the mode specified by the _IO_OPENFD message, and increments the read and write count flags (ocb->attr->rcount and ocb->attr->wcount), and the locking flags (ocb->attr->rlocks and ocb->attr->wlocks), as specified by the open mode.

The function does what's needed to support the openfd() function.

io_openfd_t structure

The io_openfd_t structure holds the _IO_OPENFD message received by the resource manager:

struct _io_openfd {
    uint16_t                    type;
    uint16_t                    combine_len;
    uint32_t                    ioflag;
    uint16_t                    sflag;
    uint16_t                    xtype;
    struct _msg_info            info;
    uint32_t                    reserved2;
    uint32_t                    key;
};

typedef union {
    struct _io_openfd           i;
} io_openfd_t;

The I/O message structures are unions of an input message (coming to the resource manager) and an output or reply message (going back to the client). In this case, there's only an input message, i.

The i member is a structure of type _io_openfd that contains the following members:

type
_IO_OPENFD.
combine_len
If the message is a combine message, _IO_COMBINE_FLAG is set in this member. For more information, see Combine Messages chapter of Writing a Resource Manager.
ioflag
How the client wants to open the file; a combination of the following bits:
sflag
How the client wants the file to be shared; a combination of the following bits:
xtype
Extended type information that can change the behavior of an I/O function. One of:
info
A pointer to a _msg_info structure that contains information about the message received by the resource manager.
key
Reserved for future use.

Returns:

EOK
Success.
EACCES
You don't have permission to open the file.
EBUSY
The file has shared locks that are in use.

Classification:

QNX Neutrino

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

iofunc_ocb_attach(), iofunc_openfd_default(), _msg_info, openfd()

Writing a Resource Manager

Resource Managers chapter of Getting Started with QNX Neutrino