[Sunhelp] EXACT!!! creation time of files

James Coby James.E.Coby.Jr at cdc.com
Tue Aug 31 11:21:42 CDT 1999


Hello Wolfgang,

   On reading your question over it appears that the value you want
the exact creation date is not available. Look at the stat man page:

You can see what is returned from a stat call. Notice there is no
creation time returned. The command sent to you will
return the last access time. To prove this do the following
run the perl -c command against a file and note the time returned.
Then do a touch or a vi of the file and rerun the perl -e again.
You will notice the value returned is the date and time of the 
last access not the creation time. If you think about it the
example given was for /etc/hosts. It is highly unlikely that
the creation date was in the last 3 days on a system which has
been running.

Below is part of thje man page giving what is returned from
the stat command. As can be seen the creation time is not kept.

 The contents of the structure pointed to by buf include  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 */

So the information about creation time is true only if the file is
created and never accessed.


Regards,

---
                              : The views expressed are those of the
                              : author and are not those of: 
Jim Coby                      : Control Data Systems Inc.
email                         : James.E.Coby.Jr at cdc.com
phone                         : 1-800-345-6628 U.S. & Canada
                              : 612-482-3434   International
WWW Support Services page     : http://www.cdc.com/support






More information about the SunHELP mailing list