Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ lstat(2) — UnixWare 2.01

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

chown(2)

creat(2)

fattach(3C)

link(2)

mknod(2)

pipe(2)

read(2)

realpath(3C)

stat(5)

time(2)

unlink(2)

utime(2)

write(2)






       stat(2)                                                      stat(2)


       NAME
             stat, lstat, fstat - get file status

       SYNOPSIS
             #include <sys/types.h>
             #include <sys/stat.h>
             int stat(const char *path, struct stat *buf);
             int lstat(const char *path, struct stat *buf);
             int fstat(int fildes, struct stat *buf);

       DESCRIPTION
             The stat system calls get information about a file.  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.

             lstat obtains file attributes similar to stat, except when the
             named file is a symbolic link; in that case lstat returns
             information about the link, while stat returns information
             about the file the link references.

             fstat obtains information about an open file known by the file
             descriptor fildes, obtained from a successful creat, open,
             dup, fcntl, pipe, or ioctl 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 includes the
             following members:

                mode_t   st_mode;     /* File mode [see mknod)] */
                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 */
                                      /* char special or block special files */
                nlink_t  st_nlink;    /* Number of links */
                uid_t    st_uid;      /* User ID of the file's owner */
                gid_t    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 */


                           Copyright 1994 Novell, Inc.               Page 1













      stat(2)                                                      stat(2)


                                     /* Times measured in seconds since */
                                     /* 00:00:00 UTC, Jan. 1, 1970 */
               long     st_blksize;  /* Preferred I/O block size */
               long     st_blocks;   /* Number of 512 blocks allocated */
                                     /*A files residing on an s5*/
                                     /*file system reports number of*/
                                     /*blocks allocated assuming no*/
                                     /*holes in the file*/
               char    st_fstype[]   /* name of filesystem type */
               int     st_aclcnt     /* number of ACL entries (default is 4)*/
               level   st_level      /* level identifier (MAC) */
               ulong   st_flags      /* general purpose flag*/

            st_mode   The mode of the file as described in mknod(1M).  In
                      addition to the modes described in mknod(1M), the
                      mode of a file may also be S_IFLNK if the file is a
                      symbolic link.  (Note that S_IFLNK may only be
                      returned by lstat.)

            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 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.  Defined for block devices, although the
                      size may be zero if the device size is unknown.  See
                      also pipe(2).



                          Copyright 1994 Novell, Inc.               Page 2













       stat(2)                                                      stat(2)


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

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

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

             st_blksize
                       A hint as to the ``best'' unit size for I/O
                       operations.  This field is not defined for block-
                       special or character-special files.

             st_blocks The total number of physical blocks of size 512
                       bytes actually allocated on disk.  This field is not
                       defined for block-special or character-special
                       files.  A file residing on an s5 filesystem reports
                       number of blocks allocated assuming no holes in the
                       file.

             st_flags  _S_ISMOUNTED indicates that path is a block or
                       character special file that contains a mounted file
                       system.  This flag is reserved for use by
                       administrative commands and is not intended for
                       general application use.

             st_fstype Is the name of the filesystem type.

             aclcnt    The number of ACL entries (the default is 4).

             st_level  The level indentifier (MAC).

             st_flags  General-purpose flags.

          Return Values
             On success, stat, lstat, and fstat return 0.  On failure,
             stat, lstat, and fstat return -1 and set errno to identify the
             error.






                           Copyright 1994 Novell, Inc.               Page 3













      stat(2)                                                      stat(2)


         Errors
            In the following conditions, stat and lstat fail and set errno
            to:

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

            EACCES    Read permission is denied on the named file.

            EFAULT    buf or path points to an invalid address.

            EINTR     A signal was caught during the stat or lstat system
                      call.

            ELOOP     Too many symbolic links were encountered in
                      translating path.

            EMULTIHOP Components of path require hopping to multiple
                      remote machines and the file system does not allow
                      it.

            ENAMETOOLONG
                      The length of the path argument exceeds {PATH_MAX},
                      or the length of a path component exceeds {NAME_MAX}
                      while _POSIX_NO_TRUNC is in effect.

            ENOENT    The named file does not exist or is the null
                      pathname.

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

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

            EOVERFLOW A component is too large to store in the structure
                      pointed to by buf.

            In the following conditions, fstat fails and sets errno to:

            EBADF     fildes is not a valid open file descriptor.

            EFAULT    buf points to an invalid address.

            EINTR     A signal was caught during the fstat system call.




                          Copyright 1994 Novell, Inc.               Page 4













       stat(2)                                                      stat(2)


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

             EOVERFLOW A component is too large to store in the structure
                       pointed to by buf.

       REFERENCES
             chmod(2), chown(2), creat(2), fattach(3C), link(2), mknod(2),
             pipe(2), read(2), realpath(3C), stat(5), time(2), unlink(2),
             utime(2), write(2)






































                           Copyright 1994 Novell, Inc.               Page 5








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