]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
- use separate directories for the tdb files by default
authorAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 23:58:23 +0000 (09:58 +1000)
committerAndrew Tridgell <tridge@samba.org>
Wed, 18 Apr 2007 23:58:23 +0000 (09:58 +1000)
- use TDB_CLEAR_IF_FIRST to ensure we don't use an old tdb
(This used to be ctdb commit ac47d7b4eb79597da1358da21f10e634cdc9dd2e)

ctdb/common/cmdline.c
ctdb/common/ctdb_ltdb.c

index 4995cc8de131dd88a40d1916cefd9fcd1973a0e4..07a19cedc57c7501a09c72e1cb382e87e5eaf5c4 100644 (file)
@@ -37,7 +37,7 @@ static struct {
        .transport = "tcp",
        .myaddress = NULL,
        .self_connect = 0,
-       .db_dir = "."
+       .db_dir = NULL
 };
 
 
index 63a1e22d496edd53ff63e9040a93616151665f2b..7fb0fe557941d12c281cc80152b8c9f84aa42138 100644 (file)
@@ -82,6 +82,13 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
                }
        }
 
+       if (mkdir(ctdb->db_directory, 0700) == -1 && errno != EEXIST) {
+               DEBUG(0,(__location__ " Unable to create ctdb directory '%s'\n", 
+                        ctdb->db_directory));
+               talloc_free(ctdb_db);
+               return NULL;
+       }
+
        /* add the node id to the database name, so when we run on loopback
           we don't conflict in the local filesystem */
        name = talloc_asprintf(ctdb_db, "%s/%s", ctdb->db_directory, name);
@@ -89,7 +96,7 @@ struct ctdb_db_context *ctdb_attach(struct ctdb_context *ctdb, const char *name,
        /* when we have a separate daemon this will need to be a real
           file, not a TDB_INTERNAL, so the parent can access it to
           for ltdb bypass */
-       ctdb_db->ltdb = tdb_wrap_open(ctdb, name, 0, TDB_DEFAULT, open_flags, mode);
+       ctdb_db->ltdb = tdb_wrap_open(ctdb, name, 0, TDB_CLEAR_IF_FIRST, open_flags, mode);
        if (ctdb_db->ltdb == NULL) {
                ctdb_set_error(ctdb, "Failed to open tdb %s\n", name);
                talloc_free(ctdb_db);