[TAG] Question about file mtime on linux
Jay R. Ashworth
jra at baylink.com
Thu Apr 14 06:18:44 MSD 2005
On Wed, Apr 13, 2005 at 08:13:10PM -0600, Benjamin A. Okopnik wrote:
> On Wed, Apr 13, 2005 at 09:55:02PM -0400, Jay R. Ashworth wrote:
> > 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. :-)
> Hey, Suramya's got cred - he's written for us, hangs out here, and
> answers questions himself when they come up. Ya gotta pay more
> attention, Jay. :)
My apologies; I haven't been around much myself lately. Overextended.
> > 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?"
> Hm. I don't think it was _meant_ to expand to anything that complex,
> but it's possible.
Well, I can't see that he's asking anything else; simpler versions seem
> > IANAKH, but I *believe* the pertinent code is in kernel/fs/$FILESYS/file.c
> Sounds like a Hebrew title to me. Not quite as good as rabbi, but almost
> equivalent to a doctor...
Hey! Get away from me with that... what that thing a mohel uses?
> > http://www.ibiblio.org/navigator-bin/navigator.cgi?fs/ext2/file.c
> > and specifically the function ext2_file_write() (for ext2).
> > Short version:
> > 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? :-)
> An Ianakh like yourself would know better than humble little me. :) You
> lost me right after "The specific answer"; I got through the next five
> words via simple inertia, but then my brain seized up and had to be
> resupplied with copious amounts of good food. Unfortunately, I'm still
> waiting for the delivery boy (yum, /bulgogi/ with /gochujang/ and an
> armada of little side dishes, kimchi on the side. Woohoo!)
My turn for "silly me".
Actually, I think you may just be wimping out because you don't wanna
delay dinner... :-)
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