From zgabor@code.hu  Fri May 24 05:23:28 1996
Received: from mail.EUnet.hu (mail.eunet.hu [193.225.28.100])
          by freefall.freebsd.org (8.7.3/8.7.3) with ESMTP id FAA25222
          for <FreeBSD-gnats-submit@freebsd.org>; Fri, 24 May 1996 05:23:20 -0700 (PDT)
Received: by mail.EUnet.hu, id OAA16081; Fri, 24 May 1996 14:23:12 +0200
Received: from zg.CoDe.hu by CoDe.CoDe.hu (OAA02937); Fri, 24 May 1996 14:19:57 GMT
Received: (from zgabor@localhost) by zg.CoDe.hu (8.6.12/8.6.12) id OAA00390; Fri, 24 May 1996 14:31:04 +0200
Message-Id: <199605241231.OAA00390@zg.CoDe.hu>
Date: Fri, 24 May 1996 14:31:04 +0200
From: Zahemszky Gabor <zgabor@code.hu>
Reply-To: zgabor@code.hu
To: FreeBSD-gnats-submit@freebsd.org
Subject: S_ISFIFO === S_ISSOCK
X-Send-Pr-Version: 3.2

>Number:         1242
>Category:       bin
>Synopsis:       In the "sys/stat.h" file, the S_ISFIFO and S_ISSOCK macros are the same
>Confidential:   no
>Severity:       critical
>Priority:       high
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri May 24 05:30:04 PDT 1996
>Closed-Date:    Sat Jun 21 09:46:27 PDT 1997
>Last-Modified:  Tue Nov 27 18:53:12 PST 2001
>Originator:     Zahemszky Gabor <zgabor@CoDe.hu>
>Release:        FreeBSD 2.1.0-RELEASE i386
>Organization:
>Environment:

	FreeBSD 2.1.0-RELEASE from Walnut Creek CD

>Description:

	In the /usr/include/sys/stat.h, there are two macros:
	S_ISFIFO and S_ISSOCK.  They are the same (as mentioned in the
	comment).  But it's not very usable, eg. the tar (GNU) and cpio (GNU)
	from the distribution, save sockets as pipes.  And I cannot write
	a program like this:
	if (S_ISFIFO( f ) ) {
	/* it's a fifo */
		...
		}
	else {
		if ( S_ISSOCK( f ) ) {
		/* it's a socket */
			...
			}
		....
		}
	because I got fifo every time (or got socket, if I changes the two
	``if''-s).

>How-To-Repeat:

	Look into the include file, or save /dev/log with tar/cpio, and
	restore it, or look into the toc.

>Fix:
	
	You have to make difference between them, as in many other Unices.  Eg:
	#define S_ISFIFO( m ) (((m) & 0170000 ) == 0010000 )
	#define S_ISSOCK( m ) (((m) & 0170000 ) == 0140000 )

>Release-Note:
>Audit-Trail:

From: Bruce Evans <bde@zeta.org.au>
To: FreeBSD-gnats-submit@FreeBSD.org, zgabor@code.hu
Cc:  Subject: Re: bin/1242: S_ISFIFO === S_ISSOCK
Date: Sat, 25 May 1996 00:50:24 +1000

 >>Confidential:   yes
 >>Severity:       critical
 >>Priority:       high
 
 Sorry, fixing this would break binary compatibility.  It will take years
 to fix.
 
 >	In the /usr/include/sys/stat.h, there are two macros:
 >	S_ISFIFO and S_ISSOCK.  They are the same (as mentioned in the
 >	comment).
 
 This was intentional.  Pipes were implemented as (not very-) special cases
 of socket pairs.  The file descriptor type to distinguish them from sockets
 didn't exist until recently.  See kern_descrip.c.  Until recently, DTYPE_SOCK
 was used for both sockets and fifos.  Now nameless pipes are implemented
 differently and DTYPE_PIPE (which should be DTYPE_FIFO to match VFIFO like
 DTYPE_SOCKET almost matches VSOCK) is used to distinguish them from sockets.
 Named pipes still have tock DTYPE_SOCKET.
 
 >>Fix:
 >	
 >	You have to make difference between them, as in many other Unices.  Eg:
 >	#define S_ISFIFO( m ) (((m) & 0170000 ) == 0010000 )
 >	#define S_ISSOCK( m ) (((m) & 0170000 ) == 0140000 )
 
 This will result in S_ISFIFO() being false for all fifos.  It will fail
 even for nameless pipes in -current, since pipe_stat() sets S_ISOCK when
 it should set S_IFIFO.
 
 Bruce
State-Changed-From-To: open->analyzed 
State-Changed-By: wosch 
State-Changed-When: Wed Sep 18 14:36:30 PDT 1996 
State-Changed-Why:  
Bruce know what's wrong. 


Responsible-Changed-From-To: freebsd-bugs->bde 
Responsible-Changed-By: wosch 
Responsible-Changed-When: Wed Sep 18 14:36:30 PDT 1996 
Responsible-Changed-Why:  
State-Changed-From-To: analyzed->closed 
State-Changed-By: bde 
State-Changed-When: Sat Jun 21 09:46:27 PDT 1997 
State-Changed-Why:  
Fixed in -current (revision 1.12 1997/04/09). 
Fixed in 2.2.x (revision 1.8.2.1 1997/06/21). 
I don't plan to fix this in 2.1.x. 


Responsible-Changed-From-To: bde->freebsd-bugs 
Responsible-Changed-By: bde 
Responsible-Changed-When: Sat Jun 21 09:46:27 PDT 1997 
Responsible-Changed-Why:  
Someone else might want to fix it in 2.1.x. 
>Unformatted:
