-SUBDIRS = mount nfs nlm portmap rquota lib include . $(MAYBE_EXAMPLES)
+SUBDIRS = mount nfs nlm nsm portmap rquota lib include . $(MAYBE_EXAMPLES)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = libnfs.pc
[mount/Makefile]
[nfs/Makefile]
[nlm/Makefile]
+ [nsm/Makefile]
[portmap/Makefile]
[rquota/Makefile]
[examples/Makefile]
${abs_top_srcdir}/portmap/libnfs-raw-portmap.h \
${abs_top_srcdir}/nfs/libnfs-raw-nfs.h \
${abs_top_srcdir}/nlm/libnfs-raw-nlm.h \
+ ${abs_top_srcdir}/nsm/libnfs-raw-nsm.h \
${abs_top_srcdir}/rquota/libnfs-raw-rquota.h
struct NLM4_UNLOCKargs;
int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCKargs *args, void *private_data);
+/*
+ * NSM functions
+ */
+char *nsmstat1_to_str(int stat);
+
+/*
+ * Call NSM/NULL
+ * Call the NULL procedure for the NSM protocol
+ *
+ * Function returns
+ * 0 : The call was initiated. The callback will be invoked when the call completes.
+ * <0 : An error occured when trying to set up the call. The callback will not be invoked.
+ *
+ * When the callback is invoked, status indicates the result:
+ * RPC_STATUS_SUCCESS : We got a successful response from the nsm daemon.
+ * data is NULL
+ * RPC_STATUS_ERROR : An error occured when trying to contact the nsm daemon.
+ * data is the error string.
+ * RPC_STATUS_CANCEL : The connection attempt was aborted before it could complete.
+ * data is NULL.
+ */
+int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data);
+
+
#endif
-I../mount \
-I../nfs \
-I../nlm \
+ -I../nsm \
-I../portmap \
-I../rquota \
"-D_U_=__attribute__((unused))"
../mount/libmount.la \
../nfs/libnfs.la \
../nlm/libnlm.la \
+ ../nsm/libnsm.la \
../portmap/libportmap.la \
../rquota/librquota.la
--- /dev/null
+noinst_LTLIBRARIES = libnsm.la
+
+nsm_SOURCES_GENERATED =
+nsm_HEADERS_GENERATED =
+nsm_GENERATED = $(nsm_SOURCES_GENERATED) $(nsm_HEADERS_GENERATED)
+
+CLEANFILES = $(nsm_GENERATED) nsm-stamp
+
+libnsm_la_CPPFLAGS = -I$(abs_top_srcdir)/include \
+ -I$(abs_top_srcdir)/include/nfsc
+libnsm_la_SOURCES = \
+ $(nsm_SOURCES_GENERATED) \
+ nsm.c libnfs-raw-nsm.c
+
+$(nsm_GENERATED) : nsm-stamp
+nsm-stamp : nsm.x
+ rm -f $(nsm_GENERATED)
+ touch nsm-stamp
+
+compile_rpc:
+ rpcgen -h nsm.x | sed -e "s/#include <rpc\/rpc.h>//" | sed -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" > libnfs-raw-nsm.h
+ rpcgen -c nsm.x | sed -e "s/#include \".*nsm.h\"/#include \"libnfs-xdr.h\"\n#include \"libnfs-raw-nsm.h\"/" -e "s/xdr/zdr/g" -e "s/XDR/ZDR/g" -e "s/register int32_t \*buf;/register int32_t *buf;\n buf = NULL;/" > libnfs-raw-nsm.c
--- /dev/null
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#include "libnfs-zdr.h"
+#include "libnfs-raw-nsm.h"
+
+bool_t
+zdr_nsm_name (ZDR *zdrs, nsm_name *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_string (zdrs, &objp->mon_name, NSM_MAXSTRLEN))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsmstat1 (ZDR *zdrs, nsmstat1 *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_enum (zdrs, (enum_t *) objp))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_stat_res (ZDR *zdrs, nsm_stat_res *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_nsmstat1 (zdrs, &objp->res))
+ return FALSE;
+ if (!zdr_int (zdrs, &objp->state))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_stat (ZDR *zdrs, nsm_stat *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_int (zdrs, &objp->state))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_my_id (ZDR *zdrs, nsm_my_id *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_string (zdrs, &objp->my_name, NSM_MAXSTRLEN))
+ return FALSE;
+ if (!zdr_int (zdrs, &objp->my_prog))
+ return FALSE;
+ if (!zdr_int (zdrs, &objp->my_vers))
+ return FALSE;
+ if (!zdr_int (zdrs, &objp->my_proc))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_mon_id (ZDR *zdrs, nsm_mon_id *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_string (zdrs, &objp->mon_name, NSM_MAXSTRLEN))
+ return FALSE;
+ if (!zdr_nsm_my_id (zdrs, &objp->my_id))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_mon (ZDR *zdrs, nsm_mon *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ int i;
+ if (!zdr_nsm_mon_id (zdrs, &objp->mon_id))
+ return FALSE;
+ if (!zdr_opaque (zdrs, objp->priv, 16))
+ return FALSE;
+ return TRUE;
+}
+
+bool_t
+zdr_nsm_stat_chg (ZDR *zdrs, nsm_stat_chg *objp)
+{
+ register int32_t *buf;
+ buf = NULL;
+
+ if (!zdr_string (zdrs, &objp->mon_name, NSM_MAXSTRLEN))
+ return FALSE;
+ if (!zdr_int (zdrs, &objp->state))
+ return FALSE;
+ return TRUE;
+}
--- /dev/null
+/*
+ * Please do not edit this file.
+ * It was generated using rpcgen.
+ */
+
+#ifndef _NSM_H_RPCGEN
+#define _NSM_H_RPCGEN
+
+
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define NSM_MAXSTRLEN 1024
+
+struct nsm_name {
+ char *mon_name;
+};
+typedef struct nsm_name nsm_name;
+
+enum nsmstat1 {
+ NSM_STAT_SUCC = 0,
+ NSM_STAT_FAIL = 1,
+};
+typedef enum nsmstat1 nsmstat1;
+
+struct nsm_stat_res {
+ nsmstat1 res;
+ int state;
+};
+typedef struct nsm_stat_res nsm_stat_res;
+
+struct nsm_stat {
+ int state;
+};
+typedef struct nsm_stat nsm_stat;
+
+struct nsm_my_id {
+ char *my_name;
+ int my_prog;
+ int my_vers;
+ int my_proc;
+};
+typedef struct nsm_my_id nsm_my_id;
+
+struct nsm_mon_id {
+ char *mon_name;
+ struct nsm_my_id my_id;
+};
+typedef struct nsm_mon_id nsm_mon_id;
+
+struct nsm_mon {
+ struct nsm_mon_id mon_id;
+ char priv[16];
+};
+typedef struct nsm_mon nsm_mon;
+
+struct nsm_stat_chg {
+ char *mon_name;
+ int state;
+};
+typedef struct nsm_stat_chg nsm_stat_chg;
+
+#define NSM_PROGRAM 100024
+#define NSM_V1 1
+
+#if defined(__STDC__) || defined(__cplusplus)
+#define NSM1_NULL 0
+extern void * nsm1_null_1(void *, CLIENT *);
+extern void * nsm1_null_1_svc(void *, struct svc_req *);
+#define NSM1_STAT 1
+extern struct nsm_stat_res * nsm1_stat_1(struct nsm_name *, CLIENT *);
+extern struct nsm_stat_res * nsm1_stat_1_svc(struct nsm_name *, struct svc_req *);
+#define NSM1_MON 2
+extern struct nsm_stat_res * nsm1_mon_1(struct nsm_mon *, CLIENT *);
+extern struct nsm_stat_res * nsm1_mon_1_svc(struct nsm_mon *, struct svc_req *);
+#define NSM1_UNMON 3
+extern struct nsm_stat * nsm1_unmon_1(struct nsm_mon_id *, CLIENT *);
+extern struct nsm_stat * nsm1_unmon_1_svc(struct nsm_mon_id *, struct svc_req *);
+#define NSM1_UNMON_ALL 4
+extern struct nsm_stat * nsm1_unmon_all_1(struct nsm_my_id *, CLIENT *);
+extern struct nsm_stat * nsm1_unmon_all_1_svc(struct nsm_my_id *, struct svc_req *);
+#define NSM1_SIMU_CRASH 5
+extern void * nsm1_simu_crash_1(void *, CLIENT *);
+extern void * nsm1_simu_crash_1_svc(void *, struct svc_req *);
+#define NSM1_NOTIFY 6
+extern void * nsm1_notify_1(struct nsm_stat_chg *, CLIENT *);
+extern void * nsm1_notify_1_svc(struct nsm_stat_chg *, struct svc_req *);
+extern int nsm_program_1_freeresult (SVCXPRT *, zdrproc_t, caddr_t);
+
+#else /* K&R C */
+#define NSM1_NULL 0
+extern void * nsm1_null_1();
+extern void * nsm1_null_1_svc();
+#define NSM1_STAT 1
+extern struct nsm_stat_res * nsm1_stat_1();
+extern struct nsm_stat_res * nsm1_stat_1_svc();
+#define NSM1_MON 2
+extern struct nsm_stat_res * nsm1_mon_1();
+extern struct nsm_stat_res * nsm1_mon_1_svc();
+#define NSM1_UNMON 3
+extern struct nsm_stat * nsm1_unmon_1();
+extern struct nsm_stat * nsm1_unmon_1_svc();
+#define NSM1_UNMON_ALL 4
+extern struct nsm_stat * nsm1_unmon_all_1();
+extern struct nsm_stat * nsm1_unmon_all_1_svc();
+#define NSM1_SIMU_CRASH 5
+extern void * nsm1_simu_crash_1();
+extern void * nsm1_simu_crash_1_svc();
+#define NSM1_NOTIFY 6
+extern void * nsm1_notify_1();
+extern void * nsm1_notify_1_svc();
+extern int nsm_program_1_freeresult ();
+#endif /* K&R C */
+
+/* the zdr functions */
+
+#if defined(__STDC__) || defined(__cplusplus)
+extern bool_t zdr_nsm_name (ZDR *, nsm_name*);
+extern bool_t zdr_nsmstat1 (ZDR *, nsmstat1*);
+extern bool_t zdr_nsm_stat_res (ZDR *, nsm_stat_res*);
+extern bool_t zdr_nsm_stat (ZDR *, nsm_stat*);
+extern bool_t zdr_nsm_my_id (ZDR *, nsm_my_id*);
+extern bool_t zdr_nsm_mon_id (ZDR *, nsm_mon_id*);
+extern bool_t zdr_nsm_mon (ZDR *, nsm_mon*);
+extern bool_t zdr_nsm_stat_chg (ZDR *, nsm_stat_chg*);
+
+#else /* K&R C */
+extern bool_t zdr_nsm_name ();
+extern bool_t zdr_nsmstat1 ();
+extern bool_t zdr_nsm_stat_res ();
+extern bool_t zdr_nsm_stat ();
+extern bool_t zdr_nsm_my_id ();
+extern bool_t zdr_nsm_mon_id ();
+extern bool_t zdr_nsm_mon ();
+extern bool_t zdr_nsm_stat_chg ();
+
+#endif /* K&R C */
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* !_NSM_H_RPCGEN */
--- /dev/null
+/*
+ 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 WIN32
+#include "win32_compat.h"
+#endif/*WIN32*/
+
+#include <stdio.h>
+#include <errno.h>
+#include "libnfs-zdr.h"
+#include "libnfs.h"
+#include "libnfs-raw.h"
+#include "libnfs-private.h"
+#include "libnfs-raw-nsm.h"
+
+int rpc_nsm1_null_async(struct rpc_context *rpc, rpc_cb cb, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NSM_PROGRAM, NSM_V1, NSM1_NULL, cb, private_data, (zdrproc_t)zdr_void, 0);
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nsm/null call");
+ return -1;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nsm/null call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+
+#if 0
+int rpc_nlm4_test_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_TESTargs *args, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_TEST, cb, private_data, (zdrproc_t)zdr_NLM4_TESTres, sizeof(NLM4_TESTres));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/test call");
+ return -1;
+ }
+
+ if (zdr_NLM4_TESTargs(&pdu->zdr, args) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_TESTargs");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nlm/test call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_nlm4_lock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_LOCKargs *args, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_LOCK, cb, private_data, (zdrproc_t)zdr_NLM4_LOCKres, sizeof(NLM4_LOCKres));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/lock call");
+ return -1;
+ }
+
+ if (zdr_NLM4_LOCKargs(&pdu->zdr, args) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_LOCKargs");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nlm/lock call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_nlm4_cancel_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_CANCargs *args, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_CANCEL, cb, private_data, (zdrproc_t)zdr_NLM4_CANCres, sizeof(NLM4_CANCres));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/cancel call");
+ return -1;
+ }
+
+ if (zdr_NLM4_CANCargs(&pdu->zdr, args) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_CANCargs");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nlm/cancel call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+
+int rpc_nlm4_unlock_async(struct rpc_context *rpc, rpc_cb cb, struct NLM4_UNLOCKargs *args, void *private_data)
+{
+ struct rpc_pdu *pdu;
+
+ pdu = rpc_allocate_pdu(rpc, NLM_PROGRAM, NLM_V4, NLM4_UNLOCK, cb, private_data, (zdrproc_t)zdr_NLM4_UNLOCKres, sizeof(NLM4_UNLOCKres));
+ if (pdu == NULL) {
+ rpc_set_error(rpc, "Out of memory. Failed to allocate pdu for nlm/unlock call");
+ return -1;
+ }
+
+ if (zdr_NLM4_UNLOCKargs(&pdu->zdr, args) == 0) {
+ rpc_set_error(rpc, "ZDR error: Failed to encode NLM4_UNLOCKargs");
+ rpc_free_pdu(rpc, pdu);
+ return -2;
+ }
+
+ if (rpc_queue_pdu(rpc, pdu) != 0) {
+ rpc_set_error(rpc, "Out of memory. Failed to queue pdu for nlm/unlock call");
+ rpc_free_pdu(rpc, pdu);
+ return -1;
+ }
+
+ return 0;
+}
+#endif
+
+char *nsmstat1_to_str(int st)
+{
+ enum nsmstat1 stat = st;
+
+ char *str = "unknown n1m stat";
+ switch (stat) {
+ case NSM_STAT_SUCC: str="NSM_STAT_SUCC";break;
+ case NSM_STAT_FAIL: str="NSM_STAT_FAIL";break;
+ }
+ return str;
+}
--- /dev/null
+/*
+ * NSM definitions from:
+ * Protocols for Interworking: XNFS, Version 3W
+ * http://pubs.opengroup.org/onlinepubs/9629799/chap11.htm
+ *
+ * Symbols then massaged to avoid too much namespace pollution
+ * and to bring more inline with convention in nlm.
+ */
+
+/*
+ * This defines the maximum length of the string
+ * identifying the caller.
+ */
+const NSM_MAXSTRLEN = 1024;
+
+struct nsm_name {
+ string mon_name<NSM_MAXSTRLEN>;
+};
+
+enum nsmstat1 {
+ NSM_STAT_SUCC = 0, /* NSM agrees to monitor. */
+ NSM_STAT_FAIL = 1 /* NSM cannot monitor. */
+};
+
+struct nsm_stat_res {
+ nsmstat1 res;
+ int state;
+};
+
+struct nsm_stat {
+ int state; /* state number of NSM */
+};
+
+struct nsm_my_id {
+ string my_name<NSM_MAXSTRLEN>; /* hostname */
+ int my_prog; /* RPC program number */
+ int my_vers; /* program version number */
+ int my_proc; /* procedure number */
+};
+
+struct nsm_mon_id {
+ string mon_name<NSM_MAXSTRLEN>; /* name of the host to be monitored */
+ struct nsm_my_id my_id;
+};
+
+struct nsm_mon {
+ struct nsm_mon_id mon_id;
+ opaque priv[16]; /* private information */
+};
+
+struct nsm_stat_chg {
+ string mon_name<NSM_MAXSTRLEN>;
+ int state;
+};
+
+/*
+ * Protocol description for the NSM program.
+ */
+program NSM_PROGRAM {
+ version NSM_V1 {
+ void NSM1_NULL(void) = 0;
+ struct nsm_stat_res NSM1_STAT(struct nsm_name) = 1;
+ struct nsm_stat_res NSM1_MON(struct nsm_mon) = 2;
+ struct nsm_stat NSM1_UNMON(struct nsm_mon_id) = 3;
+ struct nsm_stat NSM1_UNMON_ALL(struct nsm_my_id) = 4;
+ void NSM1_SIMU_CRASH(void) = 5;
+ void NSM1_NOTIFY(struct nsm_stat_chg) = 6;
+ } = 1;
+} = 100024;
+
+