NFSv4 support
authorChristos Zoulas <christos@zoulas.com>
Thu, 6 Oct 2011 14:49:33 +0000 (10:49 -0400)
committerChristos Zoulas <christos@zoulas.com>
Thu, 6 Oct 2011 14:49:33 +0000 (10:49 -0400)
cleanup strdup -> xstrdup

include/am_compat.h
include/am_defs.h
include/am_utils.h
include/nfs_common.h [new file with mode: 0644]

index e1b26b94dfaa691d79da2bd01e14f1738b3625e3..87346a059ec2fd324dc91e43b1deec5c631eef0f 100644 (file)
@@ -433,6 +433,14 @@ struct hsfs_args {
 # endif /* not MNTTAB_OPT_PROTO */
 #endif /* not HAVE_FS_NFS3 */
 
+/*
+ * If NFS4, then make sure that the "sec" mnttab option is available.
+ */
+#ifdef HAVE_FS_NFS4
+# ifndef MNTTAB_OPT_SEC
+#  define MNTTAB_OPT_SEC "sec"
+# endif /* not MNTTAB_OPT_SEC */
+#endif /* not HAVE_FS_NFS4 */
 /*
  * If loop device (header file) exists, define mount table option
  */
index e911f4d9174dca870163d54049d18b8d3f3c1f84..d04bdf5cac47a3dfe6cabe04e8ef6fb427314ad9 100644 (file)
@@ -65,7 +65,7 @@
 #  define strchr index
 #  define strrchr rindex
 # endif /* not HAVE_STRCHR */
-char *strchr(), *strrchr(), *strdup();
+char *strchr(), *strrchr();
 #endif /* not STDC_HEADERS */
 
 /*
@@ -1534,14 +1534,6 @@ extern unsigned int sleep(unsigned int seconds);
 extern int strcasecmp(const char *s1, const char *s2);
 #endif /* not HAVE_EXTERN_STRCASECMP */
 
-#ifndef HAVE_EXTERN_STRDUP
-/*
- * define this extern even if function does not exist, for it will
- * be filled in by libamu/strdup.c
- */
-extern char *strdup(const char *s);
-#endif /* not HAVE_EXTERN_STRDUP */
-
 #ifndef HAVE_EXTERN_STRLCAT
 /*
  * define this extern even if function does not exist, for it will
index fa7882c4f296c30af059f77fd41a45df0a0bab18..f67a84a6db36deb8498b674449e3ec95e11ea760 100644 (file)
@@ -330,6 +330,7 @@ extern void unregister_amq(void);
 extern voidp xmalloc(int);
 extern voidp xrealloc(voidp, int);
 extern voidp xzalloc(int);
+extern char *xstrdup(const char *);
 extern int check_pmap_up(char *host, struct sockaddr_in* sin);
 extern u_long get_nfs_version(char *host, struct sockaddr_in *sin, u_long nfs_version, const char *proto);
 extern long get_server_pid(void);
@@ -371,7 +372,8 @@ extern void write_mntent(mntent_t *, const char *);
 extern int syslogging;
 #endif /* defined(HAVE_SYSLOG_H) || defined(HAVE_SYS_SYSLOG_H) */
 
-extern void compute_nfs_args(nfs_args_t *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name);
+extern void compute_nfs_args(void *nap, mntent_t *mntp, int genflags, struct netconfig *nfsncp, struct sockaddr_in *ip_addr, u_long nfs_version, char *nfs_proto, am_nfs_handle_t *fhp, char *host_name, char *fs_name);
+extern void destroy_nfs_args(void *nap, u_long nfs_version);
 extern int create_amq_service(int *udp_soAMQp, SVCXPRT **udp_amqpp, struct netconfig **udp_amqncpp, int *tcp_soAMQp, SVCXPRT **tcp_amqpp, struct netconfig **tcp_amqncpp, u_short preferred_amq_port);
 extern int create_nfs_service(int *soNFSp, u_short *nfs_portp, SVCXPRT **nfs_xprtp, void (*dispatch_fxn)(struct svc_req *rqstp, SVCXPRT *transp));
 extern int amu_svc_register(SVCXPRT *, u_long, u_long, void (*)(struct svc_req *, SVCXPRT *), u_long, struct netconfig *);
@@ -396,8 +398,14 @@ extern int unregister_autofs_service(char *autofs_conftype);
 
 
 /*
- * Network File System: the new generation
- * NFS V.3
+ * Network File System: the old faithful generation NFS V.2
+ */
+#ifndef NFS_VERSION2
+# define NFS_VERSION2 ((u_int) 2)
+#endif /* not NFS_VERSION2 */
+
+/*
+ * Network File System: the not so new anymore generation NFS V.3
  */
 #ifdef HAVE_FS_NFS3
 # ifndef NFS_VERSION3
@@ -405,6 +413,14 @@ extern int unregister_autofs_service(char *autofs_conftype);
 # endif /* not NFS_VERSION3 */
 #endif /* HAVE_FS_NFS3 */
 
+/*
+ * Network File System: the new generation NFS V.4
+ */
+#ifdef HAVE_FS_NFS4
+# ifndef NFS_VERSION4
+#  define NFS_VERSION4 ((u_int) 4)
+# endif /* not NFS_VERSION4 */
+#endif /* HAVE_FS_NFS4 */
 
 /**************************************************************************/
 /*** DEBUGGING                                                         ***/
@@ -466,7 +482,7 @@ extern void malloc_verify(void);
 # endif /* not DEBUG_MEM */
 
 /* functions that depend solely on debugging */
-extern void print_nfs_args(const nfs_args_t *nap, u_long nfs_version);
+extern void print_nfs_args(const void *, u_long nfs_version);
 extern int debug_option (char *opt);
 extern void dplog(const char *fmt, ...)
      __attribute__ ((__format__ (__printf__, 1, 2)));
diff --git a/include/nfs_common.h b/include/nfs_common.h
new file mode 100644 (file)
index 0000000..544e93c
--- /dev/null
@@ -0,0 +1,103 @@
+/*
+ * Copyright (c) 2011 Christos Zoulas
+ * 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 acknowledgment:
+ *      This product includes software developed by the University of
+ *      California, Berkeley and its contributors.
+ * 4. Neither the name of the University 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 REGENTS 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 REGENTS 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.
+ *
+ *
+ * File: am-utils/include/nfs_common.c
+ *
+ */
+struct nfs_common_args {
+  u_long flags;
+  u_long acdirmin;
+  u_long acdirmax;
+  u_long acregmin;
+  u_long acregmax;
+  u_long timeo;
+  u_long retrans;
+  u_long rsize;
+  u_long wsize;
+};
+
+#ifdef HAVE_NFS_ARGS_T_ACREGMIN
+#define GET_ACREGMIN(nap, a) nap->acregmin = a.acregmin;
+#define PUT_ACREGMIN(nap, a) a.acregmin = nap->acregmin;
+#else
+#define GET_ACREGMIN(nap, a)
+#define PUT_ACREGMIN(nap, a)
+#endif
+#ifdef HAVE_NFS_ARGS_T_ACREGMAX
+#define GET_ACREGMAX(nap, a) nap->acregmax = a.acregmax;
+#define PUT_ACREGMAX(nap, a) a.acregmax = nap->acregmax;
+#else
+#define GET_ACREGMAX(nap, a)
+#define PUT_ACREGMAX(nap, a)
+#endif
+
+#ifdef HAVE_NFS_ARGS_T_ACDIRMIN
+#define GET_ACDIRMIN(nap, a) nap->acdirmin = a.acdirmin;
+#define PUT_ACDIRMIN(nap, a) a.acdirmin = nap->acdirmin;
+#else
+#define GET_ACDIRMIN(nap, a)
+#define PUT_ACDIRMIN(nap, a)
+#endif
+#ifdef HAVE_NFS_ARGS_T_ACDIRMAX
+#define GET_ACDIRMAX(nap, a) nap->acdirmax = a.acdirmax;
+#define PUT_ACDIRMAX(nap, a) a.acdirmax = nap->acdirmax;
+#else
+#define GET_ACDIRMAX(nap, a)
+#define PUT_ACDIRMAX(nap, a)
+#endif
+
+#define get_nfs_common_args(nap, a) \
+  do { \
+    nap->flags = a.flags; \
+    GET_ACREGMIN(nap, a) \
+    GET_ACREGMAX(nap, a) \
+    GET_ACDIRMIN(nap, a) \
+    GET_ACDIRMAX(nap, a) \
+    nap->timeo = a.timeo; \
+    nap->retrans = a.retrans; \
+    nap->rsize = a.rsize; \
+    nap->wsize = a.wsize; \
+  } while (/*CONSTCOND*/0)
+
+#define put_nfs_common_args(nap, a) \
+  do { \
+    a.flags = nap->flags; \
+    PUT_ACREGMIN(nap, a) \
+    PUT_ACREGMAX(nap, a) \
+    PUT_ACDIRMIN(nap, a) \
+    PUT_ACDIRMAX(nap, a) \
+    a.timeo = nap->timeo; \
+    a.retrans = nap->retrans; \
+    a.rsize = nap->rsize; \
+    a.wsize = nap->wsize; \
+  } while (/*CONSTCOND*/0)