2.9BSD/usr/man/cat2/stat.2

Compare this file to the similar file:
Show the results in this format:


STAT(2)             UNIX Programmer's Manual              STAT(2)

NAME
     stat, lstat, fstat - get file status

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

     stat(name, buf)
     char *name;
     struct stat *buf;

     lstat(name, buf);
     char *name;
     struct stat *buf;

     fstat(fildes, buf)
     struct stat *buf;

DESCRIPTION
     _S_t_a_t obtains detailed information about a named file.  Read,
     write, or execute permission of the named file is not
     required, but all directories in the path name leadiing to
     the file must be searchable.

     _L_s_t_a_t is like _s_t_a_t except in the case where the named file
     is a symbolic link, in which case _l_s_t_a_t returns information
     about the link, while _s_t_a_t returns information about the
     file the link references.  _F_s_t_a_t obtains the same informa-
     tion about an open file known by the file descriptor from a
     successful _o_p_e_n, _c_r_e_a_t, _d_u_p or _p_i_p_e(2) call.

     _N_a_m_e points to a null-terminated string naming a file; _b_u_f
     is the address of a buffer into which information is placed
     concerning the file.  The layout of the structure pointed to
     by buf as defined in <_s_t_a_t._h> is given below.  _S_t__m_o_d_e is
     encoded according to the `#define' statements.

     struct    stat
     {
          dev_t     st_dev;
          ino_t     st_ino;
          u_short st_mode;
          short     st_nlink;
          short     st_uid;
          short     st_gid;
          dev_t     st_rdev;
          off_t     st_size;
          time_t    st_atime;
          time_t    st_mtime;
          time_t    st_ctime;
     };

Printed 7/30/83                                                 1

STAT(2)             UNIX Programmer's Manual              STAT(2)

     #define S_IFMT   0170000  /* type of file */
     #define          S_IFDIR  0040000/* directory */
     #define          S_IFCHR  0020000/* character special */
     #define          S_IFBLK  0060000/* block special */
     #define          S_IFREG  0100000/* regular */
     #define          S_IFMPC  0030000/* multiplexed char special */
     #define          S_IFMPB  0070000/* multiplexed block special */
     #define          S_IFQUOT 0140000 /* quota */

     #define S_ISUID  0004000  /* set user id on execution */
     #define S_ISGID  0002000  /* set group id on execution */
     #define S_ISVTX  0001000  /* save swapped text even after use */
     #define S_IREAD  0000400  /* read permission, owner */
     #define S_IWRITE 0000200  /* write permission, owner */
     #define S_IEXEC  0000100  /* execute/search permission, owner */

     The mode bits 0000070 and 0000007 encode group and others
     permissions (see _c_h_m_o_d(2)).  The defined types, _i_n_o__t,
     _o_f_f__t, _t_i_m_e__t, name various width integer values; _d_e_v__t
     encodes major and minor device numbers; their exact defini-
     tions are in the include file <sys/types.h> (see _t_y_p_e_s(5)).

     When _f_i_l_d_e_s is associated with a pipe, _f_s_t_a_t reports an
     ordinary file with restricted permissions.  The size is the
     number of bytes queued in the pipe.

     _S_t__a_t_i_m_e is the file was last read.  For reasons of effi-
     ciency, it is not set when a directory is searched, although
     this would be more logical.  _S_t__m_t_i_m_e is the time the file
     was last written or created.  It is not set by changes of
     owner, group, link count, or mode.  _S_t__c_t_i_m_e is set both
     both by writing and changing the i-node.

ERRORS
     _S_t_a_t and _l_s_t_a_t will fail if one or more of the following is
     true:

     [ENOTDIR]           A component of the path prefix is not a
                         directory.

     [EINVAL]            The path name contained a non-ASCII
                         character.

     [ENOENT]            The named file does not exist.

     [EACCES]            Search permission is denied for a com-
                         ponent of the path prefix.

     [EFAULT]            _B_u_f or _n_a_m_e points to an invalid
                         address.

     [ELOOP]             Too many symbolic links were encountered

Printed 7/30/83                                                 2

STAT(2)             UNIX Programmer's Manual              STAT(2)

                         in translating the path name.

     _F_s_t_a_t will fail if one or both of the following is true:

     [EBADF]             _F_i_l_d_e_s is not a valid open file descrip-
                         tor.

     [EFAULT]            _B_u_f points to an invalid address.

SEE ALSO
     ls(1), filsys(5)

ASSEMBLER
     (stat = 18.)
     sys stat; name; buf

     (fstat = 28.)
     (file descriptor in r0)
     sys fstat; buf

Printed 7/30/83                                                 3