$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
#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 */
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];
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);
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);
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);