| Updated: October 28, 2024 | 
I/O attribute structure
#include <sys/iofunc.h>
typedef struct _iofunc_attr {
    IOFUNC_MOUNT_T                  *mount;
    struct _iofunc_mmap_list        *mmap_list;
    struct _iofunc_lock_list        *lock_list;
    void                            *acl;
    union {
        void                        *lockobj;
        pthread_mutex_t             lock;
    };
    uint32_t                        flags;
    uint16_t                        count;
    uint16_t                        rcount;
    uint16_t                        wcount;
    uint16_t                        rlocks;
    uint16_t                        wlocks;
    uint16_t                        reserved;
#if !defined(_IOFUNC_OFFSET_BITS) || _IOFUNC_OFFSET_BITS == 64
 #if __OFF_BITS__ == 64
    off_t                           nbytes;
    ino_t                           inode;
 #else
    off64_t                         nbytes;
    ino64_t                         inode;
 #endif
#elif _IOFUNC_OFFSET_BITS - 0 == 32
 #if __OFF_BITS__ == 32
  #if defined(__LITTLEENDIAN__)
    off_t                           nbytes;
    off_t                           nbytes_hi;
    ino_t                           inode;
    ino_t                           inode_hi;
  #elif defined(__BIGENDIAN__)
    off_t                           nbytes_hi;
    off_t                           nbytes;
    ino_t                           inode_hi;
    ino_t                           inode;
  #else
   #error endian not configured for system
  #endif
 #else
  #if defined(__LITTLEENDIAN__)
    int32_t                         nbytes;
    int32_t                         nbytes_hi;
    int32_t                         inode;
    int32_t                         inode_hi;
  #elif defined(__BIGENDIAN__)
    int32_t                         nbytes_hi;
    int32_t                         nbytes;
    int32_t                         inode_hi;
    int32_t                         inode;
  #else
   #error endian not configured for system
  #endif
 #endif
#else
 #error _IOFUNC_OFFSET_BITS value is unsupported
#endif
    uid_t                           uid;
    gid_t                           gid;
    time_t                          mtime;
    time_t                          atime;
    time_t                          ctime;
    mode_t                          mode;
    nlink_t                         nlink;
    dev_t                           rdev;
    unsigned                        mtime_ns;
    unsigned                        atime_ns;
    unsigned                        ctime_ns;
} iofunc_attr_t;
The iofunc_attr_t structure describes the data and state associated with a service offered by a resource manager. An attribute structure is often associated with a specific name (e.g., /dev/ser1, /dev/ser2), but need not be (e.g., a pipe created by a call to pipe()). You typically use iofunc_attr_init() to initialize this structure.
The members include the following:
The resource manager layer automatically locks the attribute structure (using iofunc_attr_lock()) for you when certain handler functions are called (i.e., IO_*). You can lock the attribute structure by calling iofunc_attr_lock() or iofunc_attr_trylock(); unlock it by calling iofunc_attr_unlock().
You can use these flags to determine which fields of the attribute structure have been modified by the various iofunc-layer helper routines. That way, if you need to write the entries to some medium, you can write just those that have changed. In addition to the above, your resource manager can use in any way the bits in the range defined by IOFUNC_ATTR_PRIVATE (see <sys/iofunc.h>).
| This counter: | Tracks the number of: | 
|---|---|
| count | OCBs using this attribute in any manner. When this count goes to zero, it means that no one is using this attribute. | 
| rcount | OCBs using this attribute for reading | 
| wcount | OCBs using this attribute for writing | 
| rlocks | Read locks currently registered on the attribute | 
| wlocks | Write locks currently registered on the attribute | 
These counts aren't exclusive. For example, if an OCB has specified that the resource is opened for reading and writing, then count, rcount, and wcount are all incremented. (See the iofunc_attr_init(), iofunc_lock_default(), iofunc_lock(), iofunc_ocb_attach(), and iofunc_ocb_detach() functions.)
For a file, this would contain the file's size. For special devices (e.g., /dev/null) that don't support lseek() or have a radically different interpretation for lseek(), this field isn't used (because you wouldn't use any of the helper functions, but would supply your own instead). In these cases, we recommend that you set this field to zero, unless there's a meaningful interpretation that you care to put to it.
POSIX states that these times must be valid when the fstat() is performed, but they don't have to reflect the actual time that the associated change occurred. Also, the times must be updated between fstat() invocations if the associated change occurred between fstat() invocations. If the associated change never occurred between fstat() invocations, then the time returned should be the same as returned last time. Furthermore, if the associated change occurred multiple times between fstat() invocations, then the time need only be different from the previously returned time.
To fill the members with the correct time, call iofunc_time_update().
These fields are included if you compile for a 64-bit architecture, or if you define IOFUNC_NS_TIMESTAMP_SUPPORT before including <sys/iofunc.h> when you compile for a 32-bit architecture. If these fields are included, IOFUNC_ATTR_NS_TIMESTAMPS is set in the attribute's flags.