Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ stat(S) — Xenix 2.3.4g

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(S)

chown(S)

creat(S)

link(S)

mknod(S)

time(S)

unlink(S)



     STAT(S)                  XENIX System V                   STAT(S)



     Name
          stat, fstat - Gets 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 pathname naming a file.  Read, write or
          execute permission of the named file is not required, but
          all directories listed in the pathname leading to the file
          must be searchable.  stat obtains information about the
          named file.

          Similarly, 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
               */
                                   /* 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
               */



     Page 1                                           (printed 8/7/87)





     STAT(S)                  XENIX System V                   STAT(S)



                                   /* 00:00:00 GMT, Jan. 1, 1970 */

          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), utime(S),
                    and write(S).

          st_rdev   Device indentification. In the case of block and
                    character special files this contains the device
                    major and minor numbers; in the case of shared
                    memory and semaphores, it contains the type code.
                    The file /usr/include/sys/types.h contains the
                    macros major() and minor() for extracting major
                    and minor numbers from st_rdev. See
                    /usr/include/sys/stat.h for the semaphore and
                    shared memory type code values S_INSEM and
                    S_INSHD.

          stat will fail if one or more of the following are true:

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

               The named file does not exist.  [ENOENT]

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

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

          fstat will fail if one or more of the following are true:

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

               buf points to an invalid address.  [EFAULT]

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

     See Also
          chmod(S), chown(S), creat(S), link(S), mknod(S), time(S),
          unlink(S)



     Page 2                                           (printed 8/7/87)



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