delorie.com/archives/browse.cgi | search |
X-Recipient: | archive-cygwin AT delorie DOT com |
DomainKey-Signature: | a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; q=dns; s= | |
default; b=ry3OkTVdd7kTCGld9RspQNRSXIWl8pmvVW7TUDF3r2Iawm1dd7zmT | |
DllJ+I5eInj77e9G+NTzGvUN4Nhu54V3R6yGe4neToUcZJfxAOfRpxzsQsJGHdBt | |
Jkv9CKPeG7Wi3ckzuYrPGTdCKC+G4cB1zgvO2x7/32X22SGhhO33go= | |
DKIM-Signature: | v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id |
:list-unsubscribe:list-subscribe:list-archive:list-post | |
:list-help:sender:date:from:to:subject:message-id:reply-to | |
:references:mime-version:content-type:in-reply-to; s=default; | |
bh=6RfUooT4WH1P/tPpKW4dPkakcCY=; b=lKKGD8KfUyxSB1N9Z6rPDDpRwAi5 | |
tPL+43zTLeVA6hO3/aPE4jPiOAT/2xGVx7QJ8pGM5M8xEESe6qKRX/lk81UlEqkj | |
7f/95FZ6ouBvZRg9Jk9mb+jmp/ohj6vinUiFpAMQxF9zT1sWgD3hFWCi6nbV1X+O | |
D5qfTV1v/Yk/cow= | |
Mailing-List: | contact cygwin-help AT cygwin DOT com; run by ezmlm |
List-Id: | <cygwin.cygwin.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 |
Authentication-Results: | sourceware.org; auth=none |
X-Virus-Found: | No |
X-Spam-SWARE-Status: | No, score=-100.3 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,KAM_LAZY_DOMAIN_SECURITY,RCVD_IN_BRBL_LASTEXT,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=Ivan, kozik, Kozik, Stay |
X-HELO: | drew.franken.de |
Date: | Mon, 18 Dec 2017 14:10:35 +0100 |
From: | Corinna Vinschen <corinna-cygwin AT cygwin DOT com> |
To: | cygwin AT cygwin DOT com |
Subject: | Re: Wrong file position after writing 65537 bytes to block device |
Message-ID: | <20171218131035.GB11285@calimero.vinschen.de> |
Reply-To: | cygwin AT cygwin DOT com |
Mail-Followup-To: | cygwin AT cygwin DOT com |
References: | <CAKyntiKrJBZRTSDdAbDTuaS3NNoGLD3OaM8M7V7Fq3EroArXxg AT mail DOT gmail DOT com> |
MIME-Version: | 1.0 |
In-Reply-To: | <CAKyntiKrJBZRTSDdAbDTuaS3NNoGLD3OaM8M7V7Fq3EroArXxg@mail.gmail.com> |
User-Agent: | Mutt/1.9.1 (2017-09-22) |
--mP3DRpeJDSE+ciuQ Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Dec 16 02:07, Ivan Kozik wrote: > Hello, >=20 > I have discovered that if you write 65536 + 1 bytes to a block device > in cygwin, the file position can become 65536 + 512. >=20 > With /dev/sdc as a throwaway USB block device: >=20 > (cygwin_write.c is pasted below) > # gcc -O2 -Wall -o cygwin_write cygwin_write.c > # ./cygwin_write /dev/sdc > 66048 >=20 > I am running 64-bit cygwin 2.9.0 on an updated Windows 8.1. I saw the > same results with an 8TB drive and a 512MB USB stick. In general, the writes on disk devices is sector-oriented. Howewver, in this case ftell should have returned 65536. The problem here is that the newlib implmentation of ftell/ftello performs an fflush when called on a write stream since about 2008 to adjust for appending streams. Given your example (thanks for the testcase!) this seems pretty wrong. Looking further it turns out that neither glibc nor BSD actually calls fflush in this case. There's only a special case for appending streams, but this calls lseek, not fflush. Looks like a patch is required. Stay tuned. Thanks, Corinna --=20 Corinna Vinschen Please, send mails regarding Cygwin to Cygwin Maintainer cygwin AT cygwin DOT com Red Hat --mP3DRpeJDSE+ciuQ Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJaN75LAAoJEPU2Bp2uRE+gF3EQAIFF3CCRbb3k51088FvtRaNa 7fzWsqur6MZoFKMMge6hB2ze3phwZPcZWINQmzSIXKibJhLbQ/P3HLFCio5jg816 VDLq2BJqJLZAaWCN3MGdJRmW2j3noLrlVHDQ4EbyVxXkDe5uRbZSwwsyyV7EW4CQ rT7/MpnDixORLnEExcHcaYBmY8dwkJvSujmcsHuiK++q7Lwu/mnykhZPm3BbGBZ7 tD/lJ2yL+AyUwmjFsowJeHIIl7vxbEBK8No/tVSiwUJZwWG1X+AibPuSk3AVBHAJ 1ge9gWDygfwhjgHkuDI4nMh6gH1/yT0WWjROvhpDad1/KjBfTjr7XIehGSsF/cPC xN/kkmQXw3lfgxbjkjxReLT9PGKcBewtISKHhXvRyI8FiSH+mUlNPnaFEmcMEqY2 yH6PCVGsG8GjDvRM79AVXSHbwowPhAIHGKGvS8UDZg79DV26bnNXp+zHxn3iG/zo 5I88l/6f82Km0HmRsZRehxmbEeMob07Yr/LE0PsXbQTSYAJe8y2PYWwpeKbccVQM xEJZdmRDhERgAdUeR1HUPFi4Rz+kfCAtSlxLRE3LU29R4L5JjvTySgfDjliEUI+q qliFoG8REmECnMp95u89LLRZXmYCIV0/KJnbzHLE9xrd6GgObwTW+BZX2br3I23j 6Lu4pttsK+Vtp3gsTwOn =EEGV -----END PGP SIGNATURE----- --mP3DRpeJDSE+ciuQ--
webmaster | delorie software privacy |
Copyright © 2019 by DJ Delorie | Updated Jul 2019 |