Xref: utzoo comp.sys.sgi:3319 comp.unix.wizards:21031 Path: utzoo!utgpu!news-server.csri.toronto.edu!clyde.concordia.ca!mcgill-vision!bloom-beacon!mintaka!think!zaphod.mps.ohio-state.edu!usc!elroy.jpl.nasa.gov!ames!sgi!yohn@tumult.sgi.com From: yohn@tumult.sgi.com (Mike Thompson) Newsgroups: comp.sys.sgi,comp.unix.wizards Subject: Re: Setting the access/modify time on a file Summary: This is a bug. It is fixed for the "next release" Message-ID: <53595@sgi.sgi.com> Date: 14 Mar 90 23:00:46 GMT References: <1413@watserv1.waterloo.edu> Sender: yohn@tumult.sgi.com Organization: Silicon Graphics, Inc., Mountain View, CA Lines: 37 In article <1413@watserv1.waterloo.edu>, tom@mims-iris.waterloo.edu (Tom Haapanen) writes: > I wish to update a file (with an advisory lock), and then to close it, > setting the access and modify times to (almost) the same time. Here > is what I'm attempting: > > FILE *fp; > long times; > > fp = fopen("filename", "w"); > flock(fileno(fp), LOCK_EX); > > ... much i/o to the file ... > > fflush(fp); > times[1] = time(×[0]) - (long)2; > utime(mailfile, times); > > flock(fileno(fp), LOCK_UN); > fclose(fp); > > Now, at what point does the modify time get set? the utime() call appears > to set the access time, but the modify time appears to be set AGAIN after > the access time. Where SHOULD it get set? And what should I do to make > sure that my access time > modify time? > > The OS is IRIX 3.2 -- aka System V.3. Thanks for any and all replies! This is a bug in 3.2 -- the Extent File System routine which is deallocating preallocated file blocks on close is (mistakenly) forcing the modify time to be set (to the close time). It has been fixed for the upcoming release. For now, reopen the file after the fclose, and *then* call utime and reclose the file. The deallocation routine will not be called (actually, will return without doing anything) since there had been no file activity since the open. Michael Thompson