Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Is it always true that when a new file is created in a directory - the directory's mtime changes?

share|improve this question
    
This is quite easy to test... –  ewwhite May 10 '12 at 20:08
3  
Easy. However, not on all OSes & filesystems at once :) –  kolypto May 10 '12 at 20:12
add comment

1 Answer

The short answer is yes, it should. A longer answer follows.

A directory is a special kind of file; its contents is a set of (filename, i-node) tuples. Thus directory's mtime is updated whenever a tuple is added, removed or changed - that is, a file of any type (including hard links and directories) is added, removed or renamed.

Please note when file's metadata changes (owner, group, mode, atime, ctime, mtime - hosted in i-node), mtime is NOT updated (neither on the file nor containing dir) but the file's ctime does.

See also Base Definitions volume of IEEE Std 1003.1-2001, Section 4.7, File Times Update.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.