public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* CoPy to /dev/null fails
@ 2008-07-11 20:06 Christian Franke
  2008-07-12  9:42 ` Corinna Vinschen
  0 siblings, 1 reply; 2+ messages in thread
From: Christian Franke @ 2008-07-11 20:06 UTC (permalink / raw)
  To: cygwin

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.

Christian


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

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: CoPy to /dev/null fails
  2008-07-11 20:06 CoPy to /dev/null fails Christian Franke
@ 2008-07-12  9:42 ` Corinna Vinschen
  0 siblings, 0 replies; 2+ messages in thread
From: Corinna Vinschen @ 2008-07-12  9:42 UTC (permalink / raw)
  To: cygwin

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/

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2008-07-12  9:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-07-11 20:06 CoPy to /dev/null fails Christian Franke
2008-07-12  9:42 ` Corinna Vinschen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).