[NTLUG:Discuss] original file creation date?

Kenneth Loafman kenneth at loafman.com
Tue Sep 2 12:09:47 CDT 2008


Eric Schnoebelen wrote:
> Kenneth Loafman writes:
> - Linux does have the concept of preservation of attributes.  In other
> - words, 'cp -p src tgt' will preserve the time/date stamps and file modes
> - when the file is copied, however, it will be considered 'modified' if
> - you do not add the '-p' option, or if you copy it into the system from
> - another place.
> 
> Are you absolutely, positively sure?  I bet if you triple checked,
> you'd find that ``cp -p'' only copies access time (atime) and
> modification time (mtime).  Inode creation time (ctime) is still
> updated. (there exists no system call to set the inode creation
> time.)

You're right about the 'cp -p' only copying the atime and mtime.  Seems
the ctime is the time of the copy itself, and newer than atime or mtime.

> -                 The camera download programs must be setting the
> - creation time, otherwise it would be identical to the modification time.
> -  It would be trivial for them to set the modification time as well, but
> - that would not match the normal semantics.
> 
> No, the creation time can be newer than the modification time.
> inode creation time can  never be updated.  inode/file access and
> modification times can be updated by the utime(2) system call.

If its not possible to update the ctime, then how is it possible for the
camera download programs to recreate the file with ctime equal to the
time that the picture was taken?  I have both the info from the camera
and the ls -lc of the download that agree to the second on the ctime,
and mtime matches the time the download was done.  This implies that
there has to be a mechanism to update ctime.

On another note, I think the semantics of cp have changed in the last
few years, and not to the better.  It used to be that cp as root would
automatically imply --preserve.  Now it does not.  Not a good change.

...Ken



More information about the Discuss mailing list