tests/bin/ctdb_takeover_tests tests/bin/ctdb_update_record \
tests/bin/ctdb_update_record_persistent \
tests/bin/ctdb_tool_libctdb tests/bin/ctdb_tool_stubby \
- tests/bin/ctdb_porting_tests \
+ tests/bin/ctdb_porting_tests tests/bin/ctdb_lock_tdb \
@INFINIBAND_BINS@
BINS = bin/ctdb @CTDB_SCSI_IO@ bin/smnotify bin/ping_pong bin/ltdbtool \
@echo Linking $@
$(WRAPPER) $(CC) $(CFLAGS) -o $@ tests/src/ctdb_tool_stubby.o $(CTDB_TEST_OBJ) $(POPT_OBJ) $(LIB_FLAGS)
+tests/bin/ctdb_lock_tdb: tests/src/ctdb_lock_tdb.o @TDB_OBJ@
+ @echo Linking $@
+ $(WRAPPER) $(CC) $(CFLAGS) -o $@ $^ $(LIB_FLAGS)
+
tests/bin/ibwrapper_test: $(CTDB_CLIENT_OBJ) ib/ibwrapper_test.o
@echo Linking $@
$(WRAPPER) $(CC) $(CFLAGS) -o $@ ib/ibwrapper_test.o $(CTDB_CLIENT_OBJ) $(LIB_FLAGS)
--- /dev/null
+#include <stdio.h>
+#include <fcntl.h>
+
+#include "includes.h"
+
+const char *tdb_file;
+TDB_CONTEXT *tdb;
+
+void signal_handler(int signum)
+{
+ tdb_close(tdb);
+}
+
+
+int
+main(int argc, char *argv[])
+{
+ if (argc != 2) {
+ printf("Usage: %s <tdb file>\n", argv[0]);
+ exit(1);
+ }
+
+ tdb_file = argv[1];
+
+ tdb = tdb_open(tdb_file, 0, 0, O_RDWR, 0);
+ if (tdb == NULL) {
+ fprintf(stderr, "Failed to open TDB file %s\n", tdb_file);
+ exit(1);
+ }
+
+ signal(SIGINT, signal_handler);
+
+ if (tdb_lockall(tdb) != 0) {
+ fprintf(stderr, "Failed to lock database %s\n", tdb_file);
+ tdb_close(tdb);
+ exit(1);
+ }
+
+ sleep(999999);
+
+ return 0;
+}