From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29684 invoked by alias); 22 Apr 2014 16:09:50 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 29669 invoked by uid 89); 22 Apr 2014 16:09:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.4 required=5.0 tests=AWL,BAYES_00,UNSUBSCRIBE_BODY autolearn=no version=3.3.2 X-HELO: mailbackend.panix.com Received: from mailbackend.panix.com (HELO mailbackend.panix.com) (166.84.1.89) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 22 Apr 2014 16:09:48 +0000 Received: from compute01.cs.columbia.edu (compute01.cs.columbia.edu [128.59.11.31]) by mailbackend.panix.com (Postfix) with ESMTP id 328533229C for ; Tue, 22 Apr 2014 12:09:46 -0400 (EDT) Message-ID: <21334.37961.774546.475597@compute01.cs.columbia.edu> Date: Tue, 22 Apr 2014 16:09:00 -0000 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable To: cygwin@cygwin.com Subject: Re: fstat st_size on open files on Parallels filesystem is wrong In-Reply-To: <20140422081628.GC2339@calimero.vinschen.de> References: <21333.25325.11106.958642@compute01.cs.columbia.edu> <227151856.20140421223417@yandex.ru> <21333.26515.393838.380071@compute01.cs.columbia.edu> <20140422081628.GC2339@calimero.vinschen.de> From: lennox@cs.columbia.edu X-SW-Source: 2014-04/txt/msg00502.txt.bz2 On Tuesday, April 22 2014, "Corinna Vinschen" wrote to "cygwin at cygwin.co= m" saying: > On Apr 21 14:46, lennox at cs.columbia.edu wrote: > > On Monday, April 21 2014, "Andrey Repin" wrote to "lennox at > > cs.columbia.edu, cygwin at cygwin.com" saying: > >=20 > > > Greetings, lennox at cs.columbia.edu! > > >=20 > > > > I=E2=80=99m running cygwin64 1.7.29 in a Windows 8.1 Pro virtual ma= chine, running in > > > > Parallels Desktop 9.0.24229 on Mac OS X 10.9.2. > > >=20 > > > > Parallels Desktop automatically mounts my Mac OS X home directory a= s a Z: > > > > drive in Windows. Cygwin mount reports this drive as being type "p= rlsf". > > >=20 > > > > Unfortunately, I've discovered that if I have an open file on this > > > > filesystem which has been written to, the size returned by Cygwin f= stat() on > > > > the open file is wrong. A stat() of the file after it's been close= d is > > > > correct. > > >=20 > > > > This has the consequence that emacs always thinks saved files have = been > > > > modified externally, since emacs looks at files' sizes (as well as = their > > > > modification times) to detect external changes. This makes emacs > > > > near-unusable. > > >=20 > > > > This problem does not occur for files in my Cygwin home directory, = or other > > > > locations mounted on my Windows C: drive. > > >=20 > > > > I've attached a simple unit test program that illustrates the probl= em. > > > > I've also attached my cygcheck -s -v -r output. > > >=20 > > > > Any ideas? Is this a Cygwin bug, a Parallels bug, or something els= e? > > > > Glancing over the Cygwin code, I see that there are a few cases whe= re fstat > > > > has special cases for certain filesystem types. > > >=20 > > > You never flushing the buffer in your test code, or I'm reading it wr= ong? > >=20 > > This is using Posix APIs -- open() / write() -- not C APIs, fopen() / > > fwrite(), so there shouldn't be a buffer? Notice that the test behaves= as I > > expect for a file on NTFS. > >=20 > > Adding a call to fsync() prior to the fstat() call doesn't change anyth= ing. >=20 > This is actually a bad sign. The problem you're describing occurs on > NFS, too. If you write to the file, a subsequent call to fetch stat > attributes does not return the actual size of the file, but the size at > the time the handle has been opened. >=20 > However, on NFS, a call to FlushFileBuffers helps to kick stat back into > shape. That's the Win32 function called from fsync as well. What is > Cygwin supposed to do if that doesn't work? It's certainly possible that the file system driver in the Parallels Tools has a bug, and if so I'm happy to report it to Parallels. I'll see if I can reproduce the test case using just Win32 APIs. Are there any particular gotchas I should watch out for, or should just looking at what Win32 functions are called in fhandler_disk_file.cc be sufficient? --=20 Jonathan Lennox lennox at cs.columbia.edu -- 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