delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/12/03/15:37:44

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sat, 3 Dec 2011 21:36:56 +0100
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: Redirecting output from running proc doesn't modify the "last modified time" field for target file
Message-ID: <20111203203656.GA12518@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <32903475 DOT post AT talk DOT nabble DOT com> <CAG_2cTn_1UHZy-13ACu-EPMaUSSSOr38s1_Rc0ccmdS2JDyJSQ AT mail DOT gmail DOT com> <32904332 DOT post AT talk DOT nabble DOT com> <CAG_2cTm+VQcNuRmDTFEheEyuOAeWA4tCW5+whH74E6D4UkAFAg AT mail DOT gmail DOT com> <4ED92F64 DOT 4060905 AT redhat DOT com>
MIME-Version: 1.0
In-Reply-To: <4ED92F64.4060905@redhat.com>
User-Agent: Mutt/1.5.21 (2010-09-15)
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Unsubscribe: <mailto:cygwin-unsubscribe-archive-cygwin=delorie DOT com AT cygwin DOT com>
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

On Dec  2 13:04, Eric Blake wrote:
> On 12/02/2011 11:50 AM, Jon Clugston wrote:
> > While this loop is running, the timestamp on "x.log" doesn't change
> > (whereas on Linux it changes every 10 seconds).  It sure looks to me
> > that Windows just doesn't bother updating the file timestamp while it
> > is open.  I don't know if this update is required by POSIX - I would
> > doubt that it is.
> 
> POSIX requires that any write() to an open file mark it for update; the
> update doesn't have to occur right away (so you can batch up several
> writes, but only change the mtime metadata once at the end of the
> batch), but it DOES require that stat() and several similar functions
> flush all marked updates prior to exposing timestamps to the user.  So
> yes, Windows is violating POSIX, and I have no idea whether cygwin can
> work around it.

You can change all file operations to use FILE_WRITE_THROUGH and
FILE_NO_INTERMEDIATE_BUFFERING.  Downside:  No caching.  All file
operations must be sector aligned.  Degraded system performance.
Broken when a process has only write permissions.

Alternatively, change write(2) so that every WriteFile call is
accompanied by a FlushFileBuffers call.  Downside: Extremly degraded
write performance.

Alternatively:  Lie.  That's how SUA does it.  It has a background
service running which (among other things) keeps track of write
operations of SUA applications.  If a SUA application calls write(2)
the write timestamp is kept up to date internally, while the metadata
on disk is still lagging in Windows style.  A SUA application calling
stat(2) gets a POSIX compatible timestamp.  Non-SUA apps continue to
show the "wrong" timestamp.  If non-SUA apps write to a file, SUA apps
also show the Windows timestamp.  Cygwin could do the same.  Downside:
We don't have a mandatory background service running.  Quite a hoop to
jump through to implement a usually non-critical POSIX requirement.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019