[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Cluster-devel] cluster/group daemon/main.c tool/main.c



CVSROOT:	/cvs/cluster
Module name:	cluster
Branch: 	RHEL50
Changes by:	rpeterso sourceware org	2006-11-20 22:31:52

Modified files:
	group/daemon   : main.c 
	group/tool     : main.c 

Log message:
	Resolves: bz214625: Add group_tool log function to group_tool and
	groupd.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/daemon/main.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.51.4.1&r2=1.51.4.2
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&only_with_tag=RHEL50&r1=1.21&r2=1.21.4.1

--- cluster/group/daemon/main.c	2006/11/15 14:44:12	1.51.4.1
+++ cluster/group/daemon/main.c	2006/11/20 22:31:51	1.51.4.2
@@ -320,6 +320,7 @@
 	DO_GET_GROUPS,
 	DO_GET_GROUP,
 	DO_DUMP,
+	DO_LOG,
 };
 
 int get_action(char *buf)
@@ -367,6 +368,9 @@
 	if (!strncmp(act, "dump", 16))
 		return DO_DUMP;
 
+	if (!strncmp(act, "log", 16))
+		return DO_LOG;
+
 	return -1;
 }
 
@@ -561,6 +565,13 @@
 	return 0;
 }
 
+static int do_log(int fd, const char *comment)
+{
+
+	log_print("%s", comment);
+	return 0;
+}
+
 static void do_send(char *name, int level, int len, char *data)
 {
 	group_t *g;
@@ -655,6 +666,10 @@
 		do_dump(client[ci].fd);
 		break;
 
+	case DO_LOG:
+		do_log(client[ci].fd, &buf[4]);
+		break;
+
 	default:
 		log_print("unknown action %d client %d bytes %d", act, ci, rv);
 		log_print("invalid message: \"%s\"", buf);
--- cluster/group/tool/main.c	2006/10/21 17:15:12	1.21
+++ cluster/group/tool/main.c	2006/11/20 22:31:52	1.21.4.1
@@ -45,6 +45,7 @@
 
 #define OP_LS				1
 #define OP_DUMP				2
+#define OP_LOG				3
 
 static char *prog_name;
 static int operation;
@@ -72,6 +73,8 @@
 	printf("dump gfs           Show debug log from gfs_controld\n");
 	printf("dump plocks <name> Show posix locks for gfs with given name\n");
 	printf("\n");
+	printf("log <comments>     Add information to the groupd log.\n");
+	printf("\n");
 }
 
 static void decode_arguments(int argc, char **argv)
@@ -126,6 +129,10 @@
 			operation = OP_LS;
 			opt_ind = optind + 1;
 			break;
+		} else if (strcmp(argv[optind], "log") == 0) {
+			operation = OP_LOG;
+			opt_ind = optind + 1;
+			break;
 		}
 		optind++;
 	}
@@ -406,6 +413,21 @@
 	return 0;
 }
 
+int do_log(char *comment)
+{
+	char buf[GROUPD_MSGLEN];
+	int fd, rv;
+
+	fd = connect_daemon(GROUPD_SOCK_PATH);
+	if (fd < 0)
+		return fd;
+	memset(buf, 0, sizeof(buf));
+	snprintf(buf, sizeof(buf), "log %s", comment);
+	rv = write(fd, &buf, GROUPD_MSGLEN);
+	close(fd);
+	return rv;
+}
+
 int main(int argc, char **argv)
 {
 	int fd;
@@ -445,6 +467,11 @@
 		if (fd < 0)
 			break;
 		return do_dump(argc, argv, fd);
+
+	case OP_LOG:
+		if (opt_ind && opt_ind < argc) {
+			return do_log(argv[opt_ind]);
+		}
 	}
 
 	return 0;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]