InnerhalbNach weiteren Dokumenten suchenSupport-Ressourcen | Dieses Buch im PDF-Format herunterladen (1223 KB)
stat(2)NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SEE ALSO | NOTES NAME
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); int fstatat(int fildes, const char *path, struct stat *buf, int flag); DESCRIPTIONThe stat() function obtains information about the file pointed to by path. 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. The lstat() function 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. The fstat() function obtains information about an open file known by the file descriptor fildes, obtained from a successful open(2), creat(2), dup(2), fcntl(2), or pipe(2) function. The fstatat() function obtains file attributes similar to the stat(), lstat(), and fstat() functions. If the path argument is a relative path, it is resolved relative to the fildes argument rather than the current working directory. If path is absolute, the fildes argument is unused. If the fildes argument has the special value AT_FDCWD, defined in <fcntl.h>, relative paths are resolved from the current working directory. If the flag argument is AT_SYMLNK_NOFOLLOW, defined in <fcntl.h>, the function behaves like lstat() and does not automatically follow symbolic links. See fsattr(5). The buf argument is a pointer to a stat structure into which information is placed concerning the file. A stat structure includes the following members: mode_t st_mode; /* File mode (see mknod(2)) */
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 */
/* Times measured in seconds since */
/* 00:00:00 UTC, Jan. 1, 1970 */
long st_blksize; /* Preferred I/O block size */
blkcnt_t st_blocks; /* Number of 512 byte blocks allocated*/
Descriptions of structure members are as follows:
RETURN VALUESUpon successful completion, 0 is returned. Otherwise, -1 is returned and errno is set to indicate the error. ERRORS
The stat(), fstat(), lstat(), and fstatat()functions will fail if: The stat(), lstat(), and fstatat() functions will fail if: The fstat() and fstatat() functions will fail if: USAGEThe stat(), fstat(), and lstat() functions have transitional interfaces for 64-bit file offsets. See lf64(5). ATTRIBUTESSee attributes(5) for descriptions of the following attributes:
SEE ALSOchmod(2), chown(2), creat(2), link(2), mknod(2), pipe(2), read(2), time(2), unlink(2), utime(2), write(2), fattach(3C), stat(3HEAD), attributes(5), fsattr(5), lf64(5) NOTESIf chmod(2) is used to change the file group owner permissions on a file with ACL entries, both the file group owner permissions and the ACL mask are changed to the new permissions. The new ACL mask permissions might change the effective permissions for additional users and groups who have ACL entries on the file. NAME | SYNOPSIS | DESCRIPTION | RETURN VALUES | ERRORS | USAGE | ATTRIBUTES | SEE ALSO | NOTES |
||||||