Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ stat.h(7) — AIX/RT 2.2.1

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

stat, fstat

types.h

stat.h

Purpose

     Defines the  data structure  returned by the  stat system
     call.

Synopsis

     #include <sys/stat.h>

Description

     The stat and fstat  system calls obtain information about
     a file that has a name.  These system calls return a data
     structure defined  by this include file.   This file also
     defines encoding of the st_mode  field.  Note that in the
     structure   below  the   octal  value   is  shown.    The
     hexadecimal equivalent  values are  also shown  in paren-
     theses.

          struct  stat
          {
              dev_t   st_dev;      /* ID of device containing */
                                   /* a directory entry for this file */
                                   /* File serial + device uniquely */
                                   /* identifies the file within the system */
              ino_t   st_ino;      /* File serial number */
              ushort  st_mode;     /* File mode; see #defines below */
              short   st_nlink;    /* Number of links to file */
              ushort  st_uid;      /* User ID of the owner of the file */
              ushort  st_gid;      /* Group ID of the file group */
              dev_t   st_rdev;     /* ID of this device */
                                   /* This entry is defined only for */
                                   /* character or block special files */
              off_t   st_size;     /* File size in bytes */
              time_t  st_atime;    /* Time of the last access */
              time_t  st_mtime;    /* Time of the last data modification */
              time_t  st_ctime;    /* Time measured in seconds since */
                                   /* 00:00:00 GMT, Jan. 1, 1970 */
          };

       #define S_IFMT   0170000          /* (0xF000) type of file */
       #define S_IFDIR  0040000          /* (0x4000) directory */
       #define S_ISDIR(m)  (((m) & (S_IFMT)) == (S_IFDIR))
       #define S_IFCHR  0020000          /* (0x2000) character special */
       #define S_ISCHR(m)  (((m) & (S_IFMT)) == (S_IFCHR))
       #define S_IFBLK  0060000          /* (0x6000) block special  */
       #define S_ISBLK(m)  (((m) & (S_IFMT)) == (S_IFBLK))
       #define S_IFREG  0100000          /* (0x8000) regular */
       #define S_ISREG(m)  (((m) & (S_IFMT)) == (S_IFREG))
       #define S_IFIFO  0010000          /* (0x1000) fifo */
       #define S_ISFIFO(m)  (((m) & (S_IFMT)) == (S_IFIFO))
       #define S_ISUID  04000  /* (0x0800) set user id on execution */
       #define S_ISGID  02000  /* (0x0400) set group id on execution */
       #define S_ISVTX  01000  /* (0x0200) save swapped text even after use */
       #define S_IRWXU  00700  /* (0x01C0) owner read,write,execute permission */
       #define S_IREAD  00400  /* (0x0100) owner read permission */
       #define S_IRUSR  00400  /* (0x0100) read permission, owner */
       #define S_IWRITE 00200  /* (0x0080) owner write permission */
       #define S_IWUSR  00200  /* (0x0080) owner write permission */
       #define S_IEXEC  00100  /* (0x0040) owner execute/search permission */
       #define S_IXUSR  00100  /* (0x0040) owner execute/search permission */
       #define S_IRWXG  00070  /* (0x0038) group read,write,execut  e permission */
       #define S_IRGRP  00040  /* (0x0020) group read permission */
       #define S_IWGRP  00020  /* (0x0010) group write permission   */
       #define S_IXGRP  00010  /* (0x0008) group execute/search permission */
       #define S_IRWXO  00007  /* (0x0007) other read,write,execute, permission */
       #define S_IROTH  00004  /* (0x0004) other read permission */
       #define S_IWOTH  00002  /* (0x0002) other write permission */
       #define S_IXOTH  00001  /* (0x0001) other execute/search permission */
       #define S_IFMPX S_IFCHR|S_ISVTX /* multiplex character special file */
       #define S_ISMPX(m) (((m) & (S_IFMT|S_ISVTX)) ==   (S_IFMPX))
       #define S_ENFMT S_ISGID   /* record locking enforcement flag */

Examples

     The S_IREAD, S_IWRITE,  and S_IEXEC masks can  be used to
     test  permissions  in any  of  the  three groups  (owner,
     groups, or other) by shifting them.  For example, to test
     for read access by group, use:

           st_mode & (S_IREAD >> 3)

     To test for global write access, use:

           st_mode & (S_IWRITE >> 6)

File

     /usr/include/sys/stat.h

Related Information

     In this book:  "stat, fstat" and "types.h."

Typewritten Software • bear@typewritten.org • Edmonds, WA 98026