static void usage(void)
{
fprintf(stderr, "\n");
- fprintf(stderr, "Usage: %s <log-fd> <ctdbd-pid> <output-fd> RECORD <db-path> <db-key>\n",
+ fprintf(stderr, "Usage: %s <log-fd> <ctdbd-pid> <output-fd> RECORD <db-path> <db-flags> <db-key>\n",
progname);
- fprintf(stderr, " %s <log-fd> <ctdbd-pid> <output-fd> DB <db1-path> [<db2-path> ...]\n",
+ fprintf(stderr, " %s <log-fd> <ctdbd-pid> <output-fd> DB <db1-path> <db1-flags> [<db2-path> <db2-flags>...]\n",
progname);
}
return buffer;
}
-static int lock_record(const char *dbpath, const char *dbkey)
+static int lock_record(const char *dbpath, const char *dbflags, const char *dbkey)
{
TDB_DATA key;
struct tdb_context *tdb;
+ int tdb_flags;
+
+ /* No error checking since CTDB always passes sane values */
+ tdb_flags = strtol(dbflags, NULL, 0);
/* Convert hex key to key */
if (strcmp(dbkey, "NULL") == 0) {
key.dptr = hex_decode_talloc(NULL, dbkey, &key.dsize);
}
- tdb = tdb_open(dbpath, 0, TDB_DEFAULT, O_RDWR, 0600);
+ tdb = tdb_open(dbpath, 0, tdb_flags, O_RDWR, 0600);
if (tdb == NULL) {
fprintf(stderr, "%s: Error opening database %s\n", progname, dbpath);
return 1;
}
-static int lock_db(const char *dbpath)
+static int lock_db(const char *dbpath, const char *dbflags)
{
struct tdb_context *tdb;
+ int tdb_flags;
+
+ /* No error checking since CTDB always passes sane values */
+ tdb_flags = strtol(dbflags, NULL, 0);
- tdb = tdb_open(dbpath, 0, TDB_DEFAULT, O_RDWR, 0600);
+ tdb = tdb_open(dbpath, 0, tdb_flags, O_RDWR, 0600);
if (tdb == NULL) {
fprintf(stderr, "%s: Error opening database %s\n", progname, dbpath);
return 1;
lock_type = argv[4];
if (strcmp(lock_type, "RECORD") == 0) {
- if (argc != 7) {
+ if (argc != 8) {
fprintf(stderr, "%s: Invalid number of arguments (%d)\n",
progname, argc);
usage();
exit(1);
}
- result = lock_record(argv[5], argv[6]);
+ result = lock_record(argv[5], argv[6], argv[7]);
} else if (strcmp(lock_type, "DB") == 0) {
int n;
/* If there are no databases specified, no need for lock */
if (argc > 5) {
- for (n=5; n<argc; n++) {
- result = lock_db(argv[n]);
+ for (n=5; n+1<argc; n+=2) {
+ result = lock_db(argv[n], argv[n+1]);
if (result != 0) {
break;
}