This is the mail archive of the cygwin-patches@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

S_IFSOCK setting


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
S_IFIFO.

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

Attachment: ChangeLog.txt
Description: Text document

Attachment: i_mode.patch
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]