Patch supposed to fix Tru64.
[rsync/rsync-patches.git] / tru64.diff
1 Hi Eckert,
2
3 On Thu, Mar 21, 2002 at 03:15:39PM -0500, Eckert, Robert D wrote:
4 > Greetings, here is the output of the 'configure' step and
5 > the compile step (using the Compaq cc compiler that comes 
6 > with Tru64 V5.1A. The configure reported success and most of
7 > the compile steps cam through error/warning free except for
8 > the one that stumbled. Can someone help me out here? I am willing
9 > to provide a binary for Tru64 V5.1A if we can swat this bug.
10
11 I had the same problem. I managed to have rsync compiled OK on my
12 Tru64 5.1 box with helps from couple of people from this list.
13 Try with the patch I attach here. 
14 I am not a C programmer so you'd better check to make sure it is
15 correct.
16
17 > We depend greatly on Rsync to keep a fresh backup of our 
18 > 70gb storage system that is the backend of http://www.indiana.edu/,
19 > Indiana University's main web site to the Internet. 
20
21 I plan to do the same here instead of Tru64 vdump and vrestore
22 once I am sure backups by rsync is as reliable as vdump/vrestore.
23 Do you use rsync for root, usr partitions and and database files?
24 Have you had any problem with rsync so far?
25
26 Cheers,
27 -- 
28 Zoong Pham                        zpham@mercy.com.au
29 UNIX Systems Administrator        Mercy Health and Aged Care Inc.
30
31 To get my PGP public key, email me with the subject:
32 Request for Zoong Pham's PGP public key
33
34
35
36
37 diff -u -r rsync-2.5.4/batch.c rsync-2.5.4.new/batch.c
38 --- rsync-2.5.4/batch.c Thu Feb  7 08:20:48 2002
39 +++ rsync-2.5.4.new/batch.c     Fri Mar 22 09:24:01 2002
40 @@ -405,7 +405,15 @@
41  
42         /* FIXME: This will break if s->count is ever not exactly an int. */
43         write_batch_csums_file(flist_entry, sizeof(int));
44 +       if (s) {
45 +               write_batch_csums_file(&s->count,  sizeof(int));
46 +       }
47 +       else if (!s) {
48 +               write_batch_csums_file(&int_zero,  sizeof(int));
49 +       }
50 +       /*
51         write_batch_csums_file(s ? &s->count : &int_zero, sizeof(int));
52 +       */
53         
54         if (s) {
55                 for (i = 0; i < s->count; i++) {
56 diff -u -r rsync-2.5.4/config.h.in rsync-2.5.4.new/config.h.in
57 --- rsync-2.5.4/config.h.in     Thu Feb 28 10:15:55 2002
58 +++ rsync-2.5.4.new/config.h.in Fri Mar 22 09:24:01 2002
59 @@ -140,6 +140,9 @@
60  /* Define if you have the `mknod' function. */
61  #undef HAVE_MKNOD
62  
63 +/* Define if you have the `mkfifo' function. */
64 +#undef HAVE_MKFIFO
65 +
66  /* Define if you have the `mtrace' function. */
67  #undef HAVE_MTRACE
68  
69 @@ -244,6 +247,9 @@
70  
71  /* Define if you have the <sys/socket.h> header file. */
72  #undef HAVE_SYS_SOCKET_H
73 +
74 +/* Define if you have the <sys/un.h> header file. */
75 +#undef HAVE_SYS_UN_H
76  
77  /* Define if you have the <sys/stat.h> header file. */
78  #undef HAVE_SYS_STAT_H
79 diff -u -r rsync-2.5.4/configure rsync-2.5.4.new/configure
80 --- rsync-2.5.4/configure       Wed Mar 13 11:03:50 2002
81 +++ rsync-2.5.4.new/configure   Fri Mar 22 09:24:01 2002
82 @@ -3414,7 +3414,7 @@
83  fi
84  done
85  
86 -for ac_header in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h
87 +for ac_header in sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h
88  do
89  as_ac_Header=`echo "ac_cv_header_$ac_header" | $as_tr_sh`
90  echo "$as_me:3420: checking for $ac_header" >&5
91 @@ -6165,7 +6165,7 @@
92  fi
93  rm -f conftest.data
94  
95 -for ac_func in waitpid wait4 getcwd strdup strerror chown chmod mknod
96 +for ac_func in waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo
97  do
98  as_ac_var=`echo "ac_cv_func_$ac_func" | $as_tr_sh`
99  echo "$as_me:6171: checking for $ac_func" >&5
100 diff -u -r rsync-2.5.4/configure.in rsync-2.5.4.new/configure.in
101 --- rsync-2.5.4/configure.in    Wed Mar 13 11:03:34 2002
102 +++ rsync-2.5.4.new/configure.in        Fri Mar 22 09:24:01 2002
103 @@ -242,7 +242,7 @@
104  AC_HEADER_SYS_WAIT
105  AC_CHECK_HEADERS(sys/fcntl.h sys/select.h fcntl.h sys/time.h sys/unistd.h unistd.h utime.h grp.h)
106  AC_CHECK_HEADERS(compat.h sys/param.h ctype.h sys/wait.h sys/ioctl.h)
107 -AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h)
108 +AC_CHECK_HEADERS(sys/filio.h string.h stdlib.h sys/socket.h sys/mode.h sys/un.h)
109  AC_CHECK_HEADERS(glob.h alloca.h mcheck.h sys/sysctl.h arpa/inet.h arpa/nameser.h)
110  AC_CHECK_HEADERS(netdb.h)
111  AC_CHECK_HEADERS(malloc.h)
112 @@ -315,7 +315,19 @@
113  AC_CHECK_FUNCS(inet_ntop, , AC_LIBOBJ(lib/inet_ntop)) 
114  AC_CHECK_FUNCS(inet_pton, , AC_LIBOBJ(lib/inet_pton))
115  
116 -AC_CHECK_FUNCS(getaddrinfo, , AC_LIBOBJ(lib/getaddrinfo))
117 +# Tru64 UNIX has getaddrinfo() but has it renamed in libc as
118 +# something else so we must include <netdb.h> to get the
119 +# redefinition.
120 +AC_MSG_CHECKING([for getaddrinfo])
121 +AC_TRY_LINK([#include <sys/types.h>
122 +#include <sys/socket.h>
123 +#include <netdb.h>],[getaddrinfo(NULL, NULL, NULL, NULL);],
124 +       [AC_MSG_RESULT([yes])
125 +       AC_DEFINE(HAVE_GETADDRINFO, 1,
126 +               [Define if you have the `getaddrinfo' function.])],
127 +       [AC_MSG_RESULT([no])
128 +       AC_LIBOBJ(lib/getaddrinfo)])
129 +
130  AC_CHECK_FUNCS(getnameinfo, , AC_LIBOBJ(lib/getnameinfo))
131  
132  AC_CHECK_MEMBER([struct sockaddr.sa_len], 
133 @@ -348,7 +360,7 @@
134  dnl AC_FUNC_MEMCMP
135  
136  AC_FUNC_UTIME_NULL
137 -AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod)
138 +AC_CHECK_FUNCS(waitpid wait4 getcwd strdup strerror chown chmod mknod mkfifo)
139  AC_CHECK_FUNCS(fchmod fstat strchr readlink link utime utimes strftime)
140  AC_CHECK_FUNCS(memmove lchown vsnprintf snprintf asprintf setsid glob strpbrk)
141  AC_CHECK_FUNCS(strlcat strlcpy mtrace mallinfo setgroups)
142 diff -u -r rsync-2.5.4/lib/getaddrinfo.c rsync-2.5.4.new/lib/getaddrinfo.c
143 --- rsync-2.5.4/lib/getaddrinfo.c       Fri Dec 14 16:33:12 2001
144 +++ rsync-2.5.4.new/lib/getaddrinfo.c   Fri Mar 22 09:24:10 2002
145 @@ -41,6 +41,20 @@
146  
147  #include <rsync.h>
148  
149 +/****** Start Zoong added here */
150 +
151 +#define EAI_BADHINTS    12
152 +#define EAI_PROTOCOL    13
153 +#define EAI_MAX         14
154 +
155 +#define AI_PASSIVE      0x00000001 /* get address to use bind() */
156 +#define AI_CANONNAME    0x00000002 /* fill ai_canonname */
157 +#define AI_NUMERICHOST  0x00000004 /* prevent name resolution */
158 +#define AI_MASK         (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST)
159 +
160 +/****** End Zoong added here */
161 +
162 +
163  #if defined(__KAME__) && defined(INET6)
164  # define FAITH
165  #endif
166 diff -u -r rsync-2.5.4/rsync.h rsync-2.5.4.new/rsync.h
167 --- rsync-2.5.4/rsync.h Sat Feb 23 11:17:50 2002
168 +++ rsync-2.5.4.new/rsync.h     Fri Mar 22 09:24:01 2002
169 @@ -109,6 +109,11 @@
170  #include <sys/socket.h>
171  #endif
172  
173 +#ifdef HAVE_SYS_UN_H
174 +#define _SOCKADDR_LEN
175 +#include <sys/un.h>
176 +#endif
177 +
178  #ifdef HAVE_STRING_H
179  #include <string.h>
180  #endif
181 diff -u -r rsync-2.5.4/syscall.c rsync-2.5.4.new/syscall.c
182 --- rsync-2.5.4/syscall.c       Tue Feb 19 09:44:23 2002
183 +++ rsync-2.5.4.new/syscall.c   Fri Mar 22 09:24:01 2002
184 @@ -67,6 +67,36 @@
185  {
186         if (dry_run) return 0;
187         CHECK_RO
188 +
189 +#if HAVE_MKFIFO
190 +       if (S_ISFIFO(mode)) {
191 +               return mkfifo(pathname, mode);
192 +       }
193 +#endif
194 +
195 +#if HAVE_SYS_UN_H
196 +       if (S_ISSOCK(mode)) {
197 +               int sock;
198 +               struct sockaddr_un saddr;
199 +               int len = strlen(pathname) + 1; /* include null */
200 +
201 +               saddr.sun_family = AF_UNIX;
202 +               strncpy(saddr.sun_path, pathname, sizeof(saddr.sun_path));
203 +               saddr.sun_len = len > sizeof(saddr.sun_path) ?  sizeof(saddr.sun_path): len;
204 +
205 +               if ((sock = socket(PF_UNIX, SOCK_STREAM, 0)) < 0) {
206 +                       return -1;
207 +               }
208 +               unlink(pathname);
209 +               if ((bind(sock, (struct sockaddr*)&saddr, sizeof(saddr))) < 0) {
210 +                       return -1;
211 +               }
212 +               close(sock);
213 +               return do_chmod(pathname, mode);
214 +       }
215 +#endif
216 +
217 +
218         return mknod(pathname, mode, dev);
219  }
220  #endif