원래는 파일의 생성일을 알아보려고 찾았는데..
리눅스에서는 파일 생성일은 저장을 안한다고 한다.
struct stat
{
dev_t st_dev; /* ID of device containing file */
ino_t st_ino; /* inode number */
mode_t st_mode; /* protection */
nlink_t st_nlink; /* number of hard links */
uid_t st_uid; /* user ID of owner */
gid_t st_gid; /* group ID of owner */
dev_t st_rdev; /* device ID (if special file) */
off_t st_size; /* total size, in bytes */
blksize_t st_blksize; /* blocksize for filesystem I/O */
blkcnt_t st_blocks; /* number of blocks allocated */
time_t st_atime; /* time of last access */
time_t st_mtime; /* time of last modification */
time_t st_ctime; /* time of last status change */
};
위는 man fstat의 내용으로, 위에 보듯, time_t 구조체가 세개가 있는데
last access / modification / change 세가지 뿐이다.
ERRORS EACCES The requested access to the file is not allowed, or search permission is denied for one of the directories
in the path prefix of pathname, or the file did not exist yet and write access to the parent directory is
not allowed. (See also path_resolution(2).)
EEXIST pathname already exists and O_CREAT and O_EXCL were used.
EFAULT pathname points outside your accessible address space.
EISDIR pathname refers to a directory and the access requested involved writing (that is, O_WRONLY or O_RDWR is
set).
ELOOP Too many symbolic links were encountered in resolving pathname, or O_NOFOLLOW was specified but pathname was
a symbolic link.
EMFILE The process already has the maximum number of files open.
ENAMETOOLONG
pathname was too long.
ENFILE The system limit on the total number of open files has been reached.
ENODEV pathname refers to a device special file and no corresponding device exists. (This is a Linux kernel bug;
in this situation ENXIO must be returned.)
ENOENT O_CREAT is not set and the named file does not exist. Or, a directory component in pathname does not exist
or is a dangling symbolic link.
ENOMEM Insufficient kernel memory was available.
ENOSPC pathname was to be created but the device containing pathname has no room for the new file.
ENOTDIR
A component used as a directory in pathname is not, in fact, a directory, or O_DIRECTORY was specified and
pathname was not a directory.
ENXIO O_NONBLOCK | O_WRONLY is set, the named file is a FIFO and no process has the file open for reading. Or,
the file is a device special file and no corresponding device exists.
EOVERFLOW
pathname refers to a regular file, too large to be opened; see O_LARGEFILE above.
EPERM The O_NOATIME flag was specified, but the effective user ID of the caller did not match the owner of the
file and the caller was not privileged (CAP_FOWNER).
EROFS pathname refers to a file on a read-only filesystem and write access was requested.
ETXTBSY
pathname refers to an executable image which is currently being executed and write access was requested.
EWOULDBLOCK
The O_NONBLOCK flag was specified, and an incompatible lease was held on the file (see fcntl(2)).
access()
DESCRIPTION
mode is a mask consisting of one or more of R_OK, W_OK, X_OK and F_OK.
R_OK, W_OK and X_OK request checking whether the file exists and has read, write and execute permissions,
respectively. F_OK just requests checking for the existence of the file.
ERRORS
access() shall fail if:
EACCES The requested access would be denied to the file or search permission is denied for one of the directories in
the path prefix of pathname. (See also path_resolution(2).)
ELOOP Too many symbolic links were encountered in resolving pathname.
ENAMETOOLONG
pathname is too long.
ENOENT A directory component in pathname would have been accessible but does not exist or was a dangling symbolic
link.
ENOTDIR
A component used as a directory in pathname is not, in fact, a directory.
EROFS Write permission was requested for a file on a read-only filesystem.
access() may fail if:
EFAULT pathname points outside your accessible address space.
EINVAL mode was incorrectly specified.
EIO An I/O error occurred.
ENOMEM Insufficient kernel memory was available.
ETXTBSY
Write access was requested to an executable which is being executed.
fstat()
ERRORS EACCES Search permission is denied for one of the directories in the path prefix of path. (See also path_resolu-
tion(2).)
EBADF filedes is bad.
EFAULT Bad address.
ELOOP Too many symbolic links encountered while traversing the path.
ENAMETOOLONG
File name too long.
ENOENT A component of the path path does not exist, or the path is an empty string.
ENOMEM Out of memory (i.e. kernel memory).
ENOTDIR
A component of the path is not a directory.