Initial AROS support.
authorRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 11 Apr 2013 03:28:40 +0000 (20:28 -0700)
committerRonnie Sahlberg <ronniesahlberg@gmail.com>
Thu, 11 Apr 2013 03:28:40 +0000 (20:28 -0700)
The test app doesnt link yet since we are missing a bunch of symbols

but it is a start

12 files changed:
Makefile.AROS [new file with mode: 0644]
aros/aros_compat.c [new file with mode: 0644]
aros/aros_compat.h [new file with mode: 0644]
configure.ac
include/libnfs-private.h
include/nfsc/libnfs-zdr.h
include/nfsc/libnfs.h
lib/libnfs-sync.c
lib/libnfs-zdr.c
lib/libnfs.c
lib/socket.c
win32/win32_compat.c

diff --git a/Makefile.AROS b/Makefile.AROS
new file mode 100644 (file)
index 0000000..fb0c988
--- /dev/null
@@ -0,0 +1,27 @@
+AR=ar
+CC=gcc
+CFLAGS=-g -O0 -DAROS=1 -D_U_=" " -I. -Iinclude -Iinclude/nfsc -Iaros -Infs -Imount
+
+OBJS=lib/init.o lib/libnfs.o lib/libnfs-sync.o lib/libnfs-zdr.o lib/pdu.o lib/socket.o 
+OBJS+=mount/mount.o mount/libnfs-raw-mount.o 
+OBJS+=nfs/nfs.o nfs/nfsacl.o nfs/libnfs-raw-nfs.o 
+OBJS+=nlm/nlm.o nlm/libnfs-raw-nlm.o 
+OBJS+=portmap/portmap.o portmap/libnfs-raw-portmap.o
+OBJS+=rquota/rquota.o rquota/libnfs-raw-rquota.o
+OBJS+=aros/aros_compat.o
+
+EXAMPLES=examples/nfsclient-listservers
+
+all: lib/libnfs.a $(EXAMPLES)
+
+lib/libnfs.a: $(OBJS)
+       $(AR) cru $@ $(OBJS)
+
+.c.o:
+       echo $(CC) $(CFLAGS) -c -o $@ $<
+       $(CC) $(CFLAGS) -c -o $@ $<
+
+examples/nfsclient-listservers: examples/nfsclient-listservers.c lib/libnfs.a
+
+       $(CC) $(CFLAGS) -o $@ $< lib/libnfs.a
+
diff --git a/aros/aros_compat.c b/aros/aros_compat.c
new file mode 100644 (file)
index 0000000..10f127b
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+   Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU Lesser General Public License as published by
+   the Free Software Foundation; either version 2.1 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public License
+   along with this program; if not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifdef AROS
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include "aros_compat.h"
+
+#undef poll
+
+
+int aros_poll(struct pollfd *fds, unsigned int nfds, int timo)
+{
+  struct timeval timeout, *toptr;
+  fd_set ifds, ofds, efds, *ip, *op;
+  unsigned int i;
+  int  rc;
+
+  // Set up the file-descriptor sets in ifds, ofds and efds. 
+  FD_ZERO(&ifds);
+  FD_ZERO(&ofds);
+  FD_ZERO(&efds);
+  for (i = 0, op = ip = 0; i < nfds; ++i) 
+  {
+    fds[i].revents = 0;
+    if(fds[i].events & (POLLIN|POLLPRI)) 
+    {
+      ip = &ifds;
+      FD_SET(fds[i].fd, ip);
+    }
+    if(fds[i].events & POLLOUT) 
+    {
+      op = &ofds;
+      FD_SET(fds[i].fd, op);
+    }
+    FD_SET(fds[i].fd, &efds);
+  } 
+
+  // Set up the timeval structure for the timeout parameter
+  if(timo < 0) 
+  {
+    toptr = 0;
+  } 
+  else 
+  {
+    toptr = &timeout;
+    timeout.tv_sec = timo / 1000;
+    timeout.tv_usec = (timo - timeout.tv_sec * 1000) * 1000;
+  }
+
+  rc = select(0, ip, op, &efds, toptr);
+
+  if(rc <= 0)
+    return rc;
+
+  if(rc > 0) 
+  {
+    for (i = 0; i < nfds; ++i) 
+    {
+      int fd = fds[i].fd;
+      if(fds[i].events & (POLLIN|POLLPRI) && FD_ISSET(fd, &ifds))
+        fds[i].revents |= POLLIN;
+      if(fds[i].events & POLLOUT && FD_ISSET(fd, &ofds))
+        fds[i].revents |= POLLOUT;
+      if(FD_ISSET(fd, &efds)) // Some error was detected ... should be some way to know.
+        fds[i].revents |= POLLHUP;
+    }
+  }
+  return rc;
+}
+
+#endif
diff --git a/aros/aros_compat.h b/aros/aros_compat.h
new file mode 100644 (file)
index 0000000..f9db059
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef AROS_COMPAT_H
+#define AROS_COMPAT_H
+
+#include <netinet/in.h>
+#include <sys/mount.h>
+
+#define statvfs statfs
+
+#define f_flag    f_flags
+#define f_favail  f_ffree
+/* we dont have these at all */
+#define f_fsid    f_spare[0]
+#define f_frsize  f_spare[0]
+#define f_namemax f_spare[0]
+
+#define POLLIN      0x0001    /* There is data to read */
+#define POLLPRI     0x0002    /* There is urgent data to read */
+#define POLLOUT     0x0004    /* Writing now will not block */
+#define POLLERR     0x0008    /* Error condition */
+#define POLLHUP     0x0010    /* Hung up */
+#define POLLNVAL    0x0020    /* Invalid request: fd not open */
+
+struct pollfd {
+    int fd;           /* file descriptor */
+    short events;     /* requested events */
+    short revents;    /* returned events */
+};
+
+#define poll(x, y, z)        aros_poll(x, y, z)
+
+#endif
index 1183bd25038d43fdf43472899ad0cf84f78becf2..7578ef5d412ccd4653dac3d0408ea3bb4a3bf1d5 100644 (file)
@@ -81,6 +81,10 @@ case $host in
     ;;
 esac
 
+# check for poll.h
+dnl Check for poll.h
+AC_CHECK_HEADERS([poll.h])
+
 # check for SA_LEN
 dnl Check if sockaddr data structure includes a "sa_len"
 AC_CHECK_MEMBER([struct sockaddr.sa_len],
@@ -91,6 +95,16 @@ AC_CHECK_MEMBER([struct sockaddr.sa_len],
 #include <sys/socket.h>
 ])
 
+# check for sockaddr_storage
+dnl Check if sockaddr structure includes a "ss_family"
+AC_CHECK_MEMBER([struct sockaddr_storage.ss_family],
+                [ AC_DEFINE(HAVE_SOCKADDR_STORAGE,1,[Whether we have sockaddr_Storage]) ],
+                [],
+                [
+#include <sys/types.h>
+#include <sys/socket.h>
+])
+
 #output
 AC_CONFIG_FILES([Makefile]
                 [include/Makefile]
index d3cd3ec0b647c862460848c38fa57d4f56494e11..f153e35d9f063ac974bc2f56001e956880e79144 100644 (file)
    You should have received a copy of the GNU Lesser General Public License
    along with this program; if not, see <http://www.gnu.org/licenses/>.
 */
+#ifdef HAVE_CONFIG_H
+#include "config.h"  /* HAVE_SOCKADDR_STORAGE ? */
+#endif
+
 #include <sys/socket.h>  /* struct sockaddr_storage */
 
 #include "libnfs-zdr.h"
 
+#ifndef HAVE_SOCKADDR_STORAGE
+/*
+ * RFC 2553: protocol-independent placeholder for socket addresses
+ */
+#define _SS_MAXSIZE    128
+#define _SS_ALIGNSIZE  (sizeof(double))
+#define _SS_PAD1SIZE   (_SS_ALIGNSIZE - sizeof(unsigned char) * 2)
+#define _SS_PAD2SIZE   (_SS_MAXSIZE - sizeof(unsigned char) * 2 - \
+                               _SS_PAD1SIZE - _SS_ALIGNSIZE)
+
+struct sockaddr_storage {
+#ifdef HAVE_SA_LEN
+       unsigned char ss_len;           /* address length */
+       unsigned char ss_family;        /* address family */
+#else
+       unsigned short ss_family;
+#endif
+       char    __ss_pad1[_SS_PAD1SIZE];
+       double  __ss_align;     /* force desired structure storage alignment */
+       char    __ss_pad2[_SS_PAD2SIZE];
+};
+#endif
+
+
 struct rpc_fragment {
        struct rpc_fragment *next;
        uint64_t size;
index 44f73786c91d97330884ee67fb01f947183eb1ef..55daa1221a7f4430996526afe464781ba55a6f8f 100644 (file)
@@ -26,7 +26,9 @@
  * and slightly modified.
  ************************************************************/
 
+#ifdef HAVE_CONFIG_H
 #include "config.h"
+#endif
 
 #ifndef _LIBNFS_ZDR_H_
 #define _LIBNFS_ZDR_H_
@@ -58,8 +60,12 @@ typedef void SVCXPRT;
 #define IZDR_PUT_BOOL(...)             assert(0)
 #define IZDR_GET_BOOL(...)             (assert(0), 0)
 
+#ifndef TRUE
 #define TRUE           1
+#endif
+#ifndef FALSE
 #define FALSE          0
+#endif
 
 enum zdr_op {
        ZDR_ENCODE = 0,
@@ -178,8 +184,8 @@ struct rejected_reply {
        enum reject_stat stat;
        union {
                struct {
-                       u_long low;
-                       u_long high;
+                       uint32_t low;
+                       uint32_t high;
                } mismatch_info;
                enum auth_stat stat;
        } reject_data;
index 75613d701bf67b034c563d0c1f7cce0ecc310e74..094de3c27027bad8280853d924f6a2a1fd3aed9b 100644 (file)
@@ -21,6 +21,9 @@
 #if defined(ANDROID)
 #include <sys/time.h>
 #endif
+#if defined(AROS)
+#include <sys/time.h>
+#endif
 
 struct nfs_context;
 struct rpc_context;
index fd6f796e3f830a869fc0b6c8f849e4de1e8a7a57..2fe5ed5a5886a78ab0050a3af02ddb6ff0c98d37 100644 (file)
 #ifdef WIN32
 #include "win32_compat.h"
 #define DllExport
+#define HAVE_POLL_H
 #else
 #include <strings.h>
 #include <unistd.h>
-#ifndef ANDROID
-#include <sys/statvfs.h>
-#else
-#include <netinet/in.h>
-#include <sys/vfs.h>
-#define statvfs statfs
-#endif
-#include <poll.h>
 #include <sys/ioctl.h>
 #include <netdb.h>
 #include <sys/socket.h>
 #include <net/if.h>
-#endif
+
+#ifdef AROS
+#include "aros_compat.h"
+#else
+#ifdef ANDROID
+#include <netinet/in.h>
+#include <sys/vfs.h>
+#define statvfs statfs
+#else
+#include <sys/statvfs.h>
+#endif /*ANDRIOD*/
+#endif /*AROS*/
+#endif /*WIN32*/
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
 
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
index a243d1d1a7447b5a4ffc5169d60df6128ca7beb4..24bf6c2bc38cf9d73d1cf24095e731794f32d534 100644 (file)
@@ -23,6 +23,7 @@
 #ifdef WIN32
 #include "win32_compat.h"
 #else
+#include <sys/types.h>
 #include <arpa/inet.h>
 #endif/*WIN32*/
 
index deab4f1c1036ef1e1584ea904d3f2cd28214c6a3..cd5a629805dfd3b3cd18b3952033562b7bbeedc6 100644 (file)
 #include "win32_compat.h"
 #define DllExport
 #else
+
 #include <strings.h>
-#ifndef ANDROID
-#include <sys/statvfs.h>
+#include <utime.h>
+#include <unistd.h>
+
+#ifdef AROS
+#include "aros_compat.h"
 #else
+#ifdef ANDROID
 #include <sys/vfs.h>
 #define statvfs statfs
-#endif
-#include <utime.h>
-#include <unistd.h>
-#endif/*WIN32*/
+#else
+#include <sys/statvfs.h>
+#endif /*ANDROID*/
+#endif /*AROS*/
+#endif /*WIN32*/
 
 #define _GNU_SOURCE
 
index 83ca50e1765ad365a6f67650edcb01119a133bea..1dbbdeae5eb5c21758f5e1c7789765f706706d71 100644 (file)
@@ -18,7 +18,6 @@
 #include "win32_compat.h"
 #else
 #include <unistd.h>
-#include <poll.h>
 #include <arpa/inet.h>
 #include <sys/ioctl.h>
 #include <sys/socket.h>
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
+
+#ifdef AROS
+#include "aros_compat.h"
+#endif
+
+#ifdef HAVE_POLL_H
+#include <poll.h>
+#endif
+
 #include <stdio.h>
 #include <stdlib.h>
 #include <assert.h>
index fe2ca05762b7e685a17c3bdf7d7d416be6a7850f..87f9ab1a189c7a5bd27c1b323bf4f54f521f26a4 100644 (file)
@@ -29,7 +29,7 @@ static int dummy ATTRIBUTE((unused));
 #include "win32_compat.h"
 #include <errno.h>
 #include <stdio.h>
-#include < time.h >
+#include <time.h>
 
 #undef poll
 #undef socket