12-29-07 12:23 AM
On Dec 28, 4:21 pm, Generic Usenet Account <use...@sta.samsung.com>
wrote:
> Hi,
>
> As per my man pages, the stat structure contains the following fields:
> struct stat {
> dev_t st_dev; /* device */
> ino_t st_ino; /* inode */
> 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 type (if inode
> device) */
> 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 change */
> };
>
> I am interested in the file creation time. What field should I use?
None of these tell you the file creation time. That information is
only kept for a few filesystems. For example, ufs2 on FreeBSD fills
in an st_birthtime field. But in general it's not available via
stat(2) or any other system call.
> Should I go with some other system call? Also, what is the difference
> between the time of last modification and the time of last change?
The FreeBSD man page describes them as follows:
st_atime Time when file data last accessed. Changed by the
mknod(2), utimes(2), read(2) and readv(2) system
calls.
st_mtime Time when file data last modified. Changed by the
mkdir(2), mkfifo(2), mknod(2), utimes(2), write(2)
and
writev(2) system calls.
st_ctime Time when file status was last changed (inode data
modifi-
cation). Changed by the chflags(2), chmod(2),
chown(2),
creat(2), link(2), mkdir(2), mkfifo(2), mknod(2),
rename(2), rmdir(2), symlink(2), truncate(2),
unlink(2),
utimes(2), write(2) and writev(2) system calls.
st_birthtime Time when the inode was created.
Hope this helps.
[ Post a follow-up to this message ]
|