delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2011/09/22/01:36:11

X-Recipient: archive-cygwin AT delorie DOT com
X-SWARE-Spam-Status: No, hits=-1.6 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,RCVD_IN_DNSWL_NONE,TW_FD,UNPARSEABLE_RELAY
X-Spam-Check-By: sourceware.org
X-Yahoo-SMTP: jenXL62swBAWhMTL3wnej93oaS0ClBQOAKs8jbEbx_o-
Date: Thu, 22 Sep 2011 01:35:43 -0400
From: Christopher Faylor <cgf-use-the-mailinglist-please AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: fsync bug
Message-ID: <20110922053543.GA29796@ednor.casa.cgf.cx>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4E7A4C69 DOT 5080807 AT redhat DOT com> <20110921205418 DOT GE31288 AT ednor DOT casa DOT cgf DOT cx> <4E7A5209 DOT 1000907 AT redhat DOT com>
MIME-Version: 1.0
In-Reply-To: <4E7A5209.1000907@redhat.com>
User-Agent: Mutt/1.5.20 (2009-06-14)
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 Wed, Sep 21, 2011 at 03:07:21PM -0600, Eric Blake wrote:
>On 09/21/2011 02:54 PM, Christopher Faylor wrote:
>> On Wed, Sep 21, 2011 at 02:43:21PM -0600, Eric Blake wrote:
>>> fsync() is required to work on read-only fds (in theory, you can sync
>>> the atime metadata, which is a write operation triggered by a read-only
>>> fd).  But cygwin rejects this program, which works on Linux:
>>>
>>> $ cat foo.c
>>> #include<errno.h>
>>> #include<unistd.h>
>>> #include<stdio.h>
>>> #include<stdlib.h>
>>> #include<assert.h>
>>> #include<fcntl.h>
>>> int main (void)
>>> {
>>>    int fd = open("file", O_CREAT|O_EXCL|O_WRONLY, 0600);
>>>    if (fd<  0)
>>>      return 1;
>>>    if (close(fd))
>>>      return 2;
>>>    fd = open("file", O_RDONLY);
>>>    if (fd<  0)
>>>      return 3;
>>>    if (fsync(fd))
>>>      return 4;
>>>    if (unlink("file"))
>>>      return 5;
>>>    puts("success");
>>>    return 0;
>>> }
>>> $ rm -f file&&  ./foo; echo $?
>>> 4
>>
>> http://msdn.microsoft.com/en-us/library/aa364439%28VS.85%29.aspx
>
>So what's wrong with making fsync() a no-op for read-only fds, on the 
>grounds that windows doesn't give us a way to flush that data, so the 
>best emulation we can do is by ignoring the request rather than 
>propagating a spurious failure back to the user?

It's hard to see how lying that fsync worked would satisfy the
requirements to write metadata.  But, then, it isn't clear that this is
even an issue on Windows.

But, in any event, you know where the source code is.

cgf

--
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