INtime SDK Help
stat

Gets information about a file.

#include <sys/types.h>
#include <sys/stat.h>

int stat (const char *filename, struct stat *buffer);

int _stat64 (const char *filename, struct stat64 *buffer);

Parameters

filename
Pathname of an open file to get information on.
buffer
Pointer to file-status structure stat. The fields of stat are described in sys/stat.h. struct stat64 describes the file size using 64 bit values.

Structures and Macros

struct stat

struct stat {
    dev_t       st_dev;         /* ID of device containing this file */
    ino_t       st_ino;         /* File serial number */
    mode_t      st_mode;        /* File mode */
    nlink_t     st_nlink;       /* Number of links */
    uid_t       st_uid;         /* User ID of the file's owner */
    gid_t       st_gid;         /* Group ID of the file's group */
    dev_t       st_rdev;        /* Same as    st_dev */
    off_t       st_size;        /* File size in bytes (regular files only) */
    time_t      st_atime;       /* Time of last access */
    time_t      st_mtime;       /* Time of last data modification */
    time_t      st_ctime;       /* Time of last file status change */
};

struct stat64

struct stat64 {
    dev_t       st_dev;         /* ID of device containing this file */
    ino_t       st_ino_lo;      /* File serial number */
    ino_t       st_ino_hi;      /* File serial number */
    mode_t      st_mode;        /* File mode */
    nlink_t     st_nlink;       /* Number of links */
    uid_t       st_uid;         /* User ID of the file's owner */
    gid_t       st_gid;         /* Group ID of the file's group */
    dev_t       st_rdev;        /* Same as    st_dev */
    unsigned long64 st_size;     /* File size in bytes (regular files only) */
    time_t      st_atime;       /* Time of last access */
    time_t      st_mtime;       /* Time of last data modification */
    time_t      st_ctime;       /* Time of last file status change */
};
/*
 * file types for st_mode field
 */
        
#define S_IFMT      0xF000      /* mask */
#define S_IFIFO     0x1000      /* fifo file */
#define S_IFCHR     0x2000      /* character device */
#define S_IFDIR     0x4000      /* directory */
#define S_IFBLK     0x6000      /* block device */
#define S_IFREG     0x8000      /* regular file */
/*
 * file types test masks
 */
#define S_ISDIR(m)    (((m) & S_IFMT ) == S_IFDIR)
#define S_ISCHR(m)    (((m) & S_IFMT ) == S_IFCHR)
#define S_ISBLK(m)    (((m) & S_IFMT ) == S_IFBLK)
#define S_ISREG(m)    (((m) & S_IFMT ) == S_IFREG)
#define S_ISFIFO(m)   (((m) & S_IFMT ) == S_IFIFO)
/*
 * file access permission levels (in octal)
 */
#define S_ISGID     0002000     /* set group ID on execution */
#define S_ISUID     0001000     /* set user ID on execution */
#define S_IREAD     0000400     /* pre-POSIX definition */
#define S_IWRITE    0000200     /* pre-POSIX definition */
#define S_IEXEC     0000100     /* pre-POSIX definition */
#define S_IARCHIVE  0100000     /* DOS specific mode */
#define S_ISUBDIR   0040000     /* DOS specific mode */
#define S_IVOLUME   0020000     /* DOS specific mode */
#define S_ISYSTEM   0010000     /* DOS specific mode */
#define S_IHIDDEN   0004000     /* DOS specific mode */
/*
 * file owner class (in octal)
 */
#define S_IRWXU     0000700     /* mask for file owner class */
#define S_IRUSR     0000400     /* read permission for file owner class */
#define S_IWUSR     0000200     /* write permission for file owner class */
#define S_IXUSR     0000100     /* execute/search permission for file owner class */
/*
 * file group class (in octal)
 */
#define S_IRWXG     0000070     /* mask for file group class */
#define S_IRGRP     0000040     /* read permission for file group class */
#define S_IWGRP     0000020     /* write permission for file group class */
#define S_IXGRP     0000010     /* execute or search permission for file group class */
/*
 * file other class (in octal)
 */
#define S_IRWXO     0000007     /* mask for file other class */
#define S_IROTH     0000004     /* read permission for file other class */
#define S_IWOTH     0000002     /* write permission for file other class */
#define S_IXOTH     0000001     /* execute or search permission for file other class */

Remarks

This function translates real-time OS file ownership rights and real-time OS access rights to POSIX as described in SYS/STAT.H.

Return Values

0 (zero); file-status information is obtained.
Success.
-1; the function sets errno to ENOENT, indicating an invalid filename.
Failure.

Requirements

Versions Defined in Include Link to
INtime 3.0 (stat)
INtime 4.0 (_stat64)
intime/rt/include/stat.h sys/types.h
sys/stat.h
clib.lib
See Also