Charles Russell wrote:
> James Michael Fultz wrote:
>> * Charles Russell <NOSPAM@bellsouth.net>:
<snip>
>> $ find /cygdrive/d -type f -exec cp -v {} /dev/null \;
>>
>
> That yields the error message:
> cp: cannot create regular file `/dev/null': Invalid request code
>
> I don't know whether this is typical unix behavior or something peculiar
> to Cygwin, which is usually a pretty close emulation. As noted in my
> original posting, cp does not like /dev/null.
It's cygwin. Remember that cygwin is an emulation running on top of
windows. In linux /dev/null is a real file, whereas in cygwin it's
almost an illusion. There are no real devices under cygwin, it simply
uses the underlying windows resources with a lot of filtering. The real
/dev/null file can actually be opened in linux. Under cygwin if you look
at strace output you can see where cygwin passes /dev/null down to
windows which tries to open a nul file which fails. It works with
redirection because of some clever hacking that hides the fact there is
no real /dev/null.
Still it seems this used to work better in an earlier version of cygwin
so one day I might go look at the code again and see if I'm rememberng
badly or if it changed.
I'm back

It seems the codes changed on February 23 2007 for reasons I
didn't grok completely with a first glance. The /dev/null open stuff was
removed according to the changelog. It seems like they attempted to let
windows try and open the windows nul device rather than keep emulating a
cygwin fake null device.
Anyway, I don't have any time to really run this down right now. I'm
guessing that /dev/null won't work in any context where you are trying
to open /dev/null (such as cp file /dev/null) but will work in
redirection (such as ls /cygdrive/c/windows > /dev/null) I may be wrong
but the code looks like that upon a quick glance.
FWIW I tried copy file nul in a dos command line and it appears to work
normally. So maybe somethng is broken with they way cygwin passes
windows the open(nul) call. If that was fixed then the whole thing might
work properly. I add this to my list of things to either find the
problem and send a patch or file a real bug report unless someone else
would like to step up.