man(1) Manual page archive


     STAT(2)                                                   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
          Stat obtains detailed information about a named file.  Lstat
          obtains the same information, but in the case of a symbolic
          link (see link(2)), supplies information about the link
          itself.  Fstat obtains the same information about an open
          file known by a file descriptor.

          Name points to a null-terminated string naming a file; buf
          is the address of a buffer into which information is placed
          concerning the file.  It is unnecessary to have any permis-
          sions at all with respect to the file, but all directories
          leading to the file must be searchable.  The layout of the
          structure pointed to by buf is given below; st_mode is
          encoded according to the `#define' statements.