delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2008/07/12/05:42:07

X-Recipient: archive-cygwin AT delorie DOT com
X-Spam-Check-By: sourceware.org
Date: Sat, 12 Jul 2008 11:42:28 +0200
From: Corinna Vinschen <corinna-cygwin AT cygwin DOT com>
To: cygwin AT cygwin DOT com
Subject: Re: CoPy to /dev/null fails
Message-ID: <20080712094227.GU24644@calimero.vinschen.de>
Reply-To: cygwin AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
References: <4877BD14 DOT 5000708 AT t-online DOT de>
MIME-Version: 1.0
In-Reply-To: <4877BD14.5000708@t-online.de>
User-Agent: Mutt/1.5.16 (2007-06-09)
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 Jul 11 22:05, Christian Franke wrote:
> Hi,
>
> this works on Linux:
>
> $ cp file /dev/null
>
> but fails on Cygwin 1.5.25-15:
>
> $ cp file /dev/null
> cp: cannot create regular file `/dev/null': Invalid request code
>
>
> /dev/null exists, so /bin/cp opens it with O_TRUNC only. But this fails 
> with EBADRQC (54):
>
>  fd = open("/dev/null", O_WRONLY|O_TRUNC, .)
>
> According to strace, Cygwin calls:
>
>  h = CreateFile("NUL", ., ., TRUNCATE_EXISTING, ., .);
>
> which fails.
>
>
> Interestingly, this works:
>
>   fd = open("/dev/null", O_WRONLY|O_CREAT|O_TRUNC, .);
>
> Cygwin calls:
>
>  h = CreateFile("NUL", ., ., CREATE_ALWAYS, ., .);
>
> Apparently a subtle (and IMO undocumented) difference between 
> TRUNCATE_EXISTING and CREATE_ALWAYS even when file exists.

That's a weirdness of the Win32 CreateFile call used in 1.5.25 when
accessing NUL.  This will be fixed in 1.7.0.  It uses
NtCreateFile("\Device\Null") which doesn't have that problem.


Corinna

-- 
Corinna Vinschen                  Please, send mails regarding Cygwin to
Cygwin Project Co-Leader          cygwin AT cygwin DOT com
Red Hat

--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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