delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2017/12/15/21:08:32

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: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 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=-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 AT ludios DOT 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 AT cygwin DOT com
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

- Raw text -


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