Updated: October 26, 2022

Increment count and locking flags


#include <sys/iofunc.h>

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


A pointer to a resmgr_context_t structure that the resource-manager library uses to pass context information between functions.
A pointer to the io_openfd_t structure that contains the message that the resource manager received; see below.
A pointer to the iofunc_ocb_t structure for the Open Control Block that was created when the client opened the resource.
A pointer to the iofunc_attr_t structure that describes the characteristics of the device that's associated with your resource manager.



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


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_info32          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:

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.
How the client wants to open the file; a combination of the following bits:
  • _IO_FLAG_RD — permit the file to be read.
  • _IO_FLAG_WR — permit the file to be written.
  • O_APPEND — cause each record that's written to be written at the end of the file.
  • O_TRUNC — if the file exists, truncate it to contain no data. This flag has no effect if the file doesn't exist.
How the client wants the file to be shared; a combination of the following bits:
  • SH_COMPAT — this flag is ignored in the QNX implementation.
  • SH_DENYRW — prevent read or write access to the file.
  • SH_DENYWR — prevent write access to the file.
  • SH_DENYRD — prevent read access to the file.
  • SH_DENYNO — permit both read and write access to the file.
Extended type information that can change the behavior of an I/O function. The only type that's of interest is:
  • _IO_OPENFD_NONE — no extended type information.

The following are for special purposes, and your resource manager probably doesn't need to handle them:

A pointer to a _msg_info32 structure that contains information about the message received by the resource manager.
Reserved for future use.


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


QNX Neutrino

Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes