iofunc_openfd()

Updated: April 19, 2023

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

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:
  • _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.
sflag
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.
xtype
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:

  • _IO_OPENFD_ACCEPT
  • _IO_OPENFD_KQUEUE
  • _IO_OPENFD_PIPE
  • _IO_OPENFD_SCTP_PEELOFF
info
A pointer to a _msg_info32 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