* [Cluster-devel] cluster/fence/agents/manual Makefile ack.c
@ 2007-12-17 20:04 lhh
0 siblings, 0 replies; only message in thread
From: lhh @ 2007-12-17 20:04 UTC (permalink / raw)
To: cluster-devel.redhat.com
CVSROOT: /cvs/cluster
Module name: cluster
Branch: RHEL5
Changes by: lhh at sourceware.org 2007-12-17 20:04:12
Modified files:
fence/agents/manual: Makefile ack.c
Log message:
Fix #418541
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/Makefile.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.7&r2=1.7.2.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/fence/agents/manual/ack.c.diff?cvsroot=cluster&only_with_tag=RHEL5&r1=1.3&r2=1.3.16.1
--- cluster/fence/agents/manual/Makefile 2006/08/11 15:18:08 1.7
+++ cluster/fence/agents/manual/Makefile 2007/12/17 20:04:04 1.7.2.1
@@ -16,7 +16,8 @@
top_srcdir=../..
-INCLUDE= -I${top_srcdir}/include -I${top_srcdir}/config -I${incdir} -I../../../cman/lib -I../../../group/lib
+INCLUDE= -I${top_srcdir}/include -I${top_srcdir}/config -I${incdir} -I../../../cman/lib -I../../../group/lib \
+ -I../../../ccs/lib -I../../fenced
include ${top_srcdir}/make/defines.mk
@@ -31,10 +32,10 @@
$(CC) $(LDFLAGS) -o $@ $^ -lcman
manual.o: manual.c
- $(CC) $(CFLAGS) -c -o $@ $<
+ $(CC) $(CFLAGS) -c -o $@ $<
fence_ack_manual: ack.o
- ${CC} -o $@ $^
+ ${CC} -o $@ $^ ../../../ccs/lib/libccs.a
ack.o: ack.c
$(CC) $(CFLAGS) -c -o $@ $<
--- cluster/fence/agents/manual/Attic/ack.c 2004/11/24 03:46:32 1.3
+++ cluster/fence/agents/manual/Attic/ack.c 2007/12/17 20:04:04 1.3.16.1
@@ -11,6 +11,9 @@
*******************************************************************************
******************************************************************************/
+#include <limits.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
@@ -19,8 +22,9 @@
#include <errno.h>
#include <ctype.h>
#include <sys/ioctl.h>
-#include <sys/types.h>
#include <sys/wait.h>
+#include <ccs.h>
+#include <fd.h>
#include "copyright.cf"
@@ -30,6 +34,7 @@
char fname[256];
int quiet_flag = 0;
int override_flag = 0;
+int emergency_flag = 0;
void print_usage(void)
@@ -43,9 +48,78 @@
" -O override\n"
" -n <nodename> Name of node that was manually fenced\n"
" -s <ip> IP address of machine that was manually fenced (deprecated)\n"
+ " -e Emergency Override (use if fencing has failed)\n"
" -V Version information\n", pname);
}
+int do_emergency_override(char *ipaddr)
+{
+ int fd;
+ int cd, tries = 0, error = 0;
+ char buf[PATH_MAX], path[PATH_MAX], *str = NULL;
+ struct stat st_buf;
+
+ cd = ccs_force_connect(NULL, 1);
+ if (cd >= 0) {
+ memset(buf, 0, sizeof(buf));
+ snprintf(buf, sizeof(buf)-1, "/cluster/fence_daemon/@override_path");
+ error = ccs_get(cd, buf, &str);
+ ccs_disconnect(cd);
+ }
+
+ if (error != 0)
+ str = DEFAULT_OVERRIDE_PATH;
+
+ memset(path, 0, sizeof(path));
+ snprintf(path, sizeof(path)-1, "%s", str);
+
+ if (error == 0)
+ free(str);
+
+ while (1) {
+ if (tries) {
+ if (tries == 1)
+ printf("Waiting for %s to become available...\n", path);
+ sleep(1);
+ }
+ ++tries;
+
+ fd = open(path, O_WRONLY);
+ if (fd < 0) {
+ switch(errno) {
+ case ENOENT:
+ continue;
+ default:
+ perror("open");
+ return 1;
+ }
+ }
+
+ error = fstat(fd, &st_buf);
+ if (error < 0) {
+ close(fd);
+ switch(errno) {
+ case ENOENT:
+ continue;
+ default:
+ perror("fstat");
+ return 1;
+ }
+ }
+
+ if (!S_ISFIFO(st_buf.st_mode)) {
+ printf("WARNING: %s is not a named pipe\n", str);
+ }
+
+ snprintf(buf, sizeof(buf)-1, "%s\n", ipaddr);
+ write(fd, buf, strlen(buf));
+ close(fd);
+ break;
+ }
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
int error, fd;
@@ -58,7 +132,7 @@
pname = argv[0];
- while ((c = getopt(argc, argv, "hOs:n:qV")) != -1)
+ while ((c = getopt(argc, argv, "ehOs:n:qV")) != -1)
{
switch(c)
{
@@ -70,6 +144,10 @@
override_flag = 1;
break;
+ case 'e':
+ emergency_flag = 1;
+ break;
+
case 's':
ipaddr = optarg;
break;
@@ -128,6 +206,10 @@
}
}
+ if (emergency_flag) {
+ return do_emergency_override(ipaddr);
+ }
+
memset(fname, 0, 256);
sprintf(fname, "%s/fence_manual.fifo", FIFO_DIR);
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-12-17 20:04 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-12-17 20:04 [Cluster-devel] cluster/fence/agents/manual Makefile ack.c lhh
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.