X-Recipient: archive-cygwin@delorie.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:mime-version:from:date:message-id:subject:to
	:content-type; q=dns; s=default; b=X/Na26/rD8e72+dI7XZTiuOrl626a
	XAuNO59mD+6MmgPkajib7xDAgRG9M/UoFcZk0CEMlqdrZZWJpmIbjrWhtRqZwUOv
	5Nl4tUcOcdmgNNvsY93V0YBwiRkXYNXENpUBLyBcmh4uR/AweQAAWWbrKKRaXloQ
	It7N9OczeiUc3k=
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:mime-version:from:date:message-id:subject:to
	:content-type; s=default; bh=xcbEahQwxeAzcuffVP6XT++cuek=; b=Rsh
	bKKZYnTgVFo/L7wmY22SxvWB/hV/DCJGcOLl7x3LgDZsCBpH7VXv5XycdLh20xV0
	WVCoNQLZwH4ES9MQ9m8Q74aOZy2MUJ+IOpzuJvfhOs53JtbBsY0b5PzKK+3DXPQY
	CJKmpoa2GRAgxNmMC53Wa34Vel3meXlCFF6cB1RE=
Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm
List-Id: <cygwin.cygwin.com>
List-Subscribe: <mailto:cygwin-subscribe@cygwin.com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin@cygwin.com>
List-Help: <mailto:cygwin-help@cygwin.com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner@cygwin.com
Mail-Followup-To: cygwin@cygwin.com
Delivered-To: mailing list cygwin@cygwin.com
Authentication-Results: sourceware.org; auth=none
X-Virus-Found: No
X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=512mb, 512MB, ivan, USB
X-HELO: mail-qk0-f171.google.com
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;        d=1e100.net; s=20161025;        h=x-gm-message-state:mime-version:from:date:message-id:subject:to;        bh=SARqqzDvpLgUSSihZDUfyGML5Bt14cliwtzuYAuy2f4=;        b=rMTjBCeBt6gWNqRV8X633pe23Epji2vT5cNIsDyQbMlQEQwxtNa7x0+oVYYZBJL3yp         0gwOYIvXN23xvJOB65U1Bxt9n1q5ZfbfeO/kFUq7FIgzLrbyU8N/YeIrVm1dJXAmc4nt         XiP4LJKbNbs1+ipMCYoeNsnyjgkQx9jOoSGfxQzTMJa3SzgLeNuS89GwGKnt3Tv1vSzX         NnuZEmQZCMszRiD1JshXz5dS3Dxe7Gl7wek0ufCgCKIcJSRgv/USDwgoGRMokEB1ux2+         GN2guYvaent+pdu8GjyKBAzpkItoU/gkmkK47tlYOrOZYk/z+jRvAe/+jsFVFlAe1Kp5         3MUA==
X-Gm-Message-State: AKGB3mIA0PJ2NvhCNV0AuIL0A25wyUFoC4AwYUYtyHPn8P+RDT8d4G79	tnxiJfyqRIZLJs7FyI0H28+F6uFKs4+3DnnTbC/YaPQ4
X-Google-Smtp-Source: ACJfBouqpnkh3bF6MalhiWtMg10Ke7ivugE1DZTXvm+Muq66Wb1oXDNJbCKoCpZWyQQhiu+g6sbeidwp2CveLF88diA=
X-Received: by 10.55.149.196 with SMTP id x187mr22760513qkd.51.1513390097114; Fri, 15 Dec 2017 18:08:17 -0800 (PST)
MIME-Version: 1.0
From: Ivan Kozik <ivan@ludios.org>
Date: Sat, 16 Dec 2017 02:07:45 +0000
Message-ID: <CAKyntiKrJBZRTSDdAbDTuaS3NNoGLD3OaM8M7V7Fq3EroArXxg@mail.gmail.com>
Subject: Wrong file position after writing 65537 bytes to block device
To: cygwin@cygwin.com
Content-Type: text/plain; charset="UTF-8"
X-IsSubscribed: yes

Hello,

I have discovered that if you write 65536 + 1 bytes to a block device
in cygwin, the file position can become 65536 + 512.

With /dev/sdc as a throwaway USB block device:

(cygwin_write.c is pasted below)
# gcc -O2 -Wall -o cygwin_write cygwin_write.c
# ./cygwin_write /dev/sdc
66048

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.

Best regards,

Ivan


cygwin_write.c:

#include <stdio.h>

int main(int argc, char *argv[]) {
    FILE *f = fopen(argv[1], "w");
    char x[65536 + 1];
    fwrite(x, 1, 65536 + 1, f);
    printf("%ld", ftell(f));
    return 0;
}

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

