Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ stat(S) — System V/386 Software Development System 3.2.2b

Media Vault

Software Library

Restoration Projects

Artifacts Sought



     STAT(S)                   UNIX System V                   STAT(S)



     Name
          stat, fstat - get file status

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

          int stat (path, buf)
          char *path;
          struct stat *buf;

          int fstat (fildes, buf)
          int fildes;
          struct stat *buf;

     Description
          path points to a path name naming a file.  Read, write, or
          execute permission of the named file is not required, but
          all directories listed in the path name leading to the file
          must be searchable.  The stat system call obtains
          information about the named file.

          Note that in a Remote File Sharing environment, the
          information returned by stat depends upon the user/group
          mapping set-up between the local and remote computers (see
          idload(ADM)).

          fstat obtains information about an open file known by the
          file descriptor fildes, obtained from a successful open,
          creat, dup, fcntl, or pipe system call.

          buf is a pointer to a stat structure into which information
          is placed concerning the file.

          The contents of the structure pointed to by buf include the
          following members:

               ushort  st_mode;    /* File mode [see mknod(S)] */
               ino_t   st_ino;     /* Inode number */
               dev_t   st_dev;     /* ID of device containing */
                                   /* a directory entry for this file */
               dev_t   st_rdev;    /* ID of device */
                                   /* This entry is defined only for */
                                   /* character special or */
                                   /* block special files */
               short   st_nlink;   /* Number of links */
               ushort  st_uid;     /* User ID of the file's owner */
               ushort  st_gid;     /* Group ID of the file's group */
               off_t   st_size;    /* File size in bytes */
               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 */
                                   /* Times measured in seconds since */
                                   /* 00:00:00 GMT, Jan. 1, 1970 */

          st_mode   The mode of the file as described in the mknod(S)
                    system call.

          st_ino    This field uniquely identifies the file in a given
                    file system.  The pair st_ino and st_dev uniquely
                    identifies regular files.

          st_dev    This field uniquely identifies the file system
                    that contains the file.  Its value may be used as
                    input to the ustat(S) system call to determine
                    more information about this file system.  No other
                    meaning is associated with this value.

          st_rdev   This field should be used only by administrative
                    commands.  It is valid only for block special or
                    character special files and only has meaning on
                    the system where the file was configured.

          st_nlink  This field should be used only by administrative
                    commands.

          st_uid    The user ID of the file's owner.

          st_gid    The group ID of the file's group.

          st_size   For regular files, this is the address of the end
                    of the file.  For pipes or fifos, this is the
                    count of the data currently in the file.  For
                    block special or character special, this is not
                    defined.

          st_atime  Time when file data was last accessed.  Changed by
                    the following system calls: creat(S), mknod(S),
                    pipe(S), utime(S), and read(S).

          st_mtime  Time when data was last modified.  Changed by the
                    following system calls: creat(S), mknod(S),
                    pipe(S), utime(S), and write(S).

          st_ctime  Time when file status was last changed.  Changed
                    by the following system calls: chmod(S), chown(S),
                    creat(S), link(S), mknod(S), pipe(S), unlink(S),
                    utime(S), and write(S).

          The stat system call will fail if one or more of the
          following is true:

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

          [ENOENT]       The named file does not exist.

          [EACCES]       Search permission is denied for a component
                         of the path prefix.

          [EFAULT]       buf or path points to an invalid address.

          [EINTR]        A signal was caught during the stat system
                         call.

          [ENOLINK]      path points to a remote machine and the link
                         to that machine is no longer active.

          [EMULTIHOP]    Components of path require hopping to
                         multiple remote machines.

          Fstat will fail if one or more of the following is true:

          [EBADF]        fildes is not a valid open file descriptor.

          [EFAULT]       buf points to an invalid address.

          [ENOLINK]      fildes points to a remote machine and the
                         link to that machine is no longer active.

     See Also
          chmod(S), chown(S), creat(S), link(S), mknod(S), pipe(S),
          read(S), time(S), unlink(S), utime(S), write(S)

     Diagnostics
          Upon successful completion a value of 0 is returned.
          Otherwise, a value of -1 is returned, and errno is set to
          indicate the error.

     Standards Conformance
          fstat and stat are conformant with:
          AT&T SVID Issue 2, Select Code 307-127;
          The X/Open Portability Guide II of January 1987;
          IEEE POSIX Std 1003.1-1988 with C Standard Language-
          Dependent System Support;
          and NIST FIPS 151-1.








                                             (printed 6/20/89)



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