Re: ctimes vs mtime



In article <ekcnfb$f85$1@xxxxxxxxxxxxxx>,
Leslie Ballentine <ballenti@xxxxxx> wrote:
:John-Paul Stewart <jpstewart@xxxxxxxxxxxxxxxx> wrote:
:: Leslie Ballentine wrote:
::> First let me say that I have read the book, and I know the difference
::> between ctime and mtime.
::>
::> My problem -- Whenever I do something that should (and does) change mtime,
::> ctime also changes.
:
:...
:
:: Why would you expect ctime not to change when writing to the file?
:
:Why would I expect that? Because all the Unix books that I have read
:say that mtime changes when the contents of the file is changed, and
:ctime changes when the inode information is changed.
:It was implied, if not stated explicitly, that a simple 'write' would
:not change the inode information.
:But according to 'man 2 stat', which you quote, that was not correct.
:
:According to your information, there is no operation that changes mtime
:but leaves ctime unchanged (the converse being, obviously, false).

The only thing in the inode that can change without triggering a ctime
update is the automatic atime update caused by a read access. Any other
change to the inode, even an atime change if done by utime(2), causes
ctime to be updated.

If you want to set an mtime that is farther in the future than ctime you
can use 'touch' with an explicit future timestamp to set mtime. Then
ctime will show the actual time when you made the change. Perhaps you
can use that method for the testing you are trying to do.

--
Bob Nichols AT comcast.net I am "RNichols42"
.



Relevant Pages