stat(2) SDK R4.11 stat(2)
NAME
stat - get file status
SYNOPSIS
#include <sys/types.h>
#include <sys/stat.h>
int stat (path, bufferptr)
const char * path;
struct stat * bufferptr;
where:
path Address of a pathname
bufferptr Address of a stat buffer to fill
DESCRIPTION
Stat returns the current attributes of the file named by the pathname
pointed to by path into the stat buffer at the location specified by
bufferptr. If path refers to a symbolic link, file status for the
target of the symbolic link is returned. To display the file status
of the symbolic link itself, use lstat(2).
The subject file must be of type `ordinary-disk-file', `directory',
`block-special-file', `character-special-file', or `fifo-special-
file'.
The information returned in the stat structure includes:
devt stdev The major and minor device numbers
representing the flat file store
containing the file.
inot stino The inode number of the file.
modet stmode The file mode (see below).
nlinkt stnlink The number of links to the file.
uidt stuid The user ID of the file.
gidt stgid The group ID of the file.
devt strdev The major and minor device numbers
representing a special file. It is
only applicable when the device is
either a `block-special-file' or
`character-special-file.'
offt stsize The size of the file in bytes.
timet statime The time of the last access of the
file
timet stmtime The time of the last data modification
of the file.
timet stctime The time of the last attribute change
of the file.
long stblksize The data element size of the file.
long stblocks The number of blocks allocated to the
file.
char stfstype[16] The file system type string.
When DG/UX source features are in use and SIMPLESTATTIMESFLAVOR
is not defined, the stat structure also includes the following:
unsigned long stausec The extended-precision portion of
st_atime, in microseconds.
unsigned long stmusec The extended-precision portion of
st_mtime, in microseconds.
unsigned long stcusec The extended-precision portion of
st_ctime, in microseconds.
timestruct statim The time in seconds and nanoseconds of
the last access of the file.
timestruct stmtim The time in seconds and nanoseconds of
the last modification of the file.
timestruct stctim The time in seconds and nanoseconds of
the last attribute change of the file.
If stat fails, the contents of the returned structure are undefined.
The stmode field is encoded using the following literals:
SIFMT type of file
SIFDIR directory
SIFCHR character special
SIFBLK block special
SIFREG regular
SIFLNK symbolic link
SIFIFO fifo
SIFSOCK socket special file
SISUID set user id on execution
SISGID set group id on execution
SISVTX save swapped text even after use
SIREAD read permission, owner
SIWRITE write permission, owner
SIEXEC execute/search permission, owner
SENFMT record locking enforcement flag
SIRWXU read, write, execute search permission, owner
SIRUSR read permission, owner
SIWUSR write permission, owner
SIXUSR execute/search permission, owner
SIRWXG read, write, execute/search group
SIRGRP read permission, group
SIWGRP write permission, group
SIXGRP execute/search permission, group
SIRWXO read, write, execute/search, other
SIROTH read permission, other
SIWOTH write permission, other
SIXOTH execute/search permission, other
Intel Platform
When DG/UX or SVR4 source features are in use and
SIMPLESTATTIMESFLAVOR is not defined, the st_atime, st_mtime, and
st_ctime "members" of the stat structure are actually macros. Under
these conditions, use of these three names except to access the
"members" of the stat structure will not work.
When DG/UX source features are in use and SIMPLESTATTIMESFLAVOR
is not defined, the st_ausec, st_musec, and st_cusec "members" of the
stat structure are actually macros. Under these conditions, use of
these three names except to access the "members" of the stat
structure will not work.
ACCESS CONTROL
Read, write, or execute permission of the named file is not required,
but the process must have permission to resolve path.
RETURN VALUE
0 The stat operation was successful.
-1 An error occurred. errno is set to indicate the error.
DIAGNOSTICS
Errno may be set to one of the following error codes:
EFAULT Bufferptr points to an invalid address.
ENOENT The file the pathname resolved to does not exist.
ENOENT A non-terminal component of the pathname does not
exist.
ENOTDIR A non-terminal component of the pathname was not a
directory or symbolic link.
ENAMETOOLONG The pathname exceeds the length limit for pathnames.
ENAMETOOLONG A component of the pathname exceeds the length limit
for filenames.
ENOMEM There are not enough system resources to resolve the
pathname or to expand a symbolic link.
ELOOP The number of symbolic links encountered during
pathname resolution exceeded MAXSYMLINKS. A symbolic
link cycle is suspected.
EPERM The pathname contains a character not in the allowed
character set.
EFAULT The pathname does not completely reside in the
process's address space or the pathname does not
terminate in the process's address space.
SEE ALSO
chmod(2), chown(2), creat(2), dgmstat(2), fchmod(2), fchown(2),
fstat(2), link(2), lstat(2), mknod(2), pipe(2), read(2), time(2),
unlink(2), utime(2), utimes(2), write(2).
Licensed material--property of copyright holder(s)