Moved the mkfifo() and socket-making code to mkfifo.diff.
[rsync/rsync-patches.git] / mkfifo.diff
CommitLineData
5d24532c
WD
1--- orig/rsync.h 2004-09-22 08:47:31
2+++ rsync.h 2004-07-03 20:23:33
3@@ -163,6 +163,10 @@ enum msgcode {
4 #include <sys/socket.h>
5 #endif
6
7+#ifdef HAVE_SYS_UN_H
8+#include <sys/un.h>
9+#endif
10+
11 #ifdef HAVE_STRING_H
12 #include <string.h>
13 #endif
14--- orig/syscall.c 2004-08-02 21:56:59
15+++ syscall.c 2004-06-18 17:38:35
16@@ -76,6 +76,29 @@ int do_mknod(char *pathname, mode_t mode
17 {
18 if (dry_run) return 0;
19 RETURN_ERROR_IF_RO_OR_LO;
20+# if HAVE_MKFIFO
21+ if (S_ISFIFO(mode))
22+ return mkfifo(pathname, mode);
23+# endif
24+# if HAVE_SYS_UN_H
25+ if (S_ISSOCK(mode)) {
26+ int sock;
27+ struct sockaddr_un saddr;
28+ int len = strlen(pathname) + 1; /* include null */
29+
30+ saddr.sun_family = AF_UNIX;
31+ strncpy(saddr.sun_path, pathname, sizeof saddr.sun_path);
32+ saddr.sun_len = len > sizeof saddr.sun_path ? sizeof saddr.sun_path : len;
33+
34+ if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0)
35+ return -1;
36+ unlink(pathname);
37+ if ((bind(sock, (struct sockaddr*)&saddr, sizeof saddr)) < 0)
38+ return -1;
39+ close(sock);
40+ return do_chmod(pathname, mode);
41+ }
42+# endif
43 return mknod(pathname, mode, dev);
44 }
45 #endif