Museum

Home

Lab Overview

Retrotechnology Articles

Online Manuals

⇒ stat(2) — HP-UX 5.20

Media Vault

Software Library

Restoration Projects

Artifacts Sought

Related Articles

touch(1)

chmod(2)

chown(2)

creat(2)

link(2)

mknod(2)

pipe(2)

read(2)

time(2)

truncate(2)

unlink(2)

utime(2)

write(2)

stat(5)

STAT(2)  —  HP-UX

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 path name naming a file.  Read, write, or execute permission of the named file is not required, but all directories listed in the path name 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:

dev_tst_dev;/* ID of device containing a */
/* directory entry for this file */
ino_tst_ino;/* Inode number */
ushortst_mode;/* File mode; see mknod(2) */
shortst_nlink;/* Number of links */
ushortst_uid;/* User ID of file owner */
ushortst_gid;/* Group ID of file group */
dev_tst_rdev;/* Device ID; this entry defined */
/* only for char or blk spec files */
off_tst_size;/* File size (bytes) */
time_tst_atime;/* Time of last access */
time_tst_mtime;/* Last modification time */
time_tst_ctime;/* Last file status change time */
/* Measured in secs since */
/* 00:00:00 GMT, Jan 1, 1970 */
uintst_remote:1; /* Set if file is remote */
dev_tst_netdev;/* ID of device containing */
/* network special file */
ino_tst_netino;/* Inode number of network special file */

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

st_mtime
Time when data was last modified. Changed by the following system calls: creat(2), truncate(2), ftruncate (on truncate(2)), mknod(2), pipe(2), prealloc(2), utime(2), write(2), and writev (on write(2)). Changed also by close(2) when the file is a named pipe (FIFO special) and the reference counts are zero.

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

st_remote
A zero value indicates that the file is on the local node; non-zero indicates that the file is on a remote node, and accessed through remote file access (RFA). Not all HP-UX systems support RFA; st_remote is always zero on those systems which do not. 

st_netdev, st_netino
All remote file access takes place through a special file in the local file system known as a network special file.  Each network special file identifies a particular remote node. When st_remote is non-zero, st_netdev and st_netino identify the appropriate network special file; otherwise these fields are zero. 

The touch(1) command can be used to explicitly control the times of a file.

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. 

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 (for example, path is null or a component of path does not exist). 

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

­[EFAULT] Buf or path points to an invalid address.  The reliable detection of this error will be implementation dependent. 

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.  The reliable detection of this error will be implementation dependent. 

HARDWARE DEPENDENCIES

Series 500
Besides the definition given above, st_size also has meaning in the case of special files which refer to disks.  In such a case, st_size either returns the total physical size (in bytes) of the mass storage volume, when appropriate, or −1 otherwise.  This is a property of the physical device, not any directory structure imposed upon it. 

The fields st_netdev and st_netino are not supported. 

SEE ALSO

touch(1), chmod(2), chown(2), creat(2), link(2), mknod(2), pipe(2), read(2), time(2), truncate(2), unlink(2), utime(2), write(2), stat(5). 

Hewlett-Packard Company  —  Version B.1,  April 12, 1993

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