From owner-freebsd-bugs Fri May 24 08:00:04 1996 Return-Path: owner-bugs Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id IAA14543 for bugs-outgoing; Fri, 24 May 1996 08:00:04 -0700 (PDT) Received: (from gnats@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id IAA14509; Fri, 24 May 1996 08:00:02 -0700 (PDT) Date: Fri, 24 May 1996 08:00:02 -0700 (PDT) Message-Id: <199605241500.IAA14509@freefall.freebsd.org> To: freebsd-bugs Cc: From: Bruce Evans Subject: Re: bin/1242: S_ISFIFO === S_ISSOCK Reply-To: Bruce Evans Sender: owner-bugs@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk The following reply was made to PR bin/1242; it has been noted by GNATS. From: Bruce Evans 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