cluster/group daemon/main.c tool/main.c
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: rpeterso at sourceware.org 2006-11-09 15:47:29
Modified files:
group/daemon : main.c
group/tool : main.c
Log message:
This is the fix for Bugzilla Bug 214625: 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&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/group/tool/main.c.diff?cvsroot=cluster&r1=1.21&r2=1.22
group/daemon/main.c +15 -0
@@ -318,6 +318,7 @@DO_GET_GROUPS ,DO_GET_GROUP ,DO_DUMP , + DO_LOG, };int get_action (char *buf)
@@ -365,6 +366,9 @@if (!strncmp (act,"dump" ,16 ))return DO_DUMP ; +if (!strncmp (act,"log" ,16 )) +return DO_LOG ; +return -1 ; }
@@ -559,6 +563,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;
@@ -653,6 +664,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);
group/tool/main.c +27 -0
@@ -45,6 +45,7 @@#define OP_LS 1#define OP_DUMP 2 +#define OP_LOG 3static 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 ;