From: teigland@sourceware.org <teigland@sourceware.org>
To: cluster-devel.redhat.com
Subject: [Cluster-devel] cluster/dlm Makefile tool/Makefile tool/main.c
Date: 18 May 2007 16:39:52 -0000 [thread overview]
Message-ID: <20070518163952.31247.qmail@sourceware.org> (raw)
CVSROOT: /cvs/cluster
Module name: cluster
Changes by: teigland at sourceware.org 2007-05-18 16:39:51
Added files:
dlm : Makefile
dlm/tool : Makefile main.c
Log message:
add dlm_tool, can be used to join/leave lockspace
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/Makefile.diff?cvsroot=cluster&r1=1.8&r2=1.9
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/Makefile.diff?cvsroot=cluster&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/cluster/dlm/tool/main.c.diff?cvsroot=cluster&r1=NONE&r2=1.1
--- cluster/dlm/Makefile 2007/04/30 11:22:05 1.8
+++ cluster/dlm/Makefile 2007/05/18 16:39:49 1.9
@@ -1,9 +1,8 @@
###############################################################################
###############################################################################
##
-## Copyright (C) Sistina Software, Inc. 1997-2003 All rights reserved.
-## Copyright (C) 2004 Red Hat, Inc. All rights reserved.
-##
+## Copyright (C) 2005 Red Hat, Inc. All rights reserved.
+##
## This copyrighted material is made available to anyone wishing to use,
## modify, copy, or redistribute it subject to the terms and conditions
## of the GNU General Public License v.2.
@@ -11,18 +10,10 @@
###############################################################################
###############################################################################
-all:
- ${MAKE} -C lib all
-
-install: all
- ${MAKE} -C lib install
-
-uninstall:
- ${MAKE} -C lib uninstall
-
-clean:
- ${MAKE} -C lib clean
- rm -f *~
+SUBDIRS=lib tool
-distclean: clean
- rm -f make/defines.mk
+%:
+ set -e && \
+ for i in ${SUBDIRS}; do \
+ ${MAKE} -C $$i $@; \
+ done
/cvs/cluster/cluster/dlm/tool/Makefile,v --> standard output
revision 1.1
--- cluster/dlm/tool/Makefile
+++ - 2007-05-18 16:39:52.477544000 +0000
@@ -0,0 +1,39 @@
+###############################################################################
+###############################################################################
+##
+## Copyright (C) 2005 Red Hat, Inc. All rights reserved.
+##
+## This copyrighted material is made available to anyone wishing to use,
+## modify, copy, or redistribute it subject to the terms and conditions
+## of the GNU General Public License v.2.
+##
+###############################################################################
+###############################################################################
+
+include ../../make/defines.mk
+
+TARGET= dlm_tool
+
+OBJS= main.o
+
+CFLAGS += -g
+CFLAGS += -I. -I../lib/
+LDFLAGS += -L../lib -ldlm
+
+all: ${TARGET}
+
+${TARGET}: ${OBJS}
+ $(CC) -o $@ $^ $(LDFLAGS)
+
+%.o: %.c
+ $(CC) $(CFLAGS) -c -o $@ $<
+
+clean:
+ rm -f *.o ${TARGET}
+
+install: all
+ install -d ${sbindir}
+ install ${TARGET} ${sbindir}
+
+uninstall:
+ ${UNINSTALL} ${TARGET} ${sbindir}
/cvs/cluster/cluster/dlm/tool/main.c,v --> standard output
revision 1.1
--- cluster/dlm/tool/main.c
+++ - 2007-05-18 16:39:52.912869000 +0000
@@ -0,0 +1,189 @@
+/******************************************************************************
+*******************************************************************************
+**
+** Copyright (C) 2007 Red Hat, Inc. All rights reserved.
+**
+** This copyrighted material is made available to anyone wishing to use,
+** modify, copy, or redistribute it subject to the terms and conditions
+** of the GNU General Public License v.2.
+**
+*******************************************************************************
+******************************************************************************/
+
+#include <sys/types.h>
+#include <sys/un.h>
+#include <inttypes.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stddef.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <netinet/in.h>
+
+#include "libdlm.h"
+
+#define OPTION_STRING "hVvd:"
+
+#define OP_JOIN 1
+#define OP_LEAVE 2
+#define OP_JOINLEAVE 3
+
+static char *prog_name;
+static char *lsname;
+static int operation;
+static int opt_ind;
+static int verbose;
+static int opt_dir = 0;
+
+static void print_usage(void)
+{
+ printf("Usage:\n");
+ printf("\n");
+ printf("%s [options] [join|leave]\n", prog_name);
+ printf("\n");
+ printf("Options:\n");
+ printf(" -v Verbose output, extra event information\n");
+ printf(" -h Print this help, then exit\n");
+ printf(" -V Print program version information, then exit\n");
+ printf(" -d <n> Resource directory off/on (0/1), default 0\n");
+ printf("\n");
+}
+
+static void decode_arguments(int argc, char **argv)
+{
+ int cont = 1;
+ int optchar;
+
+ while (cont) {
+ optchar = getopt(argc, argv, OPTION_STRING);
+
+ switch (optchar) {
+ case 'v':
+ verbose = 1;
+ break;
+
+ case 'h':
+ print_usage();
+ exit(EXIT_SUCCESS);
+ break;
+
+ case 'd':
+ opt_dir = atoi(optarg);
+ break;
+
+ case 'V':
+ printf("%s (built %s %s)\n",
+ prog_name, __DATE__, __TIME__);
+ /* printf("%s\n", REDHAT_COPYRIGHT); */
+ exit(EXIT_SUCCESS);
+ break;
+
+ case ':':
+ case '?':
+ fprintf(stderr, "Please use '-h' for usage.\n");
+ exit(EXIT_FAILURE);
+ break;
+
+ case EOF:
+ cont = 0;
+ break;
+
+ default:
+ fprintf(stderr, "unknown option: %c\n", optchar);
+ exit(EXIT_FAILURE);
+ break;
+ };
+ }
+
+ while (optind < argc) {
+ if (!strncmp(argv[optind], "join", 4) &&
+ (strlen(argv[optind]) == 4)) {
+ operation = OP_JOIN;
+ opt_ind = optind + 1;
+ break;
+ } else if (!strncmp(argv[optind], "leave", 5) &&
+ (strlen(argv[optind]) == 5)) {
+ operation = OP_LEAVE;
+ opt_ind = optind + 1;
+ break;
+ } else if (!strncmp(argv[optind], "joinleave", 9) &&
+ (strlen(argv[optind]) == 9)) {
+ operation = OP_JOINLEAVE;
+ opt_ind = optind + 1;
+ break;
+ }
+ optind++;
+ }
+
+ if (!operation || !opt_ind) {
+ print_usage();
+ exit(EXIT_FAILURE);
+ }
+
+ lsname = argv[opt_ind];
+}
+
+void do_join(char *name)
+{
+ dlm_lshandle_t *dh;
+
+ printf("Joining lockspace \"%s\"\n", name);
+ fflush(stdout);
+
+ dh = dlm_new_lockspace(name, 0600, DLM_LSFL_NODIR);
+ if (!dh) {
+ fprintf(stderr, "dlm_create_lockspace %s error %lu %d\n",
+ name, (unsigned long) dh, errno);
+ exit(-1);
+ }
+
+ dlm_close_lockspace(dh);
+ /* there's no autofree so the ls should stay around */
+ printf("done\n");
+}
+
+void do_leave(char *name)
+{
+ dlm_lshandle_t *dh;
+
+ printf("Leaving lockspace \"%s\"\n", name);
+ fflush(stdout);
+
+ dh = dlm_open_lockspace(name);
+ if (!dh) {
+ fprintf(stderr, "dlm_open_lockspace %s error %lu %d\n",
+ name, (unsigned long) dh, errno);
+ exit(-1);
+ }
+
+ dlm_release_lockspace(name, dh, 1);
+ printf("done\n");
+}
+
+int main(int argc, char **argv)
+{
+ prog_name = argv[0];
+ decode_arguments(argc, argv);
+ /* check_name(lsname); */
+
+ switch (operation) {
+ case OP_JOIN:
+ do_join(lsname);
+ break;
+
+ case OP_LEAVE:
+ do_leave(lsname);
+ break;
+
+ case OP_JOINLEAVE:
+ do_join(lsname);
+ do_leave(lsname);
+ break;
+ }
+
+ return 0;
+}
+
next reply other threads:[~2007-05-18 16:39 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-05-18 16:39 teigland [this message]
-- strict thread matches above, loose matches on Subject: below --
2007-06-05 18:27 [Cluster-devel] cluster/dlm Makefile tool/Makefile tool/main.c teigland
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070518163952.31247.qmail@sourceware.org \
--to=teigland@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.