Handling stat()
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_format() helper function to fill in the stat structure based on the information in the ocb->attr structure.
struct _io_stat {
uint16_t type;
uint16_t combine_len;
union {
uint32_t zero;
uint32_t format;
};
};
typedef union {
struct _io_stat i;
struct __stat_t32_2001 o_t32_2001;
struct __stat_t32_2008 o_t32_2008;
struct __stat_t64_2008 o_t64_2008;
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.
- format
- The form of the information; one of the following:
- _STAT_FORM_UNSET — unknown; this is assumed to be the same as _STAT_FORM_T32_2001
- _STAT_FORM_T32_2001 — 32-bit fields, POSIX 2001
- _STAT_FORM_T32_2008 — 32-bit fields, POSIX 2008
- _STAT_FORM_T64_2008 — 64-bit fields, POSIX 2008
- _STAT_FORM_SYS_2008 — _STAT_FORM_T32_2008 in programs compiled for a 32-bit architecture, or _STAT_FORM_T64_2008 in programs compiled for a 64-bit architecture.
- _STAT_FORM_PREFERRED — the preferred form: _STAT_FORM_T32_2001 in programs compiled for a 32-bit architecture, or _STAT_FORM_T64_2008 in programs compiled for a 64-bit architecture.
Note:The _STAT_FORM_UNSET, _STAT_FORM_T32_2001, and _STAT_FORM_T32_2008 values are legacy values for 32-bit targets and shouldn't be used in this release. Also, _STAT_FORM_SYS_2008 and _STAT_FORM_PREFERRED are always the same as _STAT_FORM_T64_2008 because only 64-bit targets are supported.
The o* members are variants of a struct stat, corresponding to the requested form; for more information, see the entry for struct stat in the QNX OS 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.