NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUE | ATTRIBUTES | SEE ALSO
#include <sys/types.h> #include <sys/stat.h>int stat(const char * path, struct stat * buf);
The function or functions documented here may not be used safely in all application contexts with all APIs provided in the ChorusOS 5.0 product.
See API(5FEA) for details.
MSDOSFS, NFS_CLIENT, UFS
The path parameter points to the pathname of 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. The lstat function is similar to stat except when the named file is a symbolic link, in which case lstat returns information about the link, while stat returns information about the file's link references. Unlike other filesystem objects, symbolic links do not have an owner, group, access mode, or times. Instead, these attributes are taken from the directory that contains the link. The only attributes returned from an lstat that refer to the symbolic link itself are the file type (S_IFLNK), size, blocks, and link count (always 1).
Similarly, fstat obtains information about an open file referenced by the file descriptor fildes , obtained from a successful open (2POSIX), or dup (2POSIX) system call.
The buf pointer indicates a stat structure into which information concerning the file is placed.
The contents of the structure pointed to by buf include the following members:
mode_t st_mode; /* File mode */ ino_t st_ino; /* Inode number */ dev_t st_dev; /* ID of device containing (special file only) */ /* a directory entry for this file */ dev_t st_rdev; /* ID of device (special files only) */ 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 */ size_t st_size; /* File size in bytes */ timestruct_t st_atime; /* Time of last access */ timestruct_t st_mtime; /* Time of last data modification */ timestruct_t st_ctime; /* Time of last file status change */ /* Time is measured since 00:00:00 GMT, Jan. 1, 1970 */ |
Upon successful completion, stat , lstat and fstat return 0; otherwise they return -1 and set errno to indicate one of the following error conditions:
A component of the path prefix is not a directory.
The named file does not exist.
Search permission is denied for a component of the path prefix.
buf or path points to an invalid address.
The length of a component of name exceeds NAME_MAX characters, or the length of name exceeds PATH_MAX characters.
Too many symbolic links or symbolic ports were encountered during analysis of name .
An I/O error occurred while making the directory entry or allocating the inode.
fildes is not a valid open file descriptor.
See attributes(5) for descriptions of the following attributes:
ATTRIBUTE TYPE | ATTRIBUTE VALUE |
---|---|
Interface Stability | Evolving |
MT-Level | Async-Signal-Safe |
NAME | SYNOPSIS | API RESTRICTIONS | FEATURES | DESCRIPTION | RETURN VALUE | ATTRIBUTES | SEE ALSO