00001
00006
00007 static int _debug = 1;
00008
00009 #include "system.h"
00010
00011 #if defined(HAVE_FTOK) && defined(HAVE_SYS_IPC_H)
00012 #include <sys/ipc.h>
00013 #endif
00014
00015 #include <rpmlib.h>
00016 #include <rpmmacro.h>
00017 #include <rpmurl.h>
00018
00019 #include <rpmdb.h>
00020
00021 #include "debug.h"
00022
00023 #if !defined(DB_CLIENT)
00024 #define DB_CLIENT DB_RPCCLIENT
00025 #endif
00026
00027
00028
00029
00030
00034
00035 struct dbiHStats_s {
00036 unsigned int hash_magic;
00037 unsigned int hash_version;
00038 unsigned int hash_nkeys;
00039 unsigned int hash_ndata;
00040 unsigned int hash_pagesize;
00041 unsigned int hash_nelem;
00042 unsigned int hash_ffactor;
00043 unsigned int hash_buckets;
00044 unsigned int hash_free;
00045 unsigned int hash_bfree;
00046 unsigned int hash_bigpages;
00047 unsigned int hash_big_bfree;
00048 unsigned int hash_overflows;
00049 unsigned int hash_ovfl_free;
00050 unsigned int hash_dup;
00051 unsigned int hash_dup_free;
00052 };
00053
00057 struct dbiBStats_s {
00058 unsigned int bt_magic;
00059 unsigned int bt_version;
00060 unsigned int bt_nkeys;
00061 unsigned int bt_ndata;
00062 unsigned int bt_pagesize;
00063 unsigned int bt_minkey;
00064 unsigned int bt_re_len;
00065 unsigned int bt_re_pad;
00066 unsigned int bt_levels;
00067 unsigned int bt_int_pg;
00068 unsigned int bt_leaf_pg;
00069 unsigned int bt_dup_pg;
00070 unsigned int bt_over_pg;
00071 unsigned int bt_free;
00072 unsigned int bt_int_pgfree;
00073 unsigned int bt_leaf_pgfree;
00074 unsigned int bt_dup_pgfree;
00075 unsigned int bt_over_pgfree;
00076 };
00077
00078
00079 #ifdef NOTNOW
00080 static const char * bfstring(unsigned int x, const char * xbf)
00081 {
00082 const char * s = xbf;
00083 static char digits[] = "0123456789abcdefghijklmnopqrstuvwxyz";
00084 static char buf[256];
00085 char * t, * te;
00086 unsigned radix;
00087 unsigned c, i, k;
00088
00089 radix = (s != NULL ? *s++ : 16);
00090
00091 if (radix <= 1 || radix >= 32)
00092 radix = 16;
00093
00094 t = buf;
00095 switch (radix) {
00096 case 8: *t++ = '0'; break;
00097 case 16: *t++ = '0'; *t++ = 'x'; break;
00098 }
00099
00100 i = 0;
00101 k = x;
00102 do { i++; k /= radix; } while (k);
00103
00104 te = t + i;
00105
00106 k = x;
00107 do { --i; t[i] = digits[k % radix]; k /= radix; } while (k);
00108
00109 t = te;
00110 i = '<';
00111 if (s != NULL)
00112 while ((c = *s++) != '\0') {
00113 if (c > ' ') continue;
00114
00115 k = (1 << (c - 1));
00116 if (!(x & k)) continue;
00117
00118 if (t == te) *t++ = '=';
00119
00120 *t++ = i;
00121 i = ',';
00122 while (*s > ' ')
00123 *t++ = *s++;
00124 }
00125 if (t > te) *t++ = '>';
00126 *t = '\0';
00127 return buf;
00128 }
00129
00130 static const char * dbtFlags =
00131 "\20\1APPMALLOC\2ISSET\3MALLOC\4PARTIAL\5REALLOC\6USERMEM\7DUPOK";
00132
00133 static const char * dbenvOpenFlags =
00134 "\20\1CREATE\2NO_EXCEPTIONS\3FORCE\4NOMMAP\5RDONLY\6RECOVER\7THREAD\10TXN_NOSYNC\11USE_ENVIRON\12USE_ENVIRON_ROOT\13CDB\14LOCK\15LOG\16MPOOL\17TXN\20JOINENV\21LOCKDOWN\22PRIVATE\23RECOVER_FATAL\24SYSTEM_MEM";
00135
00136 static const char * dbOpenFlags =
00137 "\20\1CREATE\2NO_EXCEPTIONS\3FORCE\4NOMMAP\5RDONLY\6RECOVER\7THREAD\10TXN_NOSYNC\11USE_ENVIRON\12USE_ENVIRON_ROOT\13EXCL\14FCNTL_LOCKING\15RDWRMASTER\16TRUNCATE\17EXTENT\20APPLY_LOGREG";
00138
00139 static const char * dbenvSetFlags =
00140 "\20\1CREATE\2NO_EXCEPTIONS\3FORCE\4NOMMAP\5RDONLY\6RECOVER\7THREAD\10TXN_NOSYNC\11USE_ENVIRON\12USE_ENVIRON_ROOT\13CDB_ALLDB\14NOLOCKING\15NOPANIC\16PANIC_ENV\17REGION_INIT\20YIELDCPU";
00141
00142 static const char * dbSetFlags =
00143 "\20\1DUP\2DUPSORT\3RECNUM\4RENUMBER\5REVSPLITOFF\6SNAPSHOT";
00144
00145 static const char * dbiModeFlags =
00146 "\20\1WRONLY\2RDWR\7CREAT\10EXCL\11NOCTTY\12TRUNC\13APPEND\14NONBLOCK\15SYNC\16ASYNC\17DIRECT\20LARGEFILE\21DIRECTORY\22NOFOLLOW";
00147 #endif
00148
00149
00150
00151 static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
00152
00153
00154 {
00155 int rc = error;
00156
00157 if (printit && rc) {
00158
00159 if (msg)
00160 rpmError(RPMERR_DBERR, _("db%d error(%d) from %s: %s\n"),
00161 dbi->dbi_api, rc, msg, db_strerror(error));
00162 else
00163 rpmError(RPMERR_DBERR, _("db%d error(%d): %s\n"),
00164 dbi->dbi_api, rc, db_strerror(error));
00165
00166 }
00167
00168 return rc;
00169 }
00170
00171
00172 static int db_fini(dbiIndex dbi, const char * dbhome,
00173 const char * dbfile,
00174 const char * dbsubfile)
00175
00176
00177 {
00178 rpmdb rpmdb = dbi->dbi_rpmdb;
00179 DB_ENV * dbenv = rpmdb->db_dbenv;
00180 int rc;
00181
00182 if (dbenv == NULL)
00183 return 0;
00184
00185 rc = dbenv->close(dbenv, 0);
00186 rc = cvtdberr(dbi, "dbenv->close", rc, _debug);
00187
00188 if (dbfile)
00189 rpmMessage(RPMMESS_DEBUG, _("closed db environment %s/%s\n"),
00190 dbhome, dbfile);
00191
00192 if (rpmdb->db_remove_env) {
00193 int xx;
00194
00195
00196 xx = db_env_create(&dbenv, 0);
00197
00198 xx = cvtdberr(dbi, "db_env_create", xx, _debug);
00199 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
00200 xx = dbenv->remove(dbenv, dbhome, 0);
00201 #else
00202 xx = dbenv->remove(dbenv, dbhome, NULL, 0);
00203 #endif
00204 xx = cvtdberr(dbi, "dbenv->remove", xx, _debug);
00205
00206 if (dbfile)
00207 rpmMessage(RPMMESS_DEBUG, _("removed db environment %s/%s\n"),
00208 dbhome, dbfile);
00209
00210 }
00211 return rc;
00212 }
00213
00214 static int db3_fsync_disable( int fd)
00215
00216 {
00217 return 0;
00218 }
00219
00220 #if 0
00221 #if HAVE_LIBPTHREAD
00222 #if HAVE_PTHREAD_H
00223 #include <pthread.h>
00224 #endif
00225
00230 static int db3_pthread_nptl(void)
00231
00232 {
00233 pthread_mutex_t mutex;
00234 pthread_mutexattr_t mutexattr, *mutexattrp = NULL;
00235 pthread_cond_t cond;
00236 pthread_condattr_t condattr, *condattrp = NULL;
00237 int ret = 0;
00238
00239 ret = pthread_mutexattr_init(&mutexattr);
00240 if (ret == 0) {
00241 ret = pthread_mutexattr_setpshared(&mutexattr, PTHREAD_PROCESS_SHARED);
00242 mutexattrp = &mutexattr;
00243 }
00244
00245 if (ret == 0)
00246 ret = pthread_mutex_init(&mutex, mutexattrp);
00247 if (mutexattrp != NULL)
00248 pthread_mutexattr_destroy(mutexattrp);
00249 if (ret)
00250 return ret;
00251 (void) pthread_mutex_destroy(&mutex);
00252
00253 ret = pthread_condattr_init(&condattr);
00254 if (ret == 0) {
00255 ret = pthread_condattr_setpshared(&condattr, PTHREAD_PROCESS_SHARED);
00256 condattrp = &condattr;
00257 }
00258
00259 if (ret == 0)
00260 ret = pthread_cond_init(&cond, condattrp);
00261
00262 if (condattrp != NULL)
00263 (void)pthread_condattr_destroy(condattrp);
00264 if (ret == 0)
00265 (void) pthread_cond_destroy(&cond);
00266 return ret;
00267 }
00268 #endif
00269 #endif
00270
00271
00272 static int db_init(dbiIndex dbi, const char * dbhome,
00273 const char * dbfile,
00274 const char * dbsubfile,
00275 DB_ENV ** dbenvp)
00276
00277
00278
00279 {
00280 rpmdb rpmdb = dbi->dbi_rpmdb;
00281 DB_ENV *dbenv = NULL;
00282 int eflags;
00283 int rc;
00284
00285 if (dbenvp == NULL)
00286 return 1;
00287
00288
00289
00290 if (rpmdb->db_errfile == NULL)
00291 rpmdb->db_errfile = stderr;
00292
00293
00294 eflags = (dbi->dbi_oeflags | dbi->dbi_eflags);
00295 if (eflags & DB_JOINENV) eflags &= DB_JOINENV;
00296
00297 if (dbfile)
00298 rpmMessage(RPMMESS_DEBUG, _("opening db environment %s/%s %s\n"),
00299 dbhome, dbfile, prDbiOpenFlags(eflags, 1));
00300
00301
00302 if (dbi->dbi_host == NULL)
00303 dbi->dbi_ecflags &= ~DB_CLIENT;
00304
00305
00306 if ((dbi->dbi_eflags & DB_SYSTEM_MEM) && dbi->dbi_shmkey == 0) {
00307 #if defined(HAVE_FTOK)
00308 dbi->dbi_shmkey = ftok(dbhome, 0);
00309 #else
00310 dbi->dbi_shmkey = 0x44631380;
00311 #endif
00312 }
00313
00314 rc = db_env_create(&dbenv, dbi->dbi_ecflags);
00315 rc = cvtdberr(dbi, "db_env_create", rc, _debug);
00316 if (dbenv == NULL || rc)
00317 goto errxit;
00318
00319 { int xx;
00320
00321
00322
00323
00324
00325
00326
00327 dbenv->set_errcall(dbenv, rpmdb->db_errcall);
00328 dbenv->set_errfile(dbenv, rpmdb->db_errfile);
00329 dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
00330
00331
00332
00333
00334
00335
00336
00337 if ((dbi->dbi_ecflags & DB_CLIENT) && dbi->dbi_host) {
00338 const char * home;
00339 int retry = 0;
00340
00341 if ((home = strrchr(dbhome, '/')) != NULL)
00342 dbhome = ++home;
00343
00344 while (retry++ < 5) {
00345
00346 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
00347 xx = dbenv->set_rpc_server(dbenv, NULL, dbi->dbi_host,
00348 dbi->dbi_cl_timeout, dbi->dbi_sv_timeout, 0);
00349 xx = cvtdberr(dbi, "dbenv->set_server", xx, _debug);
00350 #else
00351 xx = dbenv->set_server(dbenv, dbi->dbi_host,
00352 dbi->dbi_cl_timeout, dbi->dbi_sv_timeout, 0);
00353 xx = cvtdberr(dbi, "dbenv->set_server", xx, _debug);
00354 #endif
00355 if (!xx)
00356 break;
00357 (void) sleep(15);
00358 }
00359 } else {
00360 #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
00361 xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
00362 (dbi->dbi_verbose & DB_VERB_CHKPOINT));
00363 #endif
00364 xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
00365 (dbi->dbi_verbose & DB_VERB_DEADLOCK));
00366 xx = dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
00367 (dbi->dbi_verbose & DB_VERB_RECOVERY));
00368 xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
00369 (dbi->dbi_verbose & DB_VERB_WAITSFOR));
00370
00371 if (dbi->dbi_mmapsize) {
00372 xx = dbenv->set_mp_mmapsize(dbenv, dbi->dbi_mmapsize);
00373 xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug);
00374 }
00375 if (dbi->dbi_tmpdir) {
00376 const char * root;
00377 const char * tmpdir;
00378
00379 root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root);
00380
00381 if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone)
00382 root = NULL;
00383
00384
00385 tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
00386
00387 xx = dbenv->set_tmp_dir(dbenv, tmpdir);
00388 xx = cvtdberr(dbi, "dbenv->set_tmp_dir", xx, _debug);
00389 tmpdir = _free(tmpdir);
00390 }
00391 }
00392
00393
00394
00395
00396
00397
00398
00399
00400
00401
00402
00403
00404 if (dbi->dbi_cachesize) {
00405 xx = dbenv->set_cachesize(dbenv, 0, dbi->dbi_cachesize, 0);
00406 xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug);
00407 }
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417 if (dbi->dbi_no_fsync) {
00418 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
00419 xx = db_env_set_func_fsync(db3_fsync_disable);
00420 #else
00421 xx = dbenv->set_func_fsync(dbenv, db3_fsync_disable);
00422 #endif
00423 xx = cvtdberr(dbi, "db_env_set_func_fsync", xx, _debug);
00424 }
00425
00426 if (dbi->dbi_shmkey) {
00427 xx = dbenv->set_shm_key(dbenv, dbi->dbi_shmkey);
00428 xx = cvtdberr(dbi, "dbenv->set_shm_key", xx, _debug);
00429 }
00430 }
00431
00432 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR != 0) || (DB_VERSION_MAJOR == 4)
00433 rc = (dbenv->open)(dbenv, dbhome, eflags, dbi->dbi_perms);
00434 #else
00435 rc = (dbenv->open)(dbenv, dbhome, NULL, eflags, dbi->dbi_perms);
00436 #endif
00437 rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
00438 if (rc)
00439 goto errxit;
00440
00441
00442 *dbenvp = dbenv;
00443
00444
00445 return 0;
00446
00447 errxit:
00448 if (dbenv) {
00449 int xx;
00450 xx = dbenv->close(dbenv, 0);
00451 xx = cvtdberr(dbi, "dbenv->close", xx, _debug);
00452 }
00453 return rc;
00454 }
00455
00456
00457 static int db3sync(dbiIndex dbi, unsigned int flags)
00458
00459
00460 {
00461 DB * db = dbi->dbi_db;
00462 int rc = 0;
00463 int _printit;
00464
00465 if (db != NULL)
00466 rc = db->sync(db, flags);
00467
00468 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
00469 _printit = _debug;
00470 #else
00471 _printit = (rc == DB_INCOMPLETE ? 0 : _debug);
00472 #endif
00473 rc = cvtdberr(dbi, "db->sync", rc, _printit);
00474 return rc;
00475 }
00476
00477 static int db3cdup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp,
00478 unsigned int flags)
00479
00480
00481 {
00482 int rc;
00483
00484
00485 if (dbcp) *dbcp = NULL;
00486
00487 rc = dbcursor->c_dup(dbcursor, dbcp, flags);
00488 rc = cvtdberr(dbi, "dbcursor->c_dup", rc, _debug);
00489
00490 return rc;
00491
00492 }
00493
00494
00495 static int db3cclose(dbiIndex dbi, DBC * dbcursor,
00496 unsigned int flags)
00497
00498
00499 {
00500 int rc = -2;
00501
00502
00503 if (dbcursor != NULL) {
00504 rc = dbcursor->c_close(dbcursor);
00505 rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
00506 }
00507 return rc;
00508 }
00509
00510
00511 static int db3copen(dbiIndex dbi, DB_TXN * txnid,
00512 DBC ** dbcp, unsigned int dbiflags)
00513
00514
00515 {
00516 DB * db = dbi->dbi_db;
00517 DBC * dbcursor = NULL;
00518 int flags;
00519 int rc;
00520
00521
00522 assert(db != NULL);
00523 if ((dbiflags & DB_WRITECURSOR) &&
00524 (dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
00525 {
00526 flags = DB_WRITECURSOR;
00527 } else
00528 flags = 0;
00529
00530 rc = db->cursor(db, txnid, &dbcursor, flags);
00531 rc = cvtdberr(dbi, "db->cursor", rc, _debug);
00532
00533 if (dbcp)
00534 *dbcp = dbcursor;
00535 else
00536 (void) db3cclose(dbi, dbcursor, 0);
00537
00538 return rc;
00539 }
00540
00541 static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
00542 unsigned int flags)
00543
00544
00545 {
00546 DB * db = dbi->dbi_db;
00547 int rc;
00548
00549 assert(db != NULL);
00550 if (dbcursor == NULL) {
00551 rc = db->put(db, dbi->dbi_txnid, key, data, 0);
00552 rc = cvtdberr(dbi, "db->put", rc, _debug);
00553 } else {
00554 rc = dbcursor->c_put(dbcursor, key, data, DB_KEYLAST);
00555 rc = cvtdberr(dbi, "dbcursor->c_put", rc, _debug);
00556 }
00557
00558 return rc;
00559 }
00560
00561
00562 static int db3cdel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
00563 unsigned int flags)
00564
00565
00566 {
00567 DB * db = dbi->dbi_db;
00568 int rc;
00569
00570 assert(db != NULL);
00571 if (dbcursor == NULL) {
00572 rc = db->del(db, dbi->dbi_txnid, key, flags);
00573 rc = cvtdberr(dbi, "db->del", rc, _debug);
00574 } else {
00575 int _printit;
00576
00577
00578 rc = dbcursor->c_get(dbcursor, key, data, DB_SET);
00579
00580 _printit = (rc == DB_NOTFOUND ? 0 : _debug);
00581 rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
00582
00583 if (rc == 0) {
00584 rc = dbcursor->c_del(dbcursor, flags);
00585 rc = cvtdberr(dbi, "dbcursor->c_del", rc, _debug);
00586 }
00587 }
00588
00589 return rc;
00590 }
00591
00592
00593
00594 static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
00595 unsigned int flags)
00596
00597
00598 {
00599 DB * db = dbi->dbi_db;
00600 int _printit;
00601 int rc;
00602
00603 assert(db != NULL);
00604 if (dbcursor == NULL) {
00605
00606 rc = db->get(db, dbi->dbi_txnid, key, data, 0);
00607
00608 _printit = (rc == DB_NOTFOUND ? 0 : _debug);
00609 rc = cvtdberr(dbi, "db->get", rc, _printit);
00610 } else {
00611
00612 rc = dbcursor->c_get(dbcursor, key, data, flags);
00613
00614 _printit = (rc == DB_NOTFOUND ? 0 : _debug);
00615 rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
00616 }
00617
00618 return rc;
00619 }
00620
00621
00622
00623 static int db3cpget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * pkey,
00624 DBT * data, unsigned int flags)
00625
00626
00627 {
00628 DB * db = dbi->dbi_db;
00629 int _printit;
00630 int rc;
00631
00632 assert(db != NULL);
00633 assert(dbcursor != NULL);
00634
00635
00636 rc = dbcursor->c_pget(dbcursor, key, pkey, data, flags);
00637
00638 _printit = (rc == DB_NOTFOUND ? 0 : _debug);
00639 rc = cvtdberr(dbi, "dbcursor->c_pget", rc, _printit);
00640
00641 return rc;
00642 }
00643
00644
00645 static int db3ccount(dbiIndex dbi, DBC * dbcursor,
00646 unsigned int * countp,
00647 unsigned int flags)
00648
00649
00650 {
00651 db_recno_t count = 0;
00652 int rc = 0;
00653
00654 flags = 0;
00655 rc = dbcursor->c_count(dbcursor, &count, flags);
00656 rc = cvtdberr(dbi, "dbcursor->c_count", rc, _debug);
00657 if (rc) return rc;
00658
00659 if (countp) *countp = count;
00660
00661
00662 return rc;
00663 }
00664
00665 static int db3byteswapped(dbiIndex dbi)
00666 {
00667 DB * db = dbi->dbi_db;
00668 int rc = 0;
00669
00670 if (db != NULL) {
00671 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11) \
00672 || (DB_VERSION_MAJOR == 4)
00673 int isswapped = 0;
00674 rc = db->get_byteswapped(db, &isswapped);
00675 if (rc == 0)
00676 rc = isswapped;
00677 #else
00678 rc = db->get_byteswapped(db);
00679 #endif
00680 }
00681
00682 return rc;
00683 }
00684
00685 static int db3stat(dbiIndex dbi, unsigned int flags)
00686
00687
00688 {
00689 DB * db = dbi->dbi_db;
00690 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
00691 DB_TXN * txnid = NULL;
00692 #endif
00693 int rc = 0;
00694
00695 assert(db != NULL);
00696 #if defined(DB_FAST_STAT)
00697 if (flags)
00698 flags = DB_FAST_STAT;
00699 else
00700 #endif
00701 flags = 0;
00702 dbi->dbi_stats = _free(dbi->dbi_stats);
00703
00704 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
00705 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
00706 rc = db->stat(db, txnid, &dbi->dbi_stats, flags);
00707 #else
00708 rc = db->stat(db, &dbi->dbi_stats, flags);
00709 #endif
00710 #else
00711 rc = db->stat(db, &dbi->dbi_stats, NULL, flags);
00712 #endif
00713 rc = cvtdberr(dbi, "db->stat", rc, _debug);
00714 return rc;
00715 }
00716
00717
00718 static int db3associate(dbiIndex dbi, dbiIndex dbisecondary,
00719 int (*callback)(DB *, const DBT *, const DBT *, DBT *),
00720 unsigned int flags)
00721
00722
00723 {
00724 DB * db = dbi->dbi_db;
00725 DB * secondary = dbisecondary->dbi_db;
00726 int rc;
00727
00728
00729 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
00730 DB_TXN * txnid = NULL;
00731
00732 assert(db != NULL);
00733 rc = db->associate(db, txnid, secondary, callback, flags);
00734 #else
00735 assert(db != NULL);
00736 rc = db->associate(db, secondary, callback, flags);
00737 #endif
00738
00739 rc = cvtdberr(dbi, "db->associate", rc, _debug);
00740 return rc;
00741 }
00742
00743
00744
00745 static int db3join(dbiIndex dbi, DBC ** curslist, DBC ** dbcp,
00746 unsigned int flags)
00747
00748
00749 {
00750 DB * db = dbi->dbi_db;
00751 int rc;
00752
00753 assert(db != NULL);
00754
00755 rc = db->join(db, curslist, dbcp, flags);
00756
00757 rc = cvtdberr(dbi, "db->join", rc, _debug);
00758 return rc;
00759 }
00760
00761
00762
00763 static int db3close( dbiIndex dbi, unsigned int flags)
00764
00765
00766
00767 {
00768 rpmdb rpmdb = dbi->dbi_rpmdb;
00769 const char * urlfn = NULL;
00770 const char * root;
00771 const char * home;
00772 const char * dbhome;
00773 const char * dbfile;
00774 const char * dbsubfile;
00775 DB * db = dbi->dbi_db;
00776 int _printit;
00777 int rc = 0, xx;
00778
00779 flags = 0;
00780
00781
00782
00783
00784 root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root);
00785
00786 if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone)
00787 root = NULL;
00788
00789 home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home);
00790
00791
00792
00793
00794
00795
00796 urlfn = rpmGenPath(root, home, NULL);
00797
00798 (void) urlPath(urlfn, &dbhome);
00799 if (dbi->dbi_temporary) {
00800 dbfile = NULL;
00801 dbsubfile = NULL;
00802 } else {
00803 #ifdef HACK
00804 dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
00805 dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
00806 #else
00807 dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
00808 dbsubfile = NULL;
00809 #endif
00810 }
00811
00812 if (db) {
00813 rc = db->close(db, 0);
00814
00815 _printit = (rc == ENOENT ? 0 : _debug);
00816 rc = cvtdberr(dbi, "db->close", rc, _printit);
00817 db = dbi->dbi_db = NULL;
00818
00819 rpmMessage(RPMMESS_DEBUG, _("closed db index %s/%s\n"),
00820 dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)));
00821
00822 }
00823
00824 if (rpmdb->db_dbenv != NULL && dbi->dbi_use_dbenv) {
00825 if (rpmdb->db_opens == 1) {
00826
00827 xx = db_fini(dbi, (dbhome ? dbhome : ""), dbfile, dbsubfile);
00828
00829 rpmdb->db_dbenv = NULL;
00830 }
00831 rpmdb->db_opens--;
00832 }
00833
00834 if (dbi->dbi_verify_on_close && !dbi->dbi_temporary) {
00835 DB_ENV * dbenv = NULL;
00836
00837
00838 rc = db_env_create(&dbenv, 0);
00839
00840 rc = cvtdberr(dbi, "db_env_create", rc, _debug);
00841 if (rc || dbenv == NULL) goto exit;
00842
00843
00844 dbenv->set_errcall(dbenv, rpmdb->db_errcall);
00845 dbenv->set_errfile(dbenv, rpmdb->db_errfile);
00846 dbenv->set_errpfx(dbenv, rpmdb->db_errpfx);
00847
00848
00849 #if !(DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 3)
00850 xx = dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT,
00851 (dbi->dbi_verbose & DB_VERB_CHKPOINT));
00852 #endif
00853 xx = dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK,
00854 (dbi->dbi_verbose & DB_VERB_DEADLOCK));
00855 xx = dbenv->set_verbose(dbenv, DB_VERB_RECOVERY,
00856 (dbi->dbi_verbose & DB_VERB_RECOVERY));
00857 xx = dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR,
00858 (dbi->dbi_verbose & DB_VERB_WAITSFOR));
00859
00860 if (dbi->dbi_tmpdir) {
00861
00862 const char * tmpdir = rpmGenPath(root, dbi->dbi_tmpdir, NULL);
00863
00864 rc = dbenv->set_tmp_dir(dbenv, tmpdir);
00865 rc = cvtdberr(dbi, "dbenv->set_tmp_dir", rc, _debug);
00866 tmpdir = _free(tmpdir);
00867 if (rc) goto exit;
00868 }
00869
00870 rc = (dbenv->open)(dbenv, dbhome,
00871 DB_CREATE | DB_INIT_MPOOL | DB_PRIVATE | DB_USE_ENVIRON, 0);
00872 rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
00873 if (rc) goto exit;
00874
00875
00876 rc = db_create(&db, dbenv, 0);
00877
00878 rc = cvtdberr(dbi, "db_create", rc, _debug);
00879
00880 if (db != NULL) {
00881
00882 const char * dbf = rpmGetPath(dbhome, "/", dbfile, NULL);
00883
00884
00885 rc = db->verify(db, dbf, NULL, NULL, flags);
00886 rc = cvtdberr(dbi, "db->verify", rc, _debug);
00887
00888 rpmMessage(RPMMESS_DEBUG, _("verified db index %s/%s\n"),
00889 (dbhome ? dbhome : ""),
00890 (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)));
00891
00892
00893
00894
00895
00896 db = NULL;
00897 dbf = _free(dbf);
00898 }
00899 xx = dbenv->close(dbenv, 0);
00900 xx = cvtdberr(dbi, "dbenv->close", xx, _debug);
00901 if (rc == 0 && xx) rc = xx;
00902 }
00903
00904 exit:
00905 dbi->dbi_db = NULL;
00906
00907 urlfn = _free(urlfn);
00908
00909 dbi = db3Free(dbi);
00910
00911 return rc;
00912 }
00913
00914
00915 static int db3open(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip)
00916
00917
00918
00919 {
00920
00921 extern struct _dbiVec db3vec;
00922
00923 const char * urlfn = NULL;
00924 const char * root;
00925 const char * home;
00926 const char * dbhome;
00927 const char * dbfile;
00928 const char * dbsubfile;
00929 dbiIndex dbi = NULL;
00930 int rc = 0;
00931 int xx;
00932
00933 DB * db = NULL;
00934 DB_ENV * dbenv = NULL;
00935 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
00936 DB_TXN * txnid = NULL;
00937 #endif
00938 u_int32_t oflags;
00939 int _printit;
00940
00941
00942 if (dbip)
00943 *dbip = NULL;
00944
00945
00946
00947
00948
00949
00950 if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
00951
00952 return 1;
00953
00954
00955 dbi->dbi_api = DB_VERSION_MAJOR;
00956
00957
00958
00959
00960 root = (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root);
00961
00962 if ((root[0] == '/' && root[1] == '\0') || rpmdb->db_chrootDone)
00963 root = NULL;
00964
00965 home = (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home);
00966
00967
00968
00969
00970
00971
00972 urlfn = rpmGenPath(root, home, NULL);
00973
00974 (void) urlPath(urlfn, &dbhome);
00975 if (dbi->dbi_temporary) {
00976 dbfile = NULL;
00977 dbsubfile = NULL;
00978 } else {
00979 #ifdef HACK
00980 dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
00981 dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
00982 #else
00983 dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
00984 dbsubfile = NULL;
00985 #endif
00986 }
00987
00988 oflags = (dbi->dbi_oeflags | dbi->dbi_oflags);
00989 oflags &= ~DB_TRUNCATE;
00990
00991 #if 0
00992 if ( dbi->dbi_mode & O_EXCL) oflags |= DB_EXCL;
00993 #endif
00994
00995
00996
00997
00998 if (dbi->dbi_temporary) {
00999 oflags |= DB_CREATE;
01000 dbi->dbi_oeflags |= DB_CREATE;
01001 oflags &= ~DB_RDONLY;
01002 dbi->dbi_oflags &= ~DB_RDONLY;
01003 } else {
01004 if (!(dbi->dbi_mode & (O_RDWR|O_WRONLY))) oflags |= DB_RDONLY;
01005 if (dbi->dbi_mode & O_CREAT) {
01006 oflags |= DB_CREATE;
01007 dbi->dbi_oeflags |= DB_CREATE;
01008 }
01009 #ifdef DANGEROUS
01010 if ( dbi->dbi_mode & O_TRUNC) oflags |= DB_TRUNCATE;
01011 #endif
01012 }
01013
01014
01015
01016
01017 (void) rpmioMkpath(dbhome, 0755, getuid(), getgid());
01018
01019
01020
01021
01022 if (dbi->dbi_use_dbenv) {
01023
01024 #if 0
01025 #if HAVE_LIBPTHREAD
01026 if (rpmdb->db_dbenv == NULL) {
01027
01028 xx = db3_pthread_nptl();
01029 if (xx) {
01030 dbi->dbi_eflags |= DB_PRIVATE;
01031 rpmMessage(RPMMESS_DEBUG, _("unshared posix mutexes found(%d), adding DB_PRIVATE, using fcntl lock\n"), xx);
01032 }
01033 }
01034 #endif
01035 #endif
01036
01037 if (access(dbhome, W_OK) == -1) {
01038
01039
01040 oflags &= ~DB_CREATE;
01041
01042
01043 if (dbi->dbi_eflags & DB_PRIVATE) {
01044 dbi->dbi_eflags &= ~DB_JOINENV;
01045 } else {
01046 dbi->dbi_eflags |= DB_JOINENV;
01047 dbi->dbi_oeflags &= ~DB_CREATE;
01048 dbi->dbi_oeflags &= ~DB_THREAD;
01049
01050 dbi->dbi_use_dbenv = 0;
01051 }
01052
01053
01054 if (dbi->dbi_temporary) {
01055 oflags |= DB_CREATE;
01056 dbi->dbi_oeflags |= DB_CREATE;
01057 oflags &= ~DB_RDONLY;
01058 dbi->dbi_oflags &= ~DB_RDONLY;
01059 } else {
01060 oflags |= DB_RDONLY;
01061
01062 dbi->dbi_oflags |= DB_RDONLY;
01063 }
01064
01065 } else {
01066
01067 const char * dbf = rpmGetPath(dbhome, "/__db.001", NULL);
01068
01069
01070 if (access(dbf, F_OK) == -1) {
01071
01072 dbi->dbi_oeflags |= DB_CREATE;
01073 dbi->dbi_eflags &= ~DB_JOINENV;
01074 } else {
01075
01076 if (dbi->dbi_eflags & DB_PRIVATE) {
01077 dbi->dbi_eflags &= ~DB_JOINENV;
01078 } else {
01079 dbi->dbi_eflags |= DB_JOINENV;
01080 dbi->dbi_oeflags &= ~DB_CREATE;
01081 dbi->dbi_oeflags &= ~DB_THREAD;
01082 }
01083 }
01084 dbf = _free(dbf);
01085 }
01086 }
01087
01088
01089
01090
01091 if ((oflags & DB_CREATE) && (oflags & DB_RDONLY)) {
01092
01093 const char * dbfn = (dbfile ? dbfile : tagName(dbi->dbi_rpmtag));
01094
01095 const char * dbf = rpmGetPath(dbhome, "/", dbfn, NULL);
01096
01097
01098 if (access(dbf, F_OK) == -1) {
01099
01100 oflags &= ~DB_RDONLY;
01101 } else {
01102
01103 oflags &= ~DB_CREATE;
01104 }
01105
01106
01107 if (!(oflags & DB_RDONLY) && access(dbf, W_OK) == 0) {
01108 dbi->dbi_oflags &= ~DB_RDONLY;
01109 } else {
01110 dbi->dbi_oflags |= DB_RDONLY;
01111 }
01112 dbf = _free(dbf);
01113 }
01114
01115
01116
01117
01118 if (oflags & DB_RDONLY)
01119 dbi->dbi_verify_on_close = 0;
01120
01121 if (dbi->dbi_use_dbenv) {
01122
01123 if (rpmdb->db_dbenv == NULL) {
01124 rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
01125 if (rc == 0) {
01126 rpmdb->db_dbenv = dbenv;
01127 rpmdb->db_opens = 1;
01128 }
01129 } else {
01130 dbenv = rpmdb->db_dbenv;
01131 rpmdb->db_opens++;
01132 }
01133
01134 }
01135
01136 rpmMessage(RPMMESS_DEBUG, _("opening db index %s/%s %s mode=0x%x\n"),
01137 dbhome, (dbfile ? dbfile : tagName(dbi->dbi_rpmtag)),
01138 prDbiOpenFlags(oflags, 0), dbi->dbi_mode);
01139
01140 if (rc == 0) {
01141 static int _lockdbfd = 0;
01142
01143
01144 rc = db_create(&db, dbenv, dbi->dbi_cflags);
01145
01146 rc = cvtdberr(dbi, "db_create", rc, _debug);
01147 if (rc == 0 && db != NULL) {
01148
01149
01150 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3) || (DB_VERSION_MAJOR == 4)
01151 if (rc == 0 &&
01152 rpmdb->db_malloc && rpmdb->db_realloc && rpmdb->db_free)
01153 {
01154 rc = db->set_alloc(db,
01155 rpmdb->db_malloc, rpmdb->db_realloc, rpmdb->db_free);
01156 rc = cvtdberr(dbi, "db->set_alloc", rc, _debug);
01157 }
01158 #else
01159 if (rc == 0 && rpmdb->db_malloc) {
01160 rc = db->set_malloc(db, rpmdb->db_malloc);
01161 rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
01162 }
01163 #endif
01164
01165
01166 if (rc == 0 && !dbi->dbi_use_dbenv && dbi->dbi_cachesize) {
01167 rc = db->set_cachesize(db, 0, dbi->dbi_cachesize, 0);
01168 rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug);
01169 }
01170
01171
01172
01173
01174
01175
01176 if (rc == 0 && dbi->dbi_lorder) {
01177 rc = db->set_lorder(db, dbi->dbi_lorder);
01178 rc = cvtdberr(dbi, "db->set_lorder", rc, _debug);
01179 }
01180 if (rc == 0 && dbi->dbi_pagesize) {
01181 rc = db->set_pagesize(db, dbi->dbi_pagesize);
01182 rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug);
01183 }
01184
01185 if (rc == 0 && oflags & DB_CREATE) {
01186 switch(dbi->dbi_type) {
01187 default:
01188 case DB_HASH:
01189 if (dbi->dbi_h_ffactor) {
01190 rc = db->set_h_ffactor(db, dbi->dbi_h_ffactor);
01191 rc = cvtdberr(dbi, "db->set_h_ffactor", rc, _debug);
01192 if (rc) break;
01193 }
01194 if (dbi->dbi_h_nelem) {
01195 rc = db->set_h_nelem(db, dbi->dbi_h_nelem);
01196 rc = cvtdberr(dbi, "db->set_h_nelem", rc, _debug);
01197 if (rc) break;
01198 }
01199 if (dbi->dbi_h_flags) {
01200 rc = db->set_flags(db, dbi->dbi_h_flags);
01201 rc = cvtdberr(dbi, "db->set_h_flags", rc, _debug);
01202 if (rc) break;
01203 }
01204
01205 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2) || (DB_VERSION_MAJOR == 4)
01206 if (dbi->dbi_h_hash_fcn) {
01207 rc = db->set_h_hash(db, dbi->dbi_h_hash_fcn);
01208 rc = cvtdberr(dbi, "db->set_h_hash", rc, _debug);
01209 if (rc) break;
01210 }
01211 if (dbi->dbi_h_dup_compare_fcn) {
01212 rc = db->set_dup_compare(db, dbi->dbi_h_dup_compare_fcn);
01213 rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug);
01214 if (rc) break;
01215 }
01216 #endif
01217 break;
01218 case DB_BTREE:
01219
01220 if (dbi->dbi_bt_flags) {
01221 rc = db->set_flags(db, dbi->dbi_bt_flags);
01222 rc = cvtdberr(dbi, "db->set_bt_flags", rc, _debug);
01223 if (rc) break;
01224 }
01225 if (dbi->dbi_bt_minkey) {
01226 rc = db->set_bt_minkey(db, dbi->dbi_bt_minkey);
01227 rc = cvtdberr(dbi, "db->set_bt_minkey", rc, _debug);
01228 if (rc) break;
01229 }
01230
01231 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR > 2) || (DB_VERSION_MAJOR == 4)
01232 if (dbi->dbi_bt_compare_fcn) {
01233 rc = db->set_bt_compare(db, dbi->dbi_bt_compare_fcn);
01234 rc = cvtdberr(dbi, "db->set_bt_compare", rc, _debug);
01235 if (rc) break;
01236 }
01237 if (dbi->dbi_bt_dup_compare_fcn) {
01238 rc = db->set_dup_compare(db, dbi->dbi_bt_dup_compare_fcn);
01239 rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug);
01240 if (rc) break;
01241 }
01242 if (dbi->dbi_bt_prefix_fcn) {
01243 rc = db->set_bt_prefix(db, dbi->dbi_bt_prefix_fcn);
01244 rc = cvtdberr(dbi, "db->set_bt_prefix", rc, _debug);
01245 if (rc) break;
01246 }
01247 #endif
01248 break;
01249 case DB_RECNO:
01250 if (dbi->dbi_re_delim) {
01251
01252 rc = db->set_re_delim(db, dbi->dbi_re_delim);
01253 rc = cvtdberr(dbi, "db->set_re_selim", rc, _debug);
01254 if (rc) break;
01255 }
01256 if (dbi->dbi_re_len) {
01257 rc = db->set_re_len(db, dbi->dbi_re_len);
01258 rc = cvtdberr(dbi, "db->set_re_len", rc, _debug);
01259 if (rc) break;
01260 }
01261 if (dbi->dbi_re_pad) {
01262 rc = db->set_re_pad(db, dbi->dbi_re_pad);
01263 rc = cvtdberr(dbi, "db->set_re_pad", rc, _debug);
01264 if (rc) break;
01265 }
01266 if (dbi->dbi_re_source) {
01267 rc = db->set_re_source(db, dbi->dbi_re_source);
01268 rc = cvtdberr(dbi, "db->set_re_source", rc, _debug);
01269 if (rc) break;
01270 }
01271 break;
01272 case DB_QUEUE:
01273 if (dbi->dbi_q_extentsize) {
01274 rc = db->set_q_extentsize(db, dbi->dbi_q_extentsize);
01275 rc = cvtdberr(dbi, "db->set_q_extentsize", rc, _debug);
01276 if (rc) break;
01277 }
01278 break;
01279 }
01280 }
01281
01282 if (rc == 0) {
01283 const char * dbfullpath;
01284 const char * dbpath;
01285 char * t;
01286 int nb;
01287
01288 nb = strlen(dbhome);
01289 if (dbfile) nb += 1 + strlen(dbfile);
01290 dbfullpath = t = alloca(nb + 1);
01291
01292
01293 t = stpcpy(t, dbhome);
01294 if (dbfile)
01295 t = stpcpy( stpcpy( t, "/"), dbfile);
01296
01297 #ifdef HACK
01298 dbpath = (!dbi->dbi_use_dbenv && !dbi->dbi_temporary)
01299 ? dbfullpath : dbfile;
01300 #else
01301 dbpath = (!dbi->dbi_temporary)
01302 ? dbfullpath : dbfile;
01303 #endif
01304
01305 #if (DB_VERSION_MAJOR == 4 && DB_VERSION_MINOR >= 1)
01306 rc = (db->open)(db, txnid, dbpath, dbsubfile,
01307 dbi->dbi_type, oflags, dbi->dbi_perms);
01308 #else
01309 rc = (db->open)(db, dbpath, dbsubfile,
01310 dbi->dbi_type, oflags, dbi->dbi_perms);
01311 #endif
01312
01313 if (rc == 0 && dbi->dbi_type == DB_UNKNOWN) {
01314 #if (DB_VERSION_MAJOR == 3 && DB_VERSION_MINOR == 3 && DB_VERSION_PATCH == 11) \
01315 || (DB_VERSION_MAJOR == 4)
01316 DBTYPE dbi_type = DB_UNKNOWN;
01317 xx = db->get_type(db, &dbi_type);
01318 if (xx == 0)
01319 dbi->dbi_type = dbi_type;
01320 #else
01321 dbi->dbi_type = db->get_type(db);
01322 #endif
01323 }
01324 }
01325
01326
01327 _printit = (rc > 0 ? 0 : _debug);
01328 xx = cvtdberr(dbi, "db->open", rc, _printit);
01329
01330 dbi->dbi_txnid = NULL;
01331
01332
01333
01334
01335
01336
01337
01338
01339
01340
01341
01342
01343
01344
01345
01346
01347
01348
01349
01350 if (rc == 0 && dbi->dbi_lockdbfd &&
01351 !((dbi->dbi_ecflags & DB_CLIENT) && dbi->dbi_host) &&
01352 (!dbi->dbi_use_dbenv || _lockdbfd++ == 0))
01353 {
01354 int fdno = -1;
01355
01356 if (!(db->fd(db, &fdno) == 0 && fdno >= 0)) {
01357 rc = 1;
01358 } else {
01359 struct flock l;
01360
01361 memset(&l, 0, sizeof(l));
01362
01363 l.l_whence = 0;
01364 l.l_start = 0;
01365 l.l_len = 0;
01366 l.l_type = (dbi->dbi_mode & (O_RDWR|O_WRONLY))
01367 ? F_WRLCK : F_RDLCK;
01368 l.l_pid = 0;
01369
01370 rc = fcntl(fdno, F_SETLK, (void *) &l);
01371 if (rc) {
01372
01373 rc = ((dbi->dbi_use_dbenv &&
01374 (dbi->dbi_eflags & DB_INIT_CDB) &&
01375 !(dbi->dbi_eflags & DB_PRIVATE))
01376 ? 0 : 1);
01377 rpmError( (rc ? RPMERR_FLOCK : RPMWARN_FLOCK),
01378 _("cannot get %s lock on %s/%s\n"),
01379 ((dbi->dbi_mode & (O_RDWR|O_WRONLY))
01380 ? _("exclusive") : _("shared")),
01381 dbhome, (dbfile ? dbfile : ""));
01382 } else if (dbfile) {
01383 rpmMessage(RPMMESS_DEBUG,
01384 _("locked db index %s/%s\n"),
01385 dbhome, dbfile);
01386 }
01387 }
01388 }
01389 }
01390 }
01391
01392 dbi->dbi_db = db;
01393
01394 if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
01395 dbi->dbi_vec = &db3vec;
01396
01397 *dbip = dbi;
01398
01399 } else {
01400 dbi->dbi_verify_on_close = 0;
01401 (void) db3close(dbi, 0);
01402 }
01403
01404 urlfn = _free(urlfn);
01405
01406
01407 return rc;
01408
01409 }
01410
01413
01414
01415 struct _dbiVec db3vec = {
01416 DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
01417 db3open, db3close, db3sync, db3associate, db3join,
01418 db3copen, db3cclose, db3cdup, db3cdel, db3cget, db3cpget, db3cput, db3ccount,
01419 db3byteswapped, db3stat
01420 };
01421
01422