diff options
-rw-r--r-- | lib/db3.c | 193 | ||||
-rw-r--r-- | lib/rpmdb.c | 92 | ||||
-rw-r--r-- | lib/rpmdb.h | 51 | ||||
-rw-r--r-- | lib/rpmlib.h | 2 | ||||
-rw-r--r-- | po/rpm.pot | 38 |
5 files changed, 234 insertions, 142 deletions
@@ -18,6 +18,7 @@ static int __do_dbcursor_rmw = 0; extern int __do_dbenv_remove; /* XXX in dbindex.c, shared with rebuilddb.c */ +#ifdef DYING /* XXX dbenv parameters */ static int db_lorder = 0; /* 0 is native order */ static void (*db_errcall) (const char *db_errpfx, char *buffer) = NULL; @@ -37,6 +38,7 @@ static u_int32_t (*dbh_hash) (const void *, u_int32_t) = NULL; static u_int32_t dbh_ffactor = 0; /* db1 default: 8 */ static u_int32_t dbh_nelem = 0; /* db1 default: 1 */ static u_int32_t dbh_flags = 0; +#endif #define _mymemset(_a, _b, _c) memset((_a), (_b), (_c)) @@ -287,14 +289,15 @@ static int db_fini(dbiIndex dbi) static int db_init(dbiIndex dbi, const char *dbhome, int dbflags, DB_ENV **dbenvp) { + rpmdb rpmdb = dbi->dbi_rpmdb; DB_ENV *dbenv = NULL; int mydbopenflags; int rc; if (dbenvp == NULL) return 1; - if (db_errfile == NULL) - db_errfile = stderr; + if (rpmdb->db_errfile == NULL) + rpmdb->db_errfile = stderr; rc = db_env_create(&dbenv, 0); rc = cvtdberr(dbi, "db_env_create", rc, _debug); @@ -303,32 +306,32 @@ static int db_init(dbiIndex dbi, const char *dbhome, int dbflags, #if defined(__USE_DB3) { int xx; - dbenv->set_errcall(dbenv, db_errcall); - dbenv->set_errfile(dbenv, db_errfile); - dbenv->set_errpfx(dbenv, db_errpfx); + dbenv->set_errcall(dbenv, rpmdb->db_errcall); + dbenv->set_errfile(dbenv, rpmdb->db_errfile); + dbenv->set_errpfx(dbenv, rpmdb->db_errpfx); /* dbenv->set_paniccall(???) */ - dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT, db_verbose); - dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, db_verbose); - dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, db_verbose); - dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR, db_verbose); + dbenv->set_verbose(dbenv, DB_VERB_CHKPOINT, rpmdb->db_verbose); + dbenv->set_verbose(dbenv, DB_VERB_DEADLOCK, rpmdb->db_verbose); + dbenv->set_verbose(dbenv, DB_VERB_RECOVERY, rpmdb->db_verbose); + dbenv->set_verbose(dbenv, DB_VERB_WAITSFOR, rpmdb->db_verbose); /* dbenv->set_lg_max(???) */ /* dbenv->set_lk_conflicts(???) */ /* dbenv->set_lk_detect(???) */ /* dbenv->set_lk_max(???) */ - xx = dbenv->set_mp_mmapsize(dbenv, dbmp_mmapsize); + xx = dbenv->set_mp_mmapsize(dbenv, rpmdb->db_mp_mmapsize); xx = cvtdberr(dbi, "dbenv->set_mp_mmapsize", xx, _debug); - xx = dbenv->set_cachesize(dbenv, 0, dbmp_size, 0); + xx = dbenv->set_cachesize(dbenv, 0, rpmdb->db_mp_size, 0); xx = cvtdberr(dbi, "dbenv->set_cachesize", xx, _debug); /* dbenv->set_tx_max(???) */ /* dbenv->set_tx_recover(???) */ } #else /* __USE_DB3 */ - dbenv->db_errcall = db_errcall; - dbenv->db_errfile = db_errfile; - dbenv->db_errpfx = db_errpfx; - dbenv->db_verbose = db_verbose; - dbenv->mp_mmapsize = dbmp_mmapsize; /* XXX default is 10 Mb */ - dbenv->mp_size = dbmp_size; /* XXX default is 128 Kb */ + dbenv->db_errcall = rpmdb->db_errcall; + dbenv->db_errfile = rpmdb->db_errfile; + dbenv->db_errpfx = rpmdb->db_errpfx; + dbenv->db_verbose = rpmdb->db_verbose; + dbenv->mp_mmapsize = rpmdb->db_mp_mmapsize; /* XXX default is 10 Mb */ + dbenv->mp_size = rpmdb->db_mp_size; /* XXX default is 128 Kb */ #endif /* __USE_DB3 */ #define _DBFMASK (DB_CREATE) @@ -442,7 +445,7 @@ static int db3c_open(dbiIndex dbi, DB_TXN * txnid, DBC ** dbcp, u_int32_t flags) #else /* __USE_DB3 */ rc = db->cursor(db, txnid, dbcp); #endif /* __USE_DB3 */ - rc = cvtdberr(dbi, "db->cursor", rc, _debug); + rc = cvtdberr(dbi, "db3c_open", rc, _debug); return rc; } @@ -505,25 +508,47 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len, int i; *set = xmalloc(sizeof(**set)); - (*set)->count = data.size / sizeof(struct _dbiIR); - (*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs))); /* Convert to database internal format */ - for (i = 0; i < (*set)->count; i++) { - union _dbswap recOffset, fileNumber; - - memcpy(&recOffset.ui, sdbir, sizeof(recOffset.ui)); - sdbir += sizeof(recOffset.ui); - memcpy(&fileNumber.ui, sdbir, sizeof(fileNumber.ui)); - sdbir += sizeof(fileNumber.ui); - if (_dbbyteswapped) { - _DBSWAP(recOffset); - _DBSWAP(fileNumber); + switch (dbi->dbi_jlen) { + case 2*sizeof(int_32): + (*set)->count = data.size / (2*sizeof(int_32)); + (*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs))); + for (i = 0; i < (*set)->count; i++) { + union _dbswap recOffset, fileNumber; + + memcpy(&recOffset.ui, sdbir, sizeof(recOffset.ui)); + sdbir += sizeof(recOffset.ui); + memcpy(&fileNumber.ui, sdbir, sizeof(fileNumber.ui)); + sdbir += sizeof(fileNumber.ui); + if (_dbbyteswapped) { + _DBSWAP(recOffset); + _DBSWAP(fileNumber); + } + (*set)->recs[i].recOffset = recOffset.ui; + (*set)->recs[i].fileNumber = fileNumber.ui; + (*set)->recs[i].fpNum = 0; + (*set)->recs[i].dbNum = 0; + } + break; + default: + case 1*sizeof(int_32): + (*set)->count = data.size / (1*sizeof(int_32)); + (*set)->recs = xmalloc((*set)->count * sizeof(*((*set)->recs))); + for (i = 0; i < (*set)->count; i++) { + union _dbswap recOffset; + + memcpy(&recOffset.ui, sdbir, sizeof(recOffset.ui)); + sdbir += sizeof(recOffset.ui); + if (_dbbyteswapped) { + _DBSWAP(recOffset); + } + (*set)->recs[i].recOffset = recOffset.ui; + (*set)->recs[i].fileNumber = 0; + (*set)->recs[i].fpNum = 0; + (*set)->recs[i].dbNum = 0; } - (*set)->recs[i].recOffset = recOffset.ui; - (*set)->recs[i].fileNumber = fileNumber.ui; - (*set)->recs[i].fpNum = 0; - (*set)->recs[i].dbNum = 0; + break; } } return rc; @@ -544,7 +569,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) _mymemset(&data, 0, sizeof(data)); if (set->count) { - DBIR_t dbir = alloca(set->count * sizeof(*dbir)); + char * tdbir; int i; int _dbbyteswapped = 0; @@ -553,21 +578,42 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) #endif /* __USE_DB3 */ /* Convert to database internal format */ - for (i = 0; i < set->count; i++) { - union _dbswap recOffset, fileNumber; - - recOffset.ui = set->recs[i].recOffset; - fileNumber.ui = set->recs[i].fileNumber; - if (_dbbyteswapped) { - _DBSWAP(recOffset); - _DBSWAP(fileNumber); + + switch (dbi->dbi_jlen) { + case 2*sizeof(int_32): + data.size = set->count * (2 * sizeof(int_32)); + data.data = tdbir = alloca(data.size); + for (i = 0; i < set->count; i++) { + union _dbswap recOffset, fileNumber; + + recOffset.ui = set->recs[i].recOffset; + fileNumber.ui = set->recs[i].fileNumber; + if (_dbbyteswapped) { + _DBSWAP(recOffset); + _DBSWAP(fileNumber); + } + memcpy(tdbir, &recOffset.ui, sizeof(recOffset.ui)); + tdbir += sizeof(recOffset.ui); + memcpy(tdbir, &fileNumber.ui, sizeof(fileNumber.ui)); + tdbir += sizeof(fileNumber.ui); + } + break; + default: + case 1*sizeof(int_32): + data.size = set->count * (1 * sizeof(int_32)); + data.data = tdbir = alloca(data.size); + for (i = 0; i < set->count; i++) { + union _dbswap recOffset; + + recOffset.ui = set->recs[i].recOffset; + if (_dbbyteswapped) { + _DBSWAP(recOffset); + } + memcpy(tdbir, &recOffset.ui, sizeof(recOffset.ui)); + tdbir += sizeof(recOffset.ui); } - dbir[i].recOffset = recOffset.ui; - dbir[i].fileNumber = fileNumber.ui; + break; } - - data.data = dbir; - data.size = set->count * sizeof(*dbir); #if defined(__USE_DB2) || defined(__USE_DB3) if (!_use_cursors) { @@ -576,7 +622,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) } else { DBC * dbcursor; - rc = db3c_open(dbi, txnid, &dbcursor, DB_WRITECURSOR); + rc = db3c_open(dbi, txnid, &dbcursor, 0); if (rc) return rc; @@ -598,7 +644,7 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) } else { DBC * dbcursor; - rc = db3c_open(dbi, txnid, &dbcursor, DB_WRITECURSOR); + rc = db3c_open(dbi, txnid, &dbcursor, 0); if (rc) return rc; @@ -816,6 +862,7 @@ static int db3close(dbiIndex dbi, unsigned int flags) static int db3open(dbiIndex dbi) { + rpmdb rpmdb = dbi->dbi_rpmdb; int rc = 0; #if defined(__USE_DB2) || defined(__USE_DB3) @@ -845,32 +892,38 @@ static int db3open(dbiIndex dbi) rc = db_create(&db, dbenv, 0); rc = cvtdberr(dbi, "db_create", rc, _debug); if (rc == 0) { - if (db_lorder) { - rc = db->set_lorder(db, db_lorder); + if (rpmdb->db_lorder) { + rc = db->set_lorder(db, rpmdb->db_lorder); rc = cvtdberr(dbi, "db->set_lorder", rc, _debug); } - if (db_cachesize) { - rc = db->set_cachesize(db, 0, db_cachesize, 0); + if (rpmdb->db_cachesize) { + rc = db->set_cachesize(db, 0, rpmdb->db_cachesize, 0); rc = cvtdberr(dbi, "db->set_cachesize", rc, _debug); } - if (db_pagesize) { - rc = db->set_pagesize(db, db_pagesize); + if (rpmdb->db_pagesize) { + rc = db->set_pagesize(db, rpmdb->db_pagesize); rc = cvtdberr(dbi, "db->set_pagesize", rc, _debug); } - if (db_malloc) { - rc = db->set_malloc(db, db_malloc); + if (rpmdb->db_malloc) { + rc = db->set_malloc(db, rpmdb->db_malloc); rc = cvtdberr(dbi, "db->set_malloc", rc, _debug); } if (dbflags & DB_CREATE) { - rc = db->set_h_ffactor(db, dbh_ffactor); + rc = db->set_h_ffactor(db, rpmdb->db_h_ffactor); rc = cvtdberr(dbi, "db->set_h_ffactor", rc, _debug); - rc = db->set_h_hash(db, dbh_hash); + rc = db->set_h_hash(db, rpmdb->db_h_hash_fcn); rc = cvtdberr(dbi, "db->set_h_hash", rc, _debug); - rc = db->set_h_nelem(db, dbh_nelem); + rc = db->set_h_nelem(db, rpmdb->db_h_nelem); rc = cvtdberr(dbi, "db->set_h_nelem", rc, _debug); - rc = db->set_flags(db, dbh_flags); + } + if (rpmdb->db_h_flags) { + rc = db->set_flags(db, rpmdb->db_h_flags); rc = cvtdberr(dbi, "db->set_flags", rc, _debug); } + if (rpmdb->db_h_dup_compare_fcn) { + rc = db->set_dup_compare(db, rpmdb->db_h_dup_compare_fcn); + rc = cvtdberr(dbi, "db->set_dup_compare", rc, _debug); + } dbi->dbi_dbinfo = NULL; rc = db->open(db, "packages.db3", dbfile, dbi_to_dbtype(dbi->dbi_type), dbflags, dbi->dbi_perms); @@ -889,15 +942,15 @@ static int db3open(dbiIndex dbi) } #else { DB_INFO * dbinfo = xcalloc(1, sizeof(*dbinfo)); - dbinfo->db_cachesize = db_cachesize; - dbinfo->db_lorder = db_lorder; - dbinfo->db_pagesize = db_pagesize; - dbinfo->db_malloc = db_malloc; + dbinfo->db_cachesize = rpmdb->db_cachesize; + dbinfo->db_lorder = rpmdb->db_lorder; + dbinfo->db_pagesize = rpmdb->db_pagesize; + dbinfo->db_malloc = rpmdb->db_malloc; if (dbflags & DB_CREATE) { - dbinfo->h_ffactor = dbh_ffactor; - dbinfo->h_hash = dbh_hash; - dbinfo->h_nelem = dbh_nelem; - dbinfo->flags = dbh_flags; + dbinfo->h_ffactor = rpmdb->db_h_ffactor; + dbinfo->h_hash = rpmdb->db_h_hash_fcn; + dbinfo->h_nelem = rpmdb->db_h_nelem; + dbinfo->flags = rpmdb->db_h_flags; } dbi->dbi_dbinfo = dbinfo; rc = db_open(dbfile, dbi_to_dbtype(dbi->dbi_type), dbflags, diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 62cdfcd25..891a0949a 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -26,28 +26,28 @@ extern int _useDbiMajor; #define _DBI_MAJOR -1 struct _dbiIndex rpmdbi[] = { - { "packages.rpm", 0, + { "packages.rpm", 0, 0*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "nameindex.rpm", RPMTAG_NAME, + { "nameindex.rpm", RPMTAG_NAME, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "fileindex.rpm", RPMTAG_BASENAMES, + { "fileindex.rpm", RPMTAG_BASENAMES, 2*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "groupindex.rpm", RPMTAG_GROUP, + { "groupindex.rpm", RPMTAG_GROUP, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "requiredby.rpm", RPMTAG_REQUIRENAME, + { "requiredby.rpm", RPMTAG_REQUIRENAME, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "providesindex.rpm", RPMTAG_PROVIDENAME, + { "providesindex.rpm", RPMTAG_PROVIDENAME, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "conflictsindex.rpm", RPMTAG_CONFLICTNAME, + { "conflictsindex.rpm", RPMTAG_CONFLICTNAME, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, - { "triggerindex.rpm", RPMTAG_TRIGGERNAME, + { "triggerindex.rpm", RPMTAG_TRIGGERNAME, 1*sizeof(int_32), DBI_HASH, _DBI_FLAGS, _DBI_PERMS, _DBI_MAJOR, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }, { NULL } @@ -256,7 +256,7 @@ static struct _dbiVec *mydbvecs[] = { * @param dbiTemplate template to initialize new dbiIndex * @return index database handle */ -static dbiIndex dbiOpenIndex(const char * urlfn, int flags, const dbiIndex dbiTemplate) +static dbiIndex dbiOpenIndex(rpmdb rpmdb, const char * urlfn, int flags, const dbiIndex dbiTemplate) { dbiIndex dbi; const char * filename; @@ -272,6 +272,7 @@ static dbiIndex dbiOpenIndex(const char * urlfn, int flags, const dbiIndex dbiTe dbi->dbi_file = xstrdup(filename); dbi->dbi_flags = flags; dbi->dbi_major = _useDbiMajor; + dbi->dbi_rpmdb = rpmdb; switch (dbi->dbi_major) { case 3: @@ -347,33 +348,6 @@ void dbiFreeIndexSet(dbiIndexSet set) { /* XXX the signal handling in here is not thread safe */ -/* the requiredbyIndex isn't stricly necessary. In a perfect world, we could - have each header keep a list of packages that need it. However, we - can't reserve space in the header for extra information so all of the - required packages would move in the database every time a package was - added or removed. Instead, each package (or virtual package) name - keeps a list of package offsets of packages that might depend on this - one. Version numbers still need verification, but it gets us in the - right area w/o a linear search through the database. */ - -struct rpmdb_s { - const char * db_root; - const char * db_home; - int db_flags; - DBI_TYPE db_type; - int db_mode; - int db_perms; - int db_major; - int db_mp_mmapsize; - int db_mp_size; - int db_cachesize; - int db_pagesize; - unsigned int db_h_ffactor; - unsigned int db_h_nelem; - unsigned int db_h_flags; - dbiIndex _dbi[RPMDBI_MAX]; -}; - static sigset_t signalMask; static void blockSignals(void) @@ -396,19 +370,34 @@ static void unblockSignals(void) #define _DB_MODE 0 #define _DB_PERMS 0644 #define _DB_MAJOR -1 + +#define _DB_LORDER 0 +#define _DB_ERRCALL NULL +#define _DB_ERRFILE NULL +#define _DB_ERRPFX "rpmdb" +#define _DB_VERBOSE 1 + #define _DB_MP_MMAPSIZE 16 * 1024 * 1024 #define _DB_MP_SIZE 2 * 1024 * 1024 #define _DB_CACHESIZE 0 #define _DB_PAGESIZE 0 +#define _DB_MALLOC NULL #define _DB_H_FFACTOR 0 +#define _DB_H_HASH_FCN NULL #define _DB_H_NELEM 0 -#define _DB_H_FLAGS 0 +#define _DB_H_FLAGS 0 /* DB_DUP, DB_DUPSORT */ +#define _DB_H_DUP_COMPARE_FCN NULL + +#define _DB_NDBI 0 static struct rpmdb_s dbTemplate = { _DB_ROOT, _DB_HOME, _DB_FLAGS, _DB_TYPE, _DB_MODE, _DB_PERMS, - _DB_MAJOR, _DB_MP_MMAPSIZE, _DB_MP_SIZE, _DB_CACHESIZE, _DB_PAGESIZE, - _DB_H_FFACTOR, _DB_H_NELEM, _DB_H_FLAGS + _DB_MAJOR, _DB_LORDER, _DB_ERRCALL, _DB_ERRFILE, _DB_ERRPFX, _DB_VERBOSE, + _DB_MP_MMAPSIZE, _DB_MP_SIZE, + _DB_CACHESIZE, _DB_PAGESIZE, _DB_MALLOC, + _DB_H_FFACTOR, _DB_H_HASH_FCN, _DB_H_NELEM, _DB_H_FLAGS, + _DB_NDBI }; /* XXX query.c, rebuilddb.c, rpminstall.c, verify.c */ @@ -416,12 +405,16 @@ void rpmdbClose (rpmdb db) { int dbix; - for (dbix = RPMDBI_MAX; --dbix >= RPMDBI_MIN; ) { + for (dbix = db->db_ndbi; --dbix >= RPMDBI_MIN; ) { if (db->_dbi[dbix] == NULL) continue; dbiCloseIndex(db->_dbi[dbix]); db->_dbi[dbix] = NULL; } + if (db->db_errpfx) { + xfree(db->db_errpfx); + db->db_root = NULL; + } if (db->db_root) { xfree(db->db_root); db->db_root = NULL; @@ -459,6 +452,9 @@ static /*@only@*/ rpmdb newRpmdb(const char * root, const char * home, goto errxit; } } + if (db->db_errpfx) + db->db_errpfx = xstrdup(db->db_errpfx); + db->db_ndbi = RPMDBI_MAX; return db; errxit: @@ -486,7 +482,7 @@ int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp, { int dbix; rc = 0; - for (dbix = RPMDBI_MIN; rc == 0 && dbix < RPMDBI_MAX; dbix++) { + for (dbix = RPMDBI_MIN; rc == 0 && dbix < db->db_ndbi; dbix++) { dbiIndex dbiTemplate; dbiIndex dbi; const char * filename; @@ -497,12 +493,11 @@ int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp, dbiTemplate->dbi_basename); if (!justCheck || !rpmfileexists(filename)) { - db->_dbi[dbix] = dbiOpenIndex(filename, db->db_mode, dbiTemplate); + db->_dbi[dbix] = dbiOpenIndex(db, filename, db->db_mode, dbiTemplate); } if ((dbi = db->_dbi[dbix]) == NULL) continue; - dbi->dbi_rpmdb = db; switch (dbix) { case 1: @@ -690,11 +685,6 @@ static int rpmdbFindByFile(rpmdb db, const char * filespec, return 0; } -/* XXX python/upgrade.c, python/rpmmodule.c */ -int rpmdbFindPackage(rpmdb db, const char * name, dbiIndexSet * matches) { - return dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, matches); -} - /* XXX python/upgrade.c, install.c, uninstall.c */ int rpmdbCountPackages(rpmdb db, const char * name) { @@ -1077,7 +1067,7 @@ int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant) { int dbix; dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0); - for (dbix = RPMDBI_MIN; dbix < RPMDBI_MAX; dbix++) { + for (dbix = RPMDBI_MIN; dbix < db->db_ndbi; dbix++) { dbiIndex dbi; const char **rpmvals = NULL; int rpmtype = 0; @@ -1261,7 +1251,7 @@ int rpmdbAdd(rpmdb db, Header h) { int dbix; dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0); - for (dbix = RPMDBI_MIN; dbix < RPMDBI_MAX; dbix++) { + for (dbix = RPMDBI_MIN; dbix < db->db_ndbi; dbix++) { const char **rpmvals = NULL; int rpmtype = 0; int rpmcnt = 0; @@ -1608,7 +1598,7 @@ int findMatches(rpmdb db, const char * name, const char * version, int rc; int i; - if ((rc = rpmdbFindPackage(db, name, matches))) { + if ((rc = dbiSearchIndex(db->_dbi[RPMDBI_NAME], name, 0, matches)) != 0) { rc = ((rc == -1) ? 2 : 1); goto exit; } diff --git a/lib/rpmdb.h b/lib/rpmdb.h index 57344d04a..0a3036387 100644 --- a/lib/rpmdb.h +++ b/lib/rpmdb.h @@ -24,8 +24,8 @@ typedef /*@abstract@*/ struct _dbiIndex * dbiIndex; struct _dbiIndexRecord { unsigned int recOffset; /*!< byte offset of header in db */ unsigned int fileNumber; /*!< file array index */ - int fpNum; /*!< finger print index */ - int dbNum; /*!< database index */ + unsigned int fpNum; /*!< finger print index */ + unsigned int dbNum; /*!< database index */ }; /** @@ -153,11 +153,13 @@ struct _dbiVec { struct _dbiIndex { const char *dbi_basename; /*<! last component of name */ int dbi_rpmtag; /*<! rpm tag used for index */ + int dbi_jlen; /*<! size of join key */ DBI_TYPE dbi_type; /*<! type of access */ int dbi_flags; /*<! flags to use on open */ int dbi_perms; /*<! file permission to use on open */ int dbi_major; /*<! Berkeley db version major */ + unsigned int dbi_lastoffset; /*<! db0 with falloc.c needs this */ rpmdb dbi_rpmdb; @@ -171,6 +173,44 @@ struct _dbiIndex { /*@observer@*/ const struct _dbiVec * dbi_vec; /*<! private methods */ }; +/* XXX hack to get dup_compare prototype correct */ +#if !defined(DB_VERSION_MAJOR) +#define DBT void +#endif + +/** + * Describes the collection of index databases used by rpm. + */ +struct rpmdb_s { + const char * db_root; /*<! path prefix */ + const char * db_home; /*<! directory path */ + int db_flags; /*<! */ + DBI_TYPE db_type; /*<! db index type */ + int db_mode; /*<! open mode */ + int db_perms; /*<! open permissions */ + int db_major; /*<! Berkeley API type */ + /* dbenv parameters */ + int db_lorder; + void (*db_errcall) (const char *db_errpfx, char *buffer); + FILE * db_errfile; + const char * db_errpfx; + int db_verbose; + int db_mp_mmapsize; /*<! (10Mb) */ + int db_mp_size; /*<! (128Kb) */ + /* dbinfo parameters */ + int db_cachesize; /*<! */ + int db_pagesize; /*<! (fs blksize) */ + void * (*db_malloc) (size_t nbytes); + /* hash access parameters */ + unsigned int db_h_ffactor; /*<! */ + unsigned int (*db_h_hash_fcn) (const void *bytes, u_int32_t length); + unsigned int db_h_nelem; /*<! */ + unsigned int db_h_flags; /*<! DB_DUP, DB_DUPSORT */ + int (*db_h_dup_compare_fcn) (const DBT *, const DBT *); + int db_ndbi; + dbiIndex _dbi[16]; /*<! >= RPMDBI_MAX */ +}; + /* for RPM's internal use only */ #define RPMDB_FLAG_JUSTCHECK (1 << 0) @@ -210,12 +250,19 @@ void rpmdbRemoveDatabase(const char * rootdir, const char * dbpath); int rpmdbMoveDatabase(const char * rootdir, const char * olddbpath, const char * newdbpath); /** + */ +unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi); + +/** * @param db rpm database */ int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList, int numItems); /* XXX only for the benefit of runTransactions() */ +/** + * @param db rpm database + */ int findMatches(rpmdb db, const char * name, const char * version, const char * release, /*@out@*/ dbiIndexSet * matches); diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 6b9f66247..b7ad42537 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -368,10 +368,12 @@ int rpmdbOpen (const char * root, /*@out@*/ rpmdb * dbp, int mode, int perms); /* 0 on error */ int rpmdbInit(const char * root, int perms); /* nonzero on error */ + /** * @param db rpm database */ void rpmdbClose ( /*@only@*/ rpmdb db); + /* Databases like this should only have rpmdb*RecNum and rpmdbGetRecord used on them. Anything else could fail! */ /** diff --git a/po/rpm.pot b/po/rpm.pot index c605cbea1..9c374e5bc 100644 --- a/po/rpm.pot +++ b/po/rpm.pot @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" -"POT-Creation-Date: 2000-04-18 14:17-0400\n" +"POT-Creation-Date: 2000-04-19 09:49-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Language-Team: LANGUAGE <LL@li.org>\n" @@ -2676,7 +2676,7 @@ msgstr "" msgid "display a verbose file listing" msgstr "" -#: lib/rebuilddb.c:34 lib/rpmdb.c:458 +#: lib/rebuilddb.c:34 lib/rpmdb.c:451 msgid "no dbpath has been set" msgstr "" @@ -2841,7 +2841,7 @@ msgstr "" msgid "bad db file %s" msgstr "" -#: lib/rpmdb.c:307 +#: lib/rpmdb.c:308 msgid "" "\n" "--> Please run \"rpm --rebuilddb\" as root to convert your database from\n" @@ -2849,83 +2849,83 @@ msgid "" "\n" msgstr "" -#: lib/rpmdb.c:320 +#: lib/rpmdb.c:321 #, c-format msgid "cannot open file %s: %s" msgstr "" -#: lib/rpmdb.c:528 +#: lib/rpmdb.c:523 msgid "" "old format database is present; use --rebuilddb to generate a new format " "database" msgstr "" #. error -#: lib/rpmdb.c:709 +#: lib/rpmdb.c:699 #, c-format msgid "cannot retrieve package \"%s\" from db" msgstr "" -#: lib/rpmdb.c:1031 +#: lib/rpmdb.c:1021 #, c-format msgid "key \"%s\" not found in %s" msgstr "" -#: lib/rpmdb.c:1039 +#: lib/rpmdb.c:1029 #, c-format msgid "key \"%s\" not removed from %s" msgstr "" -#: lib/rpmdb.c:1065 +#: lib/rpmdb.c:1055 #, c-format msgid "rpmdbRemove: cannot read header at 0x%x" msgstr "" -#: lib/rpmdb.c:1096 +#: lib/rpmdb.c:1086 #, c-format msgid "removing 0 %s entries.\n" msgstr "" -#: lib/rpmdb.c:1103 +#: lib/rpmdb.c:1093 #, c-format msgid "removing \"%s\" from %s index.\n" msgstr "" -#: lib/rpmdb.c:1111 +#: lib/rpmdb.c:1101 #, c-format msgid "removing %d entries in %s index:\n" msgstr "" -#: lib/rpmdb.c:1115 +#: lib/rpmdb.c:1105 #, c-format msgid "\t%6d %s\n" msgstr "" -#: lib/rpmdb.c:1255 +#: lib/rpmdb.c:1245 msgid "cannot allocate new instance in database" msgstr "" -#: lib/rpmdb.c:1301 +#: lib/rpmdb.c:1291 #, c-format msgid "adding 0 %s entries.\n" msgstr "" -#: lib/rpmdb.c:1314 +#: lib/rpmdb.c:1304 #, c-format msgid "adding \"%s\" to %s index.\n" msgstr "" -#: lib/rpmdb.c:1321 +#: lib/rpmdb.c:1311 #, c-format msgid "adding %d entries to %s index:\n" msgstr "" -#: lib/rpmdb.c:1325 +#: lib/rpmdb.c:1315 #, c-format msgid "%6d %s\n" msgstr "" -#: lib/rpmdb.c:1637 +#: lib/rpmdb.c:1626 #, c-format msgid "cannot read header at %d for lookup" msgstr "" |