#define DEFAULT_MODE 0600
-#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb-home"
-#define DEFAULT_DBENV_MODE DEFAULT_MODE
+#define DEFAULT_DBENV_HOME LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
-#define DEFAULT_DB_DIRECTORY LDAP_RUNDIR LDAP_DIRSEP "openldap-bdb"
-#define DEFAULT_DB_MODE DEFAULT_MODE
+#define DEFAULT_DB_TMP_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "tmp"
+#define DEFAULT_DB_LG_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "log"
+#define DEFAULT_DB_DATA_DIR DEFAULT_DBENV_HOME LDAP_DIRSEP "data"
struct bdb_dbinfo {
DB_ENV *bdi_dbenv;
u_int32_t bdi_dbenv_xflags; /* extra flags */
int bdi_dbenv_mode;
- slap_mask_t bdi_db_mode;
- char *bdi_db_directory;
+ char *bdi_db_tmp_dir;
+ char *bdi_db_lg_dir;
+ char *bdi_db_data_dir;
};
LDAP_END_DECL
/* DBEnv parameters */
bdi->bdi_dbenv_home = ch_strdup( DEFAULT_DBENV_HOME );
bdi->bdi_dbenv_xflags = 0;
- bdi->bdi_dbenv_mode = DEFAULT_DBENV_MODE;
+ bdi->bdi_dbenv_mode = DEFAULT_MODE;
/* default database directories */
- bdi->bdi_db_directory = ch_strdup( DEFAULT_DB_DIRECTORY );
+ bdi->bdi_db_tmp_dir = ch_strdup( DEFAULT_DB_TMP_DIR );
+ bdi->bdi_db_lg_dir = ch_strdup( DEFAULT_DB_LG_DIR );
+ bdi->bdi_db_data_dir = ch_strdup( DEFAULT_DB_DATA_DIR );
be->be_private = bdi;
return 0;
return rc;
}
+ flags = DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_TXN |
+ DB_CREATE | DB_RECOVER | DB_THREAD;
+
#ifdef SLAPD_BDB_PRIVATE
- flags = DB_INIT_LOCK | DB_INIT_TXN |
- DB_PRIVATE | DB_RECOVER | DB_THREAD;
+ flags |= DB_PRIVATE;
#else
- flags = DB_INIT_LOCK | DB_INIT_TXN | DB_INIT_MPOOL |
- DB_RECOVER | DB_THREAD;
+ flags |= DB_INIT_MPOOL;
#endif
+ rc = bdi->bdi_dbenv->set_tmp_dir( bdi->bdi_dbenv,
+ bdi->bdi_db_tmp_dir );
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: set_tmp_dir(%s) failed: %s (%d)\n",
+ bdi->bdi_db_tmp_dir, db_strerror(rc), rc );
+ return rc;
+ }
+
+ rc = bdi->bdi_dbenv->set_lg_dir( bdi->bdi_dbenv,
+ bdi->bdi_db_lg_dir );
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: set_lg_dir(%s) failed: %s (%d)\n",
+ bdi->bdi_db_lg_dir, db_strerror(rc), rc );
+ return rc;
+ }
+
+ rc = bdi->bdi_dbenv->set_data_dir( bdi->bdi_dbenv,
+ bdi->bdi_db_data_dir );
+
+ if( rc != 0 ) {
+ Debug( LDAP_DEBUG_ANY,
+ "bdb_back_db_open: set_data_dir(%s) failed: %s (%d)\n",
+ bdi->bdi_db_data_dir, db_strerror(rc), rc );
+ return rc;
+ }
+
rc = bdi->bdi_dbenv->open( bdi->bdi_dbenv,
bdi->bdi_dbenv_home,
flags | bdi->bdi_dbenv_xflags,
if( rc != 0 ) {
Debug( LDAP_DEBUG_ANY,
- "bdb_back_db_open: db_open failed: %s (%d)\n",
- db_strerror(rc), rc, 0 );
+ "bdb_back_db_open: db_open(%s) failed: %s (%d)\n",
+ bdi->bdi_dbenv_home, db_strerror(rc), rc );
return rc;
}