Handling stat()

Your resource manager will receive an _IO_STAT message when a client calls stat(), lstat(), or fstat(). You usually don't need to provide your own handler for this message. The prototype for the io_stat handler is as follows:

int io_stat ( resmgr_context_t *ctp,
              io_stat_t *msg,
              RESMGR_OCB_T *ocb)

The default handler for the _IO_STAT message, iofunc_stat_default(), calls iofunc_time_update() to ensure that the time entries in the ocb->attr structure are current and valid, and then calls the iofunc_stat() helper function to fill in the stat structure based on the information in the ocb->attr structure.

The io_stat_t structure holds the _IO_STAT message received by the resource manager:

struct _io_stat {
    uint16_t                    type;
    uint16_t                    combine_len;
    uint32_t                    zero;
};

typedef union {
    struct _io_stat             i;
    struct stat                 o;
} io_stat_t;

As with all the I/O messages, this structure is a union of an input message (coming to the resource manager) and an output or reply message (going back to the client). The i member is a structure of type _io_stat that contains the following members:

type
_IO_STAT.
combine_len
If the message is a combine message, _IO_COMBINE_FLAG is set in this member. For more information, see the Combine Messages chapter of this guide.

The o member is a structure of type stat; for more information, see the entry for stat() in the QNX Neutrino C Library Reference.

If you write your own handler, it should return the status via the helper macro _RESMGR_STATUS() and the struct stat via message reply.

If your resource manager is for a filesystem, you might want to include the stat information in the reply for other messages. For more information, see "Returning directory entries from _IO_READ" in the Filesystem Resource Managers chapter of this guide.