Rsync 2.5.5: FreeBSD mknod can't create FIFO's
Thomas Quinot
thomas at melusine.cuivre.fr.eu.org
Mon Jun 24 06:09:02 EST 2002
The following patch (adapted to rsync 2.5.5 from the one posted in
Dec. 2000, http://lists.samba.org/pipermail/rsync/2000-December/003349.html)
is necessary to prevent rsync from failing on creating FIFOs or UNIX
sockets on FreeBSD. Any chance for it to be integrated in a future
release of rsync?
Thomas.
diff -ur work/rsync-2.5.5/config.h.in work.patch/rsync-2.5.5/config.h.in
--- work/rsync-2.5.5/config.h.in Tue Apr 2 03:50:49 2002
+++ work.patch/rsync-2.5.5/config.h.in Mon Jun 24 14:41:48 2002
@@ -140,6 +140,9 @@
/* Define if you have the `mknod' function. */
#undef HAVE_MKNOD
+/* Define if you have the `mkfifo' function. */
+#undef HAVE_MKFIFO
+
/* Define if you have the `mtrace' function. */
#undef HAVE_MTRACE
@@ -244,6 +247,9 @@
/* Define if you have the <sys/socket.h> header file. */
#undef HAVE_SYS_SOCKET_H
+
+/* Define if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
/* Define if you have the <sys/stat.h> header file. */
#undef HAVE_SYS_STAT_H
diff -ur work/rsync-2.5.5/configure work.patch/rsync-2.5.5/configure
--- work/rsync-2.5.5/configure Tue Apr 2 03:50:46 2002
+++ work.patch/rsync-2.5.5/configure Mon Jun 24 14:44:58 2002
@@ -4344,7 +4344,8 @@
-for ac_header in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h
+
+for ac_header in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h
do
as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
if eval "test \"\${$as_ac_Header+set}\" = set"; then
@@ -7736,7 +7737,8 @@
-for ac_func in waitpid wait4 getcwd strdup strerror chown chmod mknod
+
+for ac_func in waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo
do
as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
echo "$as_me:$LINENO: checking for $ac_func" >&5
diff -ur work/rsync-2.5.5/configure.in work.patch/rsync-2.5.5/configure.in
--- work/rsync-2.5.5/configure.in Tue Apr 2 03:41:59 2002
+++ work.patch/rsync-2.5.5/configure.in Mon Jun 24 14:42:28 2002
@@ -253,7 +253,7 @@
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
-AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
+AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(malloc.h)
@@ -359,7 +359,7 @@
dnl AC_FUNC_MEMCMP
AC_FUNC_UTIME_NULL
-AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
+AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo setgroups)
diff -ur work/rsync-2.5.5/rsync.h work.patch/rsync-2.5.5/rsync.h
--- work/rsync-2.5.5/rsync.h Mon Jun 24 14:53:36 2002
+++ work.patch/rsync-2.5.5/rsync.h Mon Jun 24 14:45:25 2002
@@ -108,6 +108,10 @@
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
+#endif
+
+#ifdef HAVE_SYS_UN_H
+#include <sys/un.h>
#endif
#ifdef HAVE_STRING_H
diff -ur work/rsync-2.5.5/syscall.c work.patch/rsync-2.5.5/syscall.c
--- work/rsync-2.5.5/syscall.c Mon Mar 25 04:51:17 2002
+++ work.patch/rsync-2.5.5/syscall.c Mon Jun 24 14:46:19 2002
@@ -67,6 +67,35 @@
{
if (dry_run) return 0;
CHECK_RO
+
+#if HAVE_MKFIFO
+ if (S_ISFIFO(mode)) {
+ return mkfifo(pathname, mode);
+ }
+#endif
+
+#if HAVE_SYS_UN_H
+ if (S_ISSOCK(mode)) {
+ int sock;
+ struct sockaddr_un saddr;
+ int len = strlen(pathname) + 1; /* include null */
+
+ saddr.sun_family = AF_UNIX;
+ strncpy(saddr.sun_path, pathname, sizeof(saddr.sun_path));
+ saddr.sun_len = len > sizeof(saddr.sun_path) ? sizeof(saddr.sun_path) : len;
+
+ if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
+ return -1;
+ }
+ unlink(pathname);
+ if ((bind(sock, (struct sockaddr*)&saddr, sizeof(saddr))) < 0) {
+ return -1;
+ }
+ close(sock);
+ return do_chmod(pathname, mode);
+ }
+#endif
+
return mknod(pathname, mode, dev);
}
#endif
--
Thomas.Quinot at Cuivre.FR.EU.ORG
More information about the rsync
mailing list