Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ fstat(2) — sys5 — Apollo Domain/OS SR10.3.5

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

chmod(2)

chown(2)

creat(2)

link(2)

mknod(2)

pipe(2)

read(2)

time(2)

unlink(2)

utime(2)

write(2)

STAT(2)                              SysV                              STAT(2)



NAME
     stat, fstat - get file status

SYNOPSIS
     #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.

     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:

     struct  stat
     {
             dev_t           st_dev;        /* device inode resides on */
             ino_t           st_ino;        /* this inode's number */
             unsigned short st_mode;        /* protection */
             short           st_nlink;      /* number or hard links to the file */
             short           st_rfu1;       /* reserved to apollo */
             uid_t           st_uid;        /* user-id of owner */
             short           st_rfu2;       /* reserved to apollo */
             gid_t           st_gid;        /* group-id of owner */
             long            st_rfu3;       /* reserved to apollo */
             dev_t           st_rdev;       /* the device type, for inode that is device */
             off_t           st_size;       /* total size of file */
             time_t          st_atime;      /* file last access time */
             int             st_spare1;
             time_t          st_mtime;      /* file last modify time */
             int             st_spare2;
             time_t          st_ctime;      /* file last status change time */
             int             st_spare3;
             long            st_blksize;    /* optimal blocksize for file system i/o ops */
             long            st_blocks;     /* actual number of blocks allocated */
             long            st_rfu4[5];    /* reserved to apollo */
             long            st_spare4[11]; /* reserved to apollo */
     };

     st_mode   The mode of the file as described in the mknod(2) 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(2)
               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(2), mknod(2), pipe(2), utime(2),
               and read(2).

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

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

ERRORS
     stat will fail if one or more of the following are 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.

     fstat will fail if one or more of the following are 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(2), chown(2), creat(2), link(2), mknod(2), pipe(2), read(2),
     time(2), unlink(2), utime(2), write(2).

DIAGNOSTICS
     A successful call returns 0.  A failed call returns -1 and sets errno as
     indicated under "Errors."

NOTES
     Under other implementations, stat and fstat fail if the following is
     true:
     [ENOLINK]     path points to a remote machine and the link to that
                   machine is no longer active.

     Under other implementations, stat fails if the following is true:

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

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