summaryrefslogtreecommitdiffstats
path: root/support/include/ha-callout.h
diff options
context:
space:
mode:
authorneilbrown <neilbrown>2004-09-06 02:15:04 +0000
committerneilbrown <neilbrown>2004-09-06 02:15:04 +0000
commitaf93e0306d87bba3f703386fd6390e9bf8e76816 (patch)
treeec1caa91d3ccb07af6bd36ff583148390e56ea1d /support/include/ha-callout.h
parent2c91715a9c8dbf18df1666f70e78d6e36e123ca0 (diff)
downloadnfs-utils-af93e0306d87bba3f703386fd6390e9bf8e76816.tar.gz
nfs-utils-af93e0306d87bba3f703386fd6390e9bf8e76816.tar.xz
nfs-utils-af93e0306d87bba3f703386fd6390e9bf8e76816.zip
Support --ha-callout for high-availability callouts
Diffstat (limited to 'support/include/ha-callout.h')
-rw-r--r--support/include/ha-callout.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/support/include/ha-callout.h b/support/include/ha-callout.h
new file mode 100644
index 0000000..707d51b
--- /dev/null
+++ b/support/include/ha-callout.h
@@ -0,0 +1,52 @@
+/*
+ * support/include/ha-callout.h
+ *
+ * High Availability NFS Callout support routines
+ *
+ * Copyright (c) 2004, Paul Clements, SteelEye Technology
+ *
+ * In order to implement HA NFS, we need several callouts at key
+ * points in statd and mountd. These callouts all come to ha_callout(),
+ * which, in turn, calls out to an ha-callout script (not part of nfs-utils;
+ * defined by -H argument to rpc.statd and rpc.mountd).
+ */
+#ifndef HA_CALLOUT_H
+#define HA_CALLOUT_H
+
+#include <sys/wait.h>
+
+extern char *ha_callout_prog;
+
+static inline void
+ha_callout(char *event, char *arg1, char *arg2, int arg3)
+{
+ char buf[16]; /* should be plenty */
+ pid_t pid;
+ int ret = -1;
+
+ if (!ha_callout_prog) /* HA callout is not enabled */
+ return;
+
+ sprintf(buf, "%d", arg3);
+
+ pid = fork();
+ switch (pid) {
+ case 0: execl(ha_callout_prog, ha_callout_prog,
+ event, arg1, arg2,
+ arg3 < 0 ? NULL : buf,
+ NULL);
+ perror("execl");
+ exit(2);
+ case -1: perror("fork");
+ break;
+ default: ret = waitpid(pid, NULL, 0);
+ }
+
+#ifdef dprintf
+ dprintf(N_DEBUG, "ha callout returned %d\n", WEXITSTATUS(ret));
+#else
+ xlog(D_GENERAL, "ha callout returned %d\n", WEXITSTATUS(ret));
+#endif
+}
+
+#endif