[Aide] I (ignore changed filename) woes

Bob Proulx bob at proulx.com
Sun Oct 30 23:13:15 EET 2005


Richard van den Berg wrote:
> At the time I was working on this bug, I assumed ctime meant "creation
> time", but now I realize that it is defined as "time of last status
> change". No wonder 'I' and 'c' are incompatible, because if the filename
> changed, the ctime is updated. Duh.

Uhm, that does not make sense to me.  But the easiest way to describe
what does not make sense to me is to enumerate things out by
description.  Please bear with me here.  There are three times
available on unixlike filesystems and they atime, mtime, and ctime.

The atime is the time anything last accessed the file.  That is not so
useful because as soon as you look at it you change it.  So those
always tend to be up to date.  Such as doing a backup.  (However, once
backed up the atime would not change again because you would be backed
up and the backup would not need to do it again.)

The ctime is the time the inode was last changed.  This means a chmod,
chown or chgrp operation.  This is interesting here.  If the file is
not modified with one of those then the ctime will be the time it was
created.  All it takes is a chmod, chgrp, chown to reset the time
though and so this is not 100%.  But sometimes you can say that ctime
works out like a create time when those operations were not performed.

The mtime is the time of last modification.  For files the mtime is
updated when the contents are modified.  A directory is just a file
with pointers to other files and if any file operation happens within
that directory such as creating a file, deleting a file or renaming a
file then the directory gets modified.  So for directories again the
mtime is frequently current.

For those three times you can change two of the three of them with
UNIX commands.  The third one is always current when the other two are
set.  That is if you set the mtime then ctime is current.  If you set
ctime then mtime is current.  If you set the atime then ctime is
current.

So knowing that names of files are not stored in the inode but are
stored in the directory then we can see that renaming files in a
directory will not update the ctime of the file but it will update the
mtime of the directory.

Also a file can have many names.  If you link (e.g. with ln) the file
into other directories then the same file can have multiple names all
different.  Removing, like renaming, the pointer from the directory to
the file only updates the directory it is in and does not update the
inode of the file.

Bob


More information about the Aide mailing list