stat I/O function handler

Prototype:

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

Classification:

I/O

Default handler:

iofunc_stat_default()

Helper functions:

iofunc_stat(), iofunc_stat_format()

Client functions:

stat(), lstat(), fstat()

Messages:

_IO_STAT

Data 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;

Description:

Handles the message that requests information about the resource associated with the passed OCB. Note that the attributes structure contains all the information required to fulfill the stat() request; the helper function iofunc_stat_format() fills a struct stat structure based on the attributes structure. Also, the helper function modifies the stored dev/rdev members to be unique from a single node's point of view (useful for performing stat() calls to files over a network). There's almost no reason to write your own handler for this function.

Returns:

The format of the information via the helper macro _RESMGR_STATUS(), and the struct stat via message reply.

Referenced by:

resmgr_io_funcs_t I/O table

Permission checking:

The default implementation iofunc_stat_default() is expected to work on files opened without either read or write permission. The helper function iofunc_stat() does not do any permission checking. No additional permission checking is required.

If you are implementing a resource manager that deals with user input, be careful not to leak timing data through the last accessed or last modified timestamps. Similarly, do not use the size parameter to keep track of bytes sent or received over serial ports or other potentially sensitive information that should not be observable.