]> code.citadel.org Git - citadel.git/commitdiff
* Database logs are now kept in the "data_logs" directory instead of in
authorArt Cancro <ajc@citadel.org>
Mon, 11 Apr 2005 16:31:57 +0000 (16:31 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 11 Apr 2005 16:31:57 +0000 (16:31 +0000)
  the "data" directory.  If no "data_logs" directory is found, a symlink
  to "data" will be created, in order to preserve access to any existing
  log files -- a savvy sysadmin (or a storage management wizard script)
  will know what to do if a different location is desirable.

citadel/ChangeLog
citadel/database_sleepycat.c

index 8066e0b48817aa4cab73338059f79463190da7e4..2ddebe3f469ede9f6049627a6f905b11483a5e98 100644 (file)
@@ -1,4 +1,11 @@
  $Log$
+ Revision 645.1  2005/04/11 16:31:57  ajc
+ * Database logs are now kept in the "data_logs" directory instead of in
+   the "data" directory.  If no "data_logs" directory is found, a symlink
+   to "data" will be created, in order to preserve access to any existing
+   log files -- a savvy sysadmin (or a storage management wizard script)
+   will know what to do if a different location is desirable.
+
  Revision 645.0  2005/04/01 03:02:44  ajc
  * THIS IS 6.45
 
@@ -6576,4 +6583,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import
-
index 193a327b02fdd99459b65236bab78510c662b002..fb9d6a53a4716d0cc495658b7e21006459a2c8e0 100644 (file)
@@ -55,6 +55,7 @@
 #include "database.h"
 #include "msgbase.h"
 #include "sysdep_decls.h"
+#include "tools.h"
 #include "config.h"
 
 static DB *dbp[MAXCDB];                /* One DB handle for each Citadel database */
@@ -284,6 +285,7 @@ void open_databases(void)
        char dbfilename[SIZ];
        u_int32_t flags = 0;
        char dbdirname[PATH_MAX];
+       char dblogname[PATH_MAX];
        DIR *dp;
        struct dirent *d;
        char filename[PATH_MAX];
@@ -291,6 +293,8 @@ void open_databases(void)
 
        getcwd(dbdirname, sizeof dbdirname);
        strcat(dbdirname, "/data");
+       getcwd(dblogname, sizeof dblogname);
+       strcat(dblogname, "/data_logs");
 
        lprintf(CTDL_DEBUG, "cdb_*: open_databases() starting\n");
        lprintf(CTDL_DEBUG, "Compiled db: %s\n", DB_VERSION_STRING);
@@ -307,6 +311,13 @@ void open_databases(void)
        chmod(dbdirname, 0700);
        chown(dbdirname, BBSUID, (-1) );
 
+       /*      
+        * By default, keep database logs in the same directory.  A savvy
+        * system administrator will know what to do if he/she wants to put
+        * them elsewhere.
+        */
+       symlink("data", dblogname);
+
        lprintf(CTDL_DEBUG, "cdb_*: Setting up DB environment\n");
        db_env_set_func_yield(sched_yield);
        ret = db_env_create(&dbenv, 0);
@@ -334,10 +345,22 @@ void open_databases(void)
                exit(ret);
        }
 
+       if ((ret = dbenv->set_data_dir(dbenv, dbdirname))) {
+               lprintf(CTDL_EMERG, "cdb_*: set_data_dir: %s\n", db_strerror(ret));
+               dbenv->close(dbenv, 0);
+               exit(ret);
+       }
+
+       if ((ret = dbenv->set_lg_dir(dbenv, dblogname))) {
+               lprintf(CTDL_EMERG, "cdb_*: set_lg_dir: %s\n", db_strerror(ret));
+               dbenv->close(dbenv, 0);
+               exit(ret);
+       }
+
         flags = DB_CREATE|DB_RECOVER|DB_INIT_MPOOL|DB_PRIVATE|DB_INIT_TXN|
                DB_INIT_LOCK|DB_THREAD;
-       lprintf(CTDL_DEBUG, "dbenv->open(dbenv, %s, %d, 0)\n", dbdirname, flags);
-        ret = dbenv->open(dbenv, dbdirname, flags, 0);
+       lprintf(CTDL_DEBUG, "dbenv->open(dbenv, NULL, %d, 0)\n", flags);
+        ret = dbenv->open(dbenv, NULL, flags, 0);
        if (ret) {
                lprintf(CTDL_DEBUG, "cdb_*: dbenv->open: %s\n", db_strerror(ret));
                 dbenv->close(dbenv, 0);