Bug 1804 - FreeBSD's mknod can't create FIFOs and sockets
FreeBSD's mknod can't create FIFOs and sockets
Status: CLOSED FIXED
Product: rsync
Classification: Unclassified
Component: core
2.6.3
All FreeBSD
: P4 normal
: ---
Assigned To: Wayne Davison
Rsync QA Contact
http://lists.samba.org/archive/rsync/...
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2004-09-22 02:02 UTC by Christian Recktenwald
Modified: 2005-04-01 11:22 UTC (History)
1 user (show)

See Also:


Attachments
Adapted the referenced diff for the modern codebase (1.09 KB, patch)
2004-09-22 09:51 UTC, Wayne Davison
no flags Details
Enhanced patch with configure support (12.20 KB, patch)
2004-09-22 23:41 UTC, Wayne Davison
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Christian Recktenwald 2004-09-22 02:02:57 UTC
FreeBSD's mknod(2) is not specified to create other than character and block
device entries. For FIFO there exists mkfifo(2), for unix domain sockets 
socket(2) / bind(2).

Thomas Quinot issued the mentioned postingincluding a patch which has been
adopted by the FreeBSD ports maintainer.
Comment 1 Wayne Davison 2004-09-22 09:51:37 UTC
Created attachment 674 [details]
Adapted the referenced diff for the modern codebase

There has been a diff in the patches directory named tru64.diff that added this
mkfifo() and socket-making code among some other tru64 changes.  I've separated
these common changes for FreeBSD out into a patch named mkfifo.diff (which is
in the CVS patches dir, as well as attached here).  This should make it easier
for maintainers to customize their version of rsync with this functionality.

The reason that these changes aren't in the main codebase is that it affects
too many systems (as the patch is currently written).  For instance, Linux has
both mkfifo() and the sys/un.h header file, but it needs neither kluge added by
this patch because mknod() works for FIFOs and sockets.  Furthermore, the
socket-making code in this patch looks to be inferior to mknod() (on a system
where mknod() works for sockets) because it has to delay the chmod() call until
after the bind() call.
Comment 2 Wayne Davison 2004-09-22 09:56:33 UTC
I believe that FreeBSD may enhance their mknod() so that it can handle FIFOs and
sockets.  In the meantime, I suggest that the FreeBSD build package simply apply
the mkfifo.diff that will come with the final 2.6.3 release:

    patch -d rsync-2.6.3 -p0 <patches/mkfifo.diff
Comment 3 Christian Recktenwald 2004-09-22 13:06:24 UTC
(In reply to comment #1)
> I've separated these common changes for FreeBSD out into a patch named
mkfifo.diff 

Ok, so one can find it more easy.

> The reason that these changes aren't in the main codebase is that it affects
> too many systems.

What can be done about that?
A program testing for mknod(2) functionality could be look like that:

#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>

int main () {
        int rc;
        rc = mknod("p", S_IFIFO,0600);
        if ( rc ) {
                printf("%d %d\n",rc,errno);
        }
        return errno;
}

> Furthermore, the socket-making code in this patch looks to be inferior to 
> mknod() (on a system where mknod() works for sockets) 
> because it has to delay the chmod() call until after the bind() call.

It looks superior to not working code. To keep permissions tight one 
could set umask to 0 before creating the socket and chmod() it afterwards.

> I believe that FreeBSD may enhance their mknod() ...

As I know them, they will not. They distribute a verision of cpio which 
does not handle socket files. They say socket files are created by the 
process using them instantly so copying would be pointless.

I'm convinced concerning the fifo problem the argumentation would be:
creating block and charakter devices is a privileged operation,
creating a pipe (or a socket) are not. So there are different system calls.

(On FreeBSD mkfifo is a system call, on Linux it's a library call using
mknod(2))

So they will - also for reasons of orthogonality - not modify mknod(2).

As this is neither the first or the last system dependency let's get around it. 


Comment 4 Wayne Davison 2004-09-22 22:58:56 UTC
OK, I've reconsidered the "WONTFIX".  However, a full fix will have to wait
until after 2.6.3 is released.
Comment 5 Wayne Davison 2004-09-22 23:41:13 UTC
Created attachment 677 [details]
Enhanced patch with configure support

This patch modifies configure to (1) check if mknod() can create a FIFO, (2)
check if mknod() can create a socket, and (3) check if struct sockaddr_un has a
sun_len member element or not.	This information is used in the do_mknod()
routine (in syscall.c) to fill in any missing mknod() functionality on a system
where it doesn't handle a FIFO and/or a socket (and the sun_len change makes
the socket-creating compatibility-code even more portable than it was).
Comment 6 Wolfgang Anger 2004-09-29 13:57:08 UTC
fyi: the bug also shows up on openbsd (3.5) 
(see http://cvs.openbsd.org/cgi-bin/query-pr-wrapper?full=yes&numbers=3926 )
and IMHO also posibil present present on mac OSX 
(see http://sourceforge.net/mailarchive/forum.php?thread_id=5351434&forum_id=41320 )
Comment 7 Wayne Davison 2004-10-01 11:20:46 UTC
I've checked this patch into CVS for the next version.

Those needing something for 2.6.3 should simply apply the patches/mkfifo.diff
file to the source before building (that diff is a simpler verson of this bug's
patch that does not do any of the configure-tweaking, so only apply that diff if
you need it).