arla patches for NT/cygwin32

Dan Winship danw at MIT.EDU
Sun Mar 29 03:08:06 CEST 1998


cygwin32 is pretty cool. I got arlad -t running under NT without too
much work...

You'll need to add in the right autoheader magic to make it #define
O_BINARY to 0 on platforms that don't have it. (I've never played with
autoheader and I figured you could probably deal more easily than I
could.)

I'm not sure why the HAVE_WINSOCK_H thing was there... it made
everything break, so I had to remove it and then it all worked fine.
(Oh, but I forget to remove the check from the configure script.)


I don't know if there's any hope for getting xfs or some equivalent to
work under NT, but I'm planning to show this to some NT programmer
types here who are currently really annoyed with Transarc for being so
fascist about the NT AFS client (no site license, no source
license)... :-)

-- Dan

diff -ruN arla-0.4.orig/arlad/afsdir_check.c arla-0.4/arlad/afsdir_check.c
--- arla-0.4.orig/arlad/afsdir_check.c	Fri Mar 27 20:39:45 1998
+++ arla-0.4/arlad/afsdir_check.c	Sat Mar 28 17:14:01 1998
@@ -97,7 +97,7 @@
     unsigned noverfill;
     u_int8_t my_bitmaps[MAXPAGES][ENTRIESPERPAGE / 8];
 
-    fd = open (filename, O_RDONLY, 0);
+    fd = open (filename, O_RDONLY | O_BINARY, 0);
     if (fd < 0)
 	err (1, "open %s", filename);
 
diff -ruN arla-0.4.orig/arlad/bsd-subr.c arla-0.4/arlad/bsd-subr.c
--- arla-0.4.orig/arlad/bsd-subr.c	Fri Mar 27 20:39:47 1998
+++ arla-0.4/arlad/bsd-subr.c	Sat Mar 28 17:14:45 1998
@@ -121,7 +121,7 @@
      fcache_extra_file_name (e, handle, handle_size);
      res.tokens = e->tokens |= XFS_DATA_R | XFS_OPEN_NR;
 
-     args.fd = open (handle, O_WRONLY | O_CREAT | O_TRUNC, 0666);
+     args.fd = open (handle, O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
      if (args.fd == -1) {
 	  perror ("open");
 	  res.res = -1;
diff -ruN arla-0.4.orig/arlad/fcache.c arla-0.4/arlad/fcache.c
--- arla-0.4.orig/arlad/fcache.c	Fri Mar 27 20:39:51 1998
+++ arla-0.4/arlad/fcache.c	Sat Mar 28 18:47:43 1998
@@ -412,7 +412,7 @@
     int fd;
     unsigned n;
 
-    fd = open ("fcache.new", O_WRONLY | O_CREAT | O_TRUNC, 0666);
+    fd = open ("fcache.new", O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
     if (fd < 0)
 	return errno;
     n = 0;
@@ -452,7 +452,7 @@
     unsigned n;
     AFSCallBack broken_callback = {0, 0, CBDROPPED};
 
-    fd = open ("fcache", O_RDONLY, 0);
+    fd = open ("fcache", O_RDONLY | O_BINARY, 0);
     if (fd < 0)
 	return;
     n = 0;
@@ -801,7 +801,7 @@
     char fname[MAXPATHLEN];
 
     fcache_file_name (entry, fname, sizeof(fname));
-    return open (fname, flag, mode);
+    return open (fname, flag | O_BINARY, mode);
 }
 
 /*
@@ -817,7 +817,7 @@
 	    entry->status.FileType == TYPE_DIR);
 
     fcache_extra_file_name (entry, fname, sizeof(fname));
-    return open (fname, flag, mode);
+    return open (fname, flag, mode | O_BINARY);
 }
 
 /*
diff -ruN arla-0.4.orig/arlad/inter.c arla-0.4/arlad/inter.c
--- arla-0.4.orig/arlad/inter.c	Fri Mar 27 20:39:51 1998
+++ arla-0.4/arlad/inter.c	Sat Mar 28 17:19:11 1998
@@ -86,7 +86,7 @@
 void
 cm_init (void)
 {
-    log_fd = open ("log", O_WRONLY | O_APPEND | O_CREAT, 0666);
+    log_fd = open ("log", O_WRONLY | O_APPEND | O_CREAT | O_BINARY, 0666);
     if (log_fd < 0)
 	err (1, "open log failed");
     log_fp = fdopen (log_fd, "a");
diff -ruN arla-0.4.orig/arlad/volcache.c arla-0.4/arlad/volcache.c
--- arla-0.4.orig/arlad/volcache.c	Fri Mar 27 20:39:57 1998
+++ arla-0.4/arlad/volcache.c	Sat Mar 28 17:19:57 1998
@@ -221,7 +221,7 @@
     VolCacheEntry tmp;
     unsigned n;
 
-    fd = open ("volcache", O_RDONLY, 0);
+    fd = open ("volcache", O_RDONLY | O_BINARY, 0);
     if (fd < 0)
 	return;
     n = 0;
@@ -266,7 +266,7 @@
     int fd;
     unsigned n;
 
-    fd = open ("volcache.new", O_WRONLY | O_CREAT | O_TRUNC, 0666);
+    fd = open ("volcache.new", O_WRONLY | O_CREAT | O_TRUNC | O_BINARY, 0666);
     if (fd < 0)
 	return errno;
     n = 0;
diff -ruN arla-0.4.orig/configure.in arla-0.4/configure.in
--- arla-0.4.orig/configure.in	Fri Mar 27 20:39:39 1998
+++ arla-0.4/configure.in	Sat Mar 28 15:07:27 1998
@@ -139,7 +139,7 @@
   AC_MSG_RESULT(none)
   AC_MSG_WARN(No kernel support for $target_os, compiling only user-level stuff)
   KERNEL_INCLUDE=`(cd $srcdir; pwd)`/xfs/unknown
-  KERNEL_SRCS=
+  KERNEL_SRCS=unknown-subr.c
   KERNEL_HDRS=
   KERNEL=/dev/null
   XFS_SUBDIR=
@@ -538,9 +538,10 @@
 
 AC_BROKEN(chown daemon err errx fchown flock getcwd getdtablesize getopt)
 AC_BROKEN(getusershell inet_aton initgroups lstat memmove mkstemp)
-AC_BROKEN(putenv rcmd readv setegid setenv seteuid strcasecmp strdup)
-AC_BROKEN(strerror strftime strlwr strnlen strsep strtok_r strupr unsetenv)
-AC_BROKEN(verr verrx vsyslog vwarn vwarnx warn warnx writev)
+AC_BROKEN(putenv rcmd readv recvmsg sendmsg setegid setenv seteuid)
+AC_BROKEN(strcasecmp strdup strerror strftime strlwr strnlen strsep)
+AC_BROKEN(strtok_r strupr unsetenv verr verrx vsyslog vwarn vwarnx warn)
+AC_BROKEN(warnx writev)
 
 AC_CHECK_FUNCS(fcntl getrlimit getspnam getspuid mktime setregid)
 AC_CHECK_FUNCS(setresuid setreuid setsid setsockopt sysconf sysctl)
diff -ruN arla-0.4.orig/include/config.h.in arla-0.4/include/config.h.in
--- arla-0.4.orig/include/config.h.in	Fri Mar 27 20:39:59 1998
+++ arla-0.4/include/config.h.in	Sat Mar 28 12:15:09 1998
@@ -132,8 +132,14 @@
 /* Define if you have the readv function.  */
 #undef HAVE_READV
 
+/* Define if you have the recvmsg function.  */
+#undef HAVE_RECVMSG
+
 /* Define if you have the res_search function.  */
 #undef HAVE_RES_SEARCH
+
+/* Define if you have the sendmsg function.  */
+#undef HAVE_SENDMSG
 
 /* Define if you have the setegid function.  */
 #undef HAVE_SETEGID
diff -ruN arla-0.4.orig/lib/roken/recvmsg.c arla-0.4/lib/roken/recvmsg.c
--- arla-0.4.orig/lib/roken/recvmsg.c	Wed Dec 31 19:00:00 1969
+++ arla-0.4/lib/roken/recvmsg.c	Sat Mar 28 16:27:17 1998
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hvgskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Kungliga Tekniska
+ *      Hvgskolan and its contributors.
+ * 
+ * 4. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+RCSID("$Id: $");
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+
+int
+recvmsg(int s, struct msghdr *msg, int flags)
+{
+  void *buf, *bp;
+  int i, size, rcvd = 0;
+
+  for (i = size = 0; i < msg->msg_iovlen; i++)
+    size += msg->msg_iov[i].iov_len;
+
+  do
+    {
+      buf = malloc(size);
+      if (!buf)
+	return -1;
+
+      rcvd = recvfrom(s, buf, size, flags, msg->msg_name, &msg->msg_namelen);
+      if (rcvd == -1)
+	{
+	  free(buf);
+	  if (errno == EMSGSIZE)
+	    size *= 2;
+	  else
+	    return rcvd;
+	}
+    }
+  while (rcvd <= 0);
+
+  for (i = 0, bp = buf; i < msg->msg_iovlen; i++)
+    {
+      memcpy(msg->msg_iov[i].iov_base, bp, msg->msg_iov[i].iov_len);
+      bp += msg->msg_iov[i].iov_len;
+    }
+
+  free(buf);
+  return rcvd;
+}
diff -ruN arla-0.4.orig/lib/roken/resolve.h arla-0.4/lib/roken/resolve.h
--- arla-0.4.orig/lib/roken/resolve.h	Fri Mar 27 20:40:19 1998
+++ arla-0.4/lib/roken/resolve.h	Sat Mar 28 19:27:43 1998
@@ -50,7 +50,7 @@
 #define T_AFSDB		18
 #endif
 #ifndef T_SRV
-#define T_SRV		 33
+#define T_SRV		33
 #endif
 
 struct dns_query{
@@ -89,6 +89,7 @@
 };
 
 #ifndef T_A /* XXX if <arpa/nameser.h> isn't included */
+#define T_A 1
 typedef int HEADER; /* will never be used */
 #endif
 
diff -ruN arla-0.4.orig/lib/roken/roken.h arla-0.4/lib/roken/roken.h
--- arla-0.4.orig/lib/roken/roken.h	Fri Mar 27 20:40:19 1998
+++ arla-0.4/lib/roken/roken.h	Sat Mar 28 19:22:05 1998
@@ -70,10 +70,6 @@
 #ifdef HAVE_NETINET6_IN6_H
 #include <netinet6/in6.h>
 #endif
-#ifdef HAVE_WINSOCK_H
-#include <winsock.h>
-#endif
-
 
 #ifdef HAVE_FCNTL_H
 #include <fcntl.h>
diff -ruN arla-0.4.orig/lib/roken/sendmsg.c arla-0.4/lib/roken/sendmsg.c
--- arla-0.4.orig/lib/roken/sendmsg.c	Wed Dec 31 19:00:00 1969
+++ arla-0.4/lib/roken/sendmsg.c	Sat Mar 28 15:54:25 1998
@@ -0,0 +1,72 @@
+/*
+ * Copyright (c) 1995, 1996, 1997 Kungliga Tekniska Hvgskolan
+ * (Royal Institute of Technology, Stockholm, Sweden).
+ * All rights reserved.
+ * 
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *      This product includes software developed by the Kungliga Tekniska
+ *      Hvgskolan and its contributors.
+ * 
+ * 4. Neither the name of the Institute nor the names of its contributors
+ *    may be used to endorse or promote products derived from this software
+ *    without specific prior written permission.
+ * 
+ * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED.  IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+RCSID("$Id: $");
+#endif
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/uio.h>
+#include <stdlib.h>
+#include <string.h>
+
+int
+sendmsg(int s, const struct msghdr *msg, int flags)
+{
+  void *buf, *bp;
+  int i, size, sent;
+
+  for (i = size = 0; i < msg->msg_iovlen; i++)
+    size += msg->msg_iov[i].iov_len;
+
+  buf = malloc(size);
+  if (!buf)
+    return -1;
+
+  for (i = 0, bp = buf; i < msg->msg_iovlen; i++)
+    {
+      memcpy(bp, msg->msg_iov[i].iov_base, msg->msg_iov[i].iov_len);
+      bp += msg->msg_iov[i].iov_len;
+    }
+
+  sent = sendto(s, buf, size, flags, msg->msg_name, msg->msg_namelen);
+  free(buf);
+  return sent;
+}
diff -ruN arla-0.4.orig/rx/rx_mach.h arla-0.4/rx/rx_mach.h
--- arla-0.4.orig/rx/rx_mach.h	Fri Mar 27 20:40:35 1998
+++ arla-0.4/rx/rx_mach.h	Sat Mar 28 19:24:35 1998
@@ -41,7 +41,9 @@
 #define	ADAPT_PERF
 #ifndef	AFS_SUN5_ENV
 #define MISCMTU
+#ifndef __CYGWIN32__	/* cygwin32-b19 doesn't have SIOCGIFCONF */
 #define ADAPT_MTU
+#endif
 #endif
 #endif
 





More information about the Arla-drinkers mailing list