Discussion:
File creation time
(too old to reply)
Generic Usenet Account
2007-12-29 00:21:52 UTC
Permalink
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?
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?

Thanks,
Gus
f***@yahoo.com
2007-12-29 01:04:32 UTC
Permalink
Post by Generic Usenet Account
Hi,
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.
Post by Generic Usenet Account
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.

Continue reading on narkive:
Loading...