[TAG] Question about file mtime on linux
Jay R. Ashworth
jra at baylink.com
Thu Apr 14 05:55:02 MSD 2005
On Wed, Apr 13, 2005 at 12:29:15PM -0700, Suramya Tomar wrote:
> I have a question for you about file mtime(modify
> time) on linux. Does the mtime stamp of a file change
> as soon as a process starts modifying the file or does
> it change it after the change is done?
Ok, everyone else's treating this as a real question, so I retract my
snarky remark about school projects. :-)
It seems to me that the kernel should update the mtime in the inode (as
the inode is transparently cached in RAM) *everytime a write(1) call is
made to the file*.
So, at this point, your question expands to "if someone makes a write
call which takes a finite amount of realtime to execute (like, writing
1MB from a RAM buffer to a file), at which end of the execution of that
write call will the inode get updated?"
IANAKH, but I *believe* the pertinent code is in kernel/fs/$FILESYS/file.c
and specifically the function ext2_file_write() (for ext2).
1) ext2 updates the inode *after* it writes the actual data,
2) since it's buffered, the order in which the actual bytes hit the
disk is indeterminate, and
3) it's filesystem specific, since the answer to the question lives in
a filesystem specific location in the source.
The specific answer lies in the relative positions of ll_rw_block() and
the assignment to inode->i_mtime in the function.
Do I have that right, Ben? :-)
Jay R. Ashworth jra at baylink.com
Designer Baylink RFC 2100
Ashworth & Associates The Things I Think '87 e24
St Petersburg FL USA http://baylink.pitas.com +1 727 647 1274
If you can read this... thank a system administrator. Or two. --me
More information about the TAG