Patch to handle Win32 named pipes as file names

Stephen Cleary yjfwhhvvvhzk6wdy@hotmail.com
Thu May 6 17:45:00 GMT 2004


Corinna -

Thanks for your helpful response. I have a question below on how would be 
the best way to proceed.

>From: Corinna Vinschen
>
>while I really appreciate the effort, that's not what we expect from
>an fhandler to do.  Cygwin is a POSIX layer.  An fhandler should at
>least try to come up with a POSIX-like translation of a Windows
>capability, in this case, converting Windows named pipes into POSIX
>FIFOs on the API level.  What your code is doing is just allowing to
>use Windows named pipes untranslated and treating them as FIFOs in
>stat().

OK; I will try to modify the fhandler_base/fhandler_disk_file to handle 
Win32 named pipes instead.

>The ability to open/read/write/close WIndows named pipes should already
>be available without much of a code change.  Paths like //./pipe/foo
>should go through untranslated, just treated like normal files.  If that
>doesn't work, feel free to fix the code snippets which accidentally 
>disallow
>that.

It is a bit more complex than first appears. The problem is that some 
functions (e.g., SetFilePointer, GetFileInformationByHandle) have undefined 
behavior when used on pipes (or other special Win32 files). Further, there 
is no way to determine the type of HANDLE after the fact (GetFileType may 
work "well enough", but it may not be specific enough for future use).

So, I think it may be necessary to keep some "handle type" enumeration along 
with the HANDLE value. I want to make this change in such a way that it'll 
be easier to add other types (volumes, mailslots, etc.). There's a couple 
ways to do this that come to mind:
1) Define a "Win32 file" major device number, with a minor device number for 
each HANDLE type.
2) Keep the single "Win32 file" device type, and add an enum that determines 
the handle type. Since this would be based off the file name, it makes sense 
to me to add this to path_conv instead of fhandler_base.
3) Just use GetFileType, which will work to distinguish pipes from disk 
files. This has minimal code impact now, but may not be sufficient for 
future work.

What do you think is the best way to go?

>However, if you want to contribute code to Cygwin, we need a copyright
>assignment from you, filled out and snail mailed to Red Hat.  Please
>see http://cygwin.com/contrib.html for details.

I will get this in the mail.

>I hope that's not too discouraging,
>Corinna

Not at all. Thank you for your response!

        -Steve

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar – get it now! 
http://toolbar.msn.com/go/onm00200415ave/direct/01/



More information about the Cygwin-patches mailing list