S_IFSOCK setting

Conrad Scott Conrad.Scott@dsl.pipex.com
Sat Jun 22 07:22:00 GMT 2002

I noticed, while grotting around in various /dev/ stuff, that fstat(2)
on sockets and pipes gives a file type of S_IFCHR, which doesn't seem
quite right. Sockets should get S_IFSOCK and pipes should get, well,
something. A quick investigation by reading sources (i.e. no warranty)
for various Un*ces reveals the following device type settings for
anonymous pipes (i.e. the result of calling pipe(2)):

*) Both Linux and FreeBSD set S_IFIFO.
*) V7 set IFREG.
*) In sys V.4, pipes are streams AFAIK but I'm not sure what mode to
expect for those: S_IFSOCK?
*) 4.* BSD set S_IFSOCK (since pipes are implemented as sockets).

The current Open Group specification doesn't seem to specify what file
types should be returned for which objects . . . !? [BTW I'm using
issue 6, which is available at
http://www.opengroup.org/onlinepubs/007904975/ --- I don't know of any
better source for Posix spec's on the web --- are there any?]

So, in the patch I've gone for Linux compatibility, i.e. all pipes get
S_IFIFO despite that file type being defined as being just for named
pipes. Sigh. I'm also unclear whether fhandlers ever get created with
a device type of FH_PIPE (except for explicit opens of /dev/pipe).
Just to be sure, I gave this the same i_mode as previously but with

This patch also makes the output of `ls -l /dev/tcp' a bit strange,
but I think this is a relatively unimportant detail, what with a
pending /dev vfs.

Anyhow, enjoy?

// Conrad

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: ChangeLog.txt
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020622/8307397e/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: i_mode.patch
Type: application/octet-stream
Size: 1739 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin-patches/attachments/20020622/8307397e/attachment.obj>

More information about the Cygwin-patches mailing list