summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Makefile.am2
-rw-r--r--lib/db0.c314
-rw-r--r--lib/db3.c791
-rw-r--r--lib/depends.c50
-rw-r--r--lib/header.c4
-rw-r--r--lib/rpmdb.c158
-rw-r--r--lib/rpmdb.h127
-rw-r--r--lib/rpmmalloc.c15
-rw-r--r--macros.in15
-rw-r--r--po/rpm.pot180
-rw-r--r--rpmio/rpmmalloc.c15
-rw-r--r--system.h10
12 files changed, 915 insertions, 766 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 776d29585..4583365e6 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -35,7 +35,7 @@ falloc.lo: falloc.c $(top_srcdir)/system.h rpmio.h falloc.h
db3.lo: db3.c $(top_srcdir)/system.h rpmlib.h rpmdb.h
$(LIBTOOL) --mode=compile $(COMPILE) -c $<
for F in $*.o $*.lo ; do \
- @__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb-3.0 ; \
+ @__LD@ -r -o $${F}.o $${F} -L/usr/lib -ldb-3.0 -lpthread ; \
@__OBJCOPY@ `\
@__NM@ -g --defined-only $${F}.o | \
sed -e '/ [DRTW] /!d' -e 's/.* [DRTW] /-L /' | \
diff --git a/lib/db0.c b/lib/db0.c
index 159699e7a..ae5800fcd 100644
--- a/lib/db0.c
+++ b/lib/db0.c
@@ -18,6 +18,7 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#include "falloc.h"
#include "misc.h"
+#define DBC void
#include "rpmdb.h"
/*@access dbiIndex@*/
/*@access dbiIndexSet@*/
@@ -77,55 +78,11 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit) {
return rc;
}
-#if defined(__USE_DB2)
-static int db_init(const char *home, int dbflags,
- DB_ENV **dbenvp, DB_INFO **dbinfop)
-{
- DB_ENV *dbenv = xcalloc(1, sizeof(*dbenv));
- DB_INFO *dbinfo = xcalloc(1, sizeof(*dbinfo));
- int rc;
-
- if (dbenvp) *dbenvp = NULL;
- if (dbinfop) *dbinfop = NULL;
-
- dbenv->db_errfile = stderr;
- dbenv->db_errpfx = "rpmdb";
- dbenv->mp_size = 1024 * 1024;
-
- rc = db_appinit(home, NULL, dbenv, dbflags);
- if (rc)
- goto errxit;
-
- dbinfo->db_pagesize = 1024;
-
- if (dbenvp)
- *dbenvp = dbenv;
- else
- free(dbenv);
-
- if (dbinfop)
- *dbinfop = dbinfo;
- else
- free(dbinfo);
-
- return 0;
-
-errxit:
- if (dbenv) free(dbenv);
- if (dbinfo) free(dbinfo);
- return rc;
-}
-#endif
-
static int db0sync(dbiIndex dbi, unsigned int flags) {
DB * db = GetDB(dbi);
int rc;
-#if defined(__USE_DB2)
- rc = db->sync(db, flags);
-#else
rc = db->sync(db, flags);
-#endif
switch (rc) {
default:
@@ -143,6 +100,11 @@ static int db0sync(dbiIndex dbi, unsigned int flags) {
return rc;
}
+static int db0byteswapped(dbiIndex dbi)
+{
+ return 0;
+}
+
static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len,
dbiIndexSet * set)
{
@@ -160,11 +122,7 @@ static int db0SearchIndex(dbiIndex dbi, const void * str, size_t len,
data.data = NULL;
data.size = 0;
-#if defined(__USE_DB2)
- rc = db->get(db, NULL, &key, &data, 0);
-#else
rc = db->get(db, &key, &data, 0);
-#endif
switch (rc) {
default:
@@ -231,11 +189,7 @@ static int db0UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
data.data = dbir;
data.size = set->count * sizeof(*dbir);
-#if defined(__USE_DB2)
- rc = db->put(db, NULL, &key, &data, 0);
-#else
rc = db->put(db, &key, &data, 0);
-#endif
switch (rc) {
default:
@@ -249,11 +203,7 @@ static int db0UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set) {
}
} else {
-#if defined(__USE_DB2)
- rc = db->del(db, NULL, &key, 0);
-#else
rc = db->del(db, &key, 0);
-#endif
switch (rc) {
default:
@@ -283,15 +233,19 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
h = headerRead(pkgs, HEADER_MAGIC_NO);
- if (h == NULL) return NULL;
+ if (h == NULL)
+ goto exit;
- /* the RPM used to build much of RH 5.1 could produce packages whose
- file lists did not have leading /'s. Now is a good time to fix
- that */
+ /*
+ * The RPM used to build much of RH 5.1 could produce packages whose
+ * file lists did not have leading /'s. Now is a good time to fix that.
+ */
- /* If this tag isn't present, either no files are in the package or
- we're dealing with a package that has just the compressed file name
- list */
+ /*
+ * If this tag isn't present, either no files are in the package or
+ * we're dealing with a package that has just the compressed file name
+ * list.
+ */
if (!headerGetEntryMinMemory(h, RPMTAG_OLDFILENAMES, NULL,
(void **) &fileNames, &fileCount)) goto exit;
@@ -319,41 +273,29 @@ static void * doGetRecord(FD_t pkgs, unsigned int offset)
newFileNames, fileCount);
}
- /* The file list was moved to a more compressed format which not
- only saves memory (nice), but gives fingerprinting a nice, fat
- speed boost (very nice). Go ahead and convert old headers to
- the new style (this is a noop for new headers) */
+ /*
+ * The file list was moved to a more compressed format which not
+ * only saves memory (nice), but gives fingerprinting a nice, fat
+ * speed boost (very nice). Go ahead and convert old headers to
+ * the new style (this is a noop for new headers).
+ */
compressFilelist(h);
exit:
- uh = headerUnload(h);
- headerFree(h);
+ if (h) {
+ uh = headerUnload(h);
+ headerFree(h);
+ }
return uh;
}
static int db0copen(dbiIndex dbi) {
int rc = 0;
-#if defined(__USE_DB2)
- { DBC * dbcursor = NULL;
- rc = dbp->cursor(dbp, NULL, &dbcursor, 0);
- if (rc == 0)
- dbi->dbi_dbcursor = dbcursor;
- }
-#endif
- dbi->dbi_lastoffset = 0;
return rc;
}
static int db0cclose(dbiIndex dbi) {
int rc = 0;
-#if defined(__USE_DB2)
-#endif
- dbi->dbi_lastoffset = 0;
- return rc;
-}
-
-static int db0join(dbiIndex dbi) {
- int rc = 1;
return rc;
}
@@ -361,72 +303,90 @@ static int db0cget(dbiIndex dbi, void ** keyp, size_t * keylen,
void ** datap, size_t * datalen)
{
DBT key, data;
- DB * db;
- int rc;
+ int rc = 0;
if (dbi == NULL)
return 1;
- if (dbi->dbi_pkgs) {
- if (dbi->dbi_lastoffset == 0) {
- dbi->dbi_lastoffset = fadFirstOffset(dbi->dbi_pkgs);
- } else {
- dbi->dbi_lastoffset = fadNextOffset(dbi->dbi_pkgs, dbi->dbi_lastoffset);
- }
- if (keyp)
- *keyp = &dbi->dbi_lastoffset;
- if (keylen)
- *keylen = sizeof(dbi->dbi_lastoffset);
- return 0;
- }
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ if (keyp) key.data = *keyp;
+ if (keylen) key.size = *keylen;
+ if (datap) data.data = *datap;
+ if (datalen) data.size = *datalen;
- if (dbi->dbi_db == NULL)
- return 1;
- db = GetDB(dbi);
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
+ if (dbi->dbi_rpmtag == 0) {
+ unsigned int offset;
+ unsigned int newSize;
- key.data = NULL;
- key.size = 0;
+ if (key.data == NULL) { /* XXX simulated DB_NEXT */
+ if (dbi->dbi_lastoffset == 0) {
+ dbi->dbi_lastoffset = fadFirstOffset(dbi->dbi_pkgs);
+ } else {
+ dbi->dbi_lastoffset = fadNextOffset(dbi->dbi_pkgs, dbi->dbi_lastoffset);
+ }
+ key.data = &dbi->dbi_lastoffset;
+ key.size = sizeof(dbi->dbi_lastoffset);
+ }
-#if defined(__USE_DB2)
- { DBC * dbcursor;
+ memcpy(&offset, key.data, sizeof(offset));
+ /* XXX hack to pass sizeof header to fadAlloc */
+ newSize = data.size;
- if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
- rc = db2copen(dbi);
- if (rc)
- return rc;
- dbcursor = dbi->dbi_dbcursor;
+ if (offset == 0) { /* XXX simulated offset 0 record */
+ offset = fadAlloc(dbi->dbi_pkgs, newSize);
+ if (offset == 0)
+ return -1;
+ offset--; /* XXX hack: caller will increment */
+ /* XXX hack: return offset as data, free in db0cput */
+ data.data = xmalloc(sizeof(offset));
+ memcpy(data.data, &offset, sizeof(offset));
+ data.size = sizeof(offset);
+ } else { /* XXX simulated retrieval */
+ data.data = doGetRecord(dbi->dbi_pkgs, offset);
+ data.size = 0; /* XXX WRONG */
+ if (data.data == NULL)
+ rc = 1;
}
+ } else {
+ DB * db;
+ int _printit;
+
+ if ((db = dbi->dbi_db) == NULL)
+ return 1;
- rc = dbcursor->c_get(dbcursor, &key, &data,
- (dbi->dbi_lastoffset++ ? DB_NEXT : DB_FIRST));
- if (rc == DB_NOTFOUND)
- db2cclose(dbcursor)
+ if (key.data == NULL) {
+ rc = db->seq(db, &key, &data, (dbi->dbi_lastoffset++ ? R_NEXT : R_FIRST));
+ _printit = (rc == 1 ? 0 : _debug);
+ rc = cvtdberr(dbi, "db->seq", rc, _printit);
+ } else {
+ rc = db->get(db, &key, &data, 0);
+ _printit = (rc == 1 ? 0 : _debug);
+ rc = cvtdberr(dbi, "db0cget", rc, _printit);
+ }
}
-#else
- rc = db->seq(db, &key, &data, (dbi->dbi_lastoffset++ ? R_NEXT : R_FIRST));
-#endif
switch (rc) {
default:
case RET_ERROR: /* -1 */
+ rc = -1;
+ break;
case RET_SPECIAL: /* 1 */
rc = 1;
- if (keyp)
- *keyp = NULL;
break;
case RET_SUCCESS: /* 0 */
rc = 0;
- if (keyp)
- *keyp = key.data;
+ if (keyp) *keyp = key.data;
+ if (keylen) *keylen = key.size;
+ if (datap) *datap = data.data;
+ if (datalen) *datalen = data.size;
break;
}
return rc;
}
-static int db0del(dbiIndex dbi, void * keyp, size_t keylen)
+static int db0cdel(dbiIndex dbi, void * keyp, size_t keylen)
{
int rc = 0;
@@ -450,80 +410,86 @@ static int db0del(dbiIndex dbi, void * keyp, size_t keylen)
return rc;
}
+#ifndef DYING
static int db0get(dbiIndex dbi, void * keyp, size_t keylen,
void ** datap, size_t * datalen)
{
- unsigned int newSize = 0;
+ DBT key, data;
int rc = 0;
- if (datap) *datap = NULL;
- if (datalen) {
- /* XXX hack to pass sizeof header to fadAlloc */
- newSize = *datalen;
- *datalen = 0;
- }
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ if (keyp) key.data = keyp;
+ if (keylen) key.size = keylen;
+ if (datap) data.data = *datap;
+ if (datalen) data.size = *datalen;
if (dbi->dbi_rpmtag == 0) {
unsigned int offset;
+ unsigned int newSize;
- memcpy(&offset, keyp, sizeof(offset));
+ memcpy(&offset, key.data, sizeof(offset));
+ /* XXX hack to pass sizeof header to fadAlloc */
+ newSize = data.size;
- if (offset == 0) {
+ if (offset == 0) { /* XXX simulated offset 0 record */
offset = fadAlloc(dbi->dbi_pkgs, newSize);
if (offset == 0)
return -1;
offset--; /* XXX hack: caller will increment */
- *datap = xmalloc(sizeof(offset));
- memcpy(*datap, &offset, sizeof(offset));
- *datalen = sizeof(offset);
- } else {
- void * uh = doGetRecord(dbi->dbi_pkgs, offset);
- if (uh == NULL)
- return 1;
- if (datap)
- *datap = uh;
- if (datalen)
- *datalen = 0; /* XXX WRONG */
+ /* XXX hack: return offset as data, free in db0cput */
+ data.data = xmalloc(sizeof(offset));
+ memcpy(data.data, &offset, sizeof(offset));
+ data.size = sizeof(offset);
+ } else { /* XXX simulated retrieval */
+ data.data = doGetRecord(dbi->dbi_pkgs, offset);
+ data.size = 0; /* XXX WRONG */
+ if (data.data == NULL)
+ rc = 1;
}
} else {
- DBT key, data;
DB * db = GetDB(dbi);
-
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
-
- key.data = keyp;
- key.size = keylen;
- data.data = NULL;
- data.size = 0;
+ int _printit;
rc = db->get(db, &key, &data, 0);
- rc = cvtdberr(dbi, "db->get", rc, _debug);
+ _printit = (rc == 1 ? 0 : _debug);
+ rc = cvtdberr(dbi, "db0get", rc, _printit);
+ }
- if (rc == 0) {
- *datap = data.data;
- *datalen = data.size;
- }
+ if (rc == 0) {
+ if (datap) *datap = data.data;
+ if (datalen) *datalen = data.size;
}
return rc;
}
+#endif /* DYING */
-static int db0put(dbiIndex dbi, void * keyp, size_t keylen,
+static int db0cput(dbiIndex dbi, void * keyp, size_t keylen,
void * datap, size_t datalen)
{
+ DBT key, data;
int rc = 0;
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ key.data = keyp;
+ key.size = keylen;
+ data.data = datap;
+ data.size = datalen;
+
if (dbi->dbi_rpmtag == 0) {
unsigned int offset;
- memcpy(&offset, keyp, sizeof(offset));
+ memcpy(&offset, key.data, sizeof(offset));
- if (offset == 0) {
- if (datalen == sizeof(offset))
- free(datap);
- } else {
- Header h = headerLoad(datap);
+ if (offset == 0) { /* XXX simulated offset 0 record */
+ /* XXX hack: return offset as data, free in db0cput */
+ if (data.size == sizeof(offset)) {
+ free(data.data);
+ }
+ } else { /* XXX simulated DB_KEYLAST */
+ Header h = headerLoad(data.data);
int newSize = headerSizeof(h, HEADER_MAGIC_NO);
(void)Fseek(dbi->dbi_pkgs, offset, SEEK_SET);
@@ -535,17 +501,8 @@ static int db0put(dbiIndex dbi, void * keyp, size_t keylen,
headerFree(h);
}
} else {
- DBT key, data;
DB * db = GetDB(dbi);
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
-
- key.data = keyp;
- key.size = keylen;
- data.data = datap;
- data.size = datalen;
-
rc = db->put(db, &key, &data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
}
@@ -646,11 +603,11 @@ static int db0open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
}
exit:
- if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
+ if (rc == 0 && dbip) {
rc = 0;
*dbip = dbi;
if (_debug < 0)
-fprintf(stderr, "*** db%dopen: %s\n", dbi->dbi_major, urlfn);
+fprintf(stderr, "*** db%dopen: rpmtag %d dbi %p %s\n", dbi->dbi_major, rpmtag, dbi, urlfn);
} else {
rc = 1;
db3Free(dbi);
@@ -671,5 +628,6 @@ fprintf(stderr, "*** db%dopen: %s\n", dbi->dbi_major, urlfn);
struct _dbiVec db0vec = {
DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
db0open, db0close, db0sync, db0SearchIndex, db0UpdateIndex,
- db0del, db0get, db0put, db0copen, db0cclose, db0join, db0cget
+ db0cdel, db0get, db0cput, db0copen, db0cclose, db0cdel, db0cget, db0cput,
+ db0byteswapped
};
diff --git a/lib/db3.c b/lib/db3.c
index c2f153098..3a95cf665 100644
--- a/lib/db3.c
+++ b/lib/db3.c
@@ -17,12 +17,6 @@ static const char * db3basename = "packages.db3";
#if DB_VERSION_MAJOR == 3
#define __USE_DB3 1
-#define _mymemset(_a, _b, _c) memset((_a), (_b), (_c))
-
-static inline /*@observer@*/ /*@null@*/ DB * GetDB(dbiIndex dbi) {
- return ((DB *)dbi->dbi_db);
-}
-
struct _dbiIndex db3dbi;
/* Analogue to struct poptOption */
@@ -36,32 +30,35 @@ struct dbOption {
#define _POPT_SET_BIT (POPT_ARG_VAL|POPT_ARGFLAG_OR)
struct dbOption rdbOptions[] = {
- { "recover", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_RECOVER },
- { "recover_fatal", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_RECOVER_FATAL },
-
- { "use_environ_root", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_USE_ENVIRON_ROOT },
- { "use_environ", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_USE_ENVIRON },
-
- { "create", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_CREATE },
- { "lockdown", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_LOCKDOWN },
- { "nommap", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_NOMMAP },
- { "private", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_PRIVATE },
- { "shared", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_SYSTEM_MEM },
- { "thread", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_THREAD },
- { "txn_nosync", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_TXN_NOSYNC },
-
- { "excl", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_EXCL },
- { "rdonly", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_RDONLY },
- { "truncate", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_TRUNCATE },
- { "upgrade", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_UPGRADE },
-
- { "cdb", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_INIT_CDB },
- { "lock", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_INIT_LOCK },
- { "log", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_INIT_LOG },
- { "mpool", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_INIT_MPOOL },
- { "txn", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_INIT_TXN },
-
- { "xa_create", _POPT_SET_BIT, &db3dbi.dbi_flags, DB_XA_CREATE },
+ /* XXX DB_CXX_NO_EXCEPTIONS */
+ { "xa_create", _POPT_SET_BIT, &db3dbi.dbi_cflags, DB_XA_CREATE },
+
+ { "create", _POPT_SET_BIT, &db3dbi.dbi_oeflags, DB_CREATE },
+ { "nommap", _POPT_SET_BIT, &db3dbi.dbi_oeflags, DB_NOMMAP },
+ { "thread", _POPT_SET_BIT, &db3dbi.dbi_oeflags, DB_THREAD },
+
+ { "force", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_FORCE },
+ { "cdb", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_INIT_CDB },
+ { "lock", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_INIT_LOCK },
+ { "log", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_INIT_LOG },
+ { "mpool", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_INIT_MPOOL },
+ { "txn", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_INIT_TXN },
+ { "recover", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_RECOVER },
+ { "recover_fatal", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_RECOVER_FATAL },
+ { "shared", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_SYSTEM_MEM },
+ { "txn_nosync", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_TXN_NOSYNC },
+ { "use_environ_root", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_USE_ENVIRON_ROOT },
+ { "use_environ", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_USE_ENVIRON },
+ { "lockdown", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_LOCKDOWN },
+ { "private", _POPT_SET_BIT, &db3dbi.dbi_eflags, DB_PRIVATE },
+
+ { "txn_sync", _POPT_SET_BIT, &db3dbi.dbi_tflags, DB_TXN_SYNC },
+ { "txn_nowait",_POPT_SET_BIT, &db3dbi.dbi_tflags, DB_TXN_NOWAIT },
+
+ { "excl", _POPT_SET_BIT, &db3dbi.dbi_oflags, DB_EXCL },
+ { "rdonly", _POPT_SET_BIT, &db3dbi.dbi_oflags, DB_RDONLY },
+ { "truncate", _POPT_SET_BIT, &db3dbi.dbi_oflags, DB_TRUNCATE },
+ { "fcntl_locking",_POPT_SET_BIT, &db3dbi.dbi_oflags, DB_FCNTL_LOCKING },
{ "btree", POPT_ARG_VAL, &db3dbi.dbi_type, DB_BTREE },
{ "hash", POPT_ARG_VAL, &db3dbi.dbi_type, DB_HASH },
@@ -69,6 +66,10 @@ struct dbOption rdbOptions[] = {
{ "queue", POPT_ARG_VAL, &db3dbi.dbi_type, DB_QUEUE },
{ "unknown", POPT_ARG_VAL, &db3dbi.dbi_type, DB_UNKNOWN },
+ { "root", POPT_ARG_STRING, &db3dbi.dbi_root, 0 },
+ { "home", POPT_ARG_STRING, &db3dbi.dbi_home, 0 },
+ { "file", POPT_ARG_STRING, &db3dbi.dbi_file, 0 },
+ { "subfile", POPT_ARG_STRING, &db3dbi.dbi_subfile, 0 },
{ "mode", POPT_ARG_INT, &db3dbi.dbi_mode, 0 },
{ "perms", POPT_ARG_INT, &db3dbi.dbi_perms, 0 },
@@ -77,10 +78,11 @@ struct dbOption rdbOptions[] = {
{ "db1", POPT_ARG_VAL, &db3dbi.dbi_major, 1 },
{ "db0", POPT_ARG_VAL, &db3dbi.dbi_major, 0 },
- { "teardown",POPT_ARG_NONE, &db3dbi.dbi_tear_down, 0 },
+ { "teardown", POPT_ARG_NONE, &db3dbi.dbi_tear_down, 0 },
{ "usecursors",POPT_ARG_NONE, &db3dbi.dbi_use_cursors, 0 },
- { "rmwcursor",POPT_ARG_NONE, &db3dbi.dbi_get_rmw_cursor, 0 },
+ { "rmwcursor", POPT_ARG_NONE, &db3dbi.dbi_get_rmw_cursor, 0 },
{ "nofsync", POPT_ARG_NONE, &db3dbi.dbi_no_fsync, 0 },
+ { "temporary", POPT_ARG_NONE, &db3dbi.dbi_temporary, 0 },
{ "cachesize", POPT_ARG_INT, &db3dbi.dbi_cachesize, 0 },
{ "errpfx", POPT_ARG_STRING, &db3dbi.dbi_errpfx, 0 },
@@ -183,6 +185,10 @@ static int dbSaveInt(const struct dbOption * opt, long aLong) {
void db3Free(dbiIndex dbi) {
if (dbi) {
+ if (dbi->dbi_root) xfree(dbi->dbi_root);
+ if (dbi->dbi_home) xfree(dbi->dbi_home);
+ if (dbi->dbi_file) xfree(dbi->dbi_file);
+ if (dbi->dbi_subfile) xfree(dbi->dbi_subfile);
if (dbi->dbi_errpfx) xfree(dbi->dbi_errpfx);
if (dbi->dbi_re_source) xfree(dbi->dbi_re_source);
if (dbi->dbi_dbenv) free(dbi->dbi_dbenv);
@@ -220,8 +226,6 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
while (*o && isspace(*o))
o++;
- if (*o == '\0')
- break;
for (oe = o; oe && *oe; oe++) {
if (isspace(*oe))
break;
@@ -230,6 +234,8 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
}
if (oe && *oe)
*oe++ = '\0';
+ if (*o == '\0')
+ continue;
for (pe = o; pe && *pe && *pe != '='; pe++)
;
p = (pe ? *pe++ = '\0', pe : NULL);
@@ -254,8 +260,10 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
(void) dbSaveInt(opt, (long)opt->val);
break;
case POPT_ARG_STRING:
- *((const char **) opt->arg) = xstrdup( (p ? p : "") );
- break;
+ { const char ** t = opt->arg;
+ if (*t) xfree(*t);
+ *t = xstrdup( (p ? p : "") );
+ } break;
case POPT_ARG_INT:
case POPT_ARG_LONG:
@@ -310,7 +318,7 @@ dbiIndex db3New(rpmdb rpmdb, int rpmtag)
return dbi;
}
-static const char *const prDbiOpenFlags(int dbflags)
+static const char *const prDbiOpenFlags(int dbflags, int print_dbenv_flags)
{
static char buf[256];
struct dbOption *opt;
@@ -321,8 +329,15 @@ static const char *const prDbiOpenFlags(int dbflags)
for (opt = rdbOptions; opt->longName != NULL; opt++) {
if (opt->argInfo != _POPT_SET_BIT)
continue;
- if (opt->arg != &db3dbi.dbi_flags)
- continue;
+ if (print_dbenv_flags) {
+ if (!(opt->arg == &db3dbi.dbi_oeflags ||
+ opt->arg == &db3dbi.dbi_eflags))
+ continue;
+ } else {
+ if (!(opt->arg == &db3dbi.dbi_oeflags ||
+ opt->arg == &db3dbi.dbi_oflags))
+ continue;
+ }
if ((dbflags & opt->val) != opt->val)
continue;
if (oe != buf)
@@ -437,7 +452,8 @@ static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
rc = dbenv->close(dbenv, 0);
rc = cvtdberr(dbi, "dbenv->close", rc, _debug);
- rpmMessage(RPMMESS_DEBUG, _("closed db environment %s/%s(%s)\n"),
+ if (dbfile)
+ rpmMessage(RPMMESS_DEBUG, _("closed db environment %s/%s(%s)\n"),
dbhome, dbfile, dbsubfile);
if (rpmdb->db_remove_env || dbi->dbi_tear_down) {
@@ -448,7 +464,8 @@ static int db_fini(dbiIndex dbi, const char * dbhome, const char * dbfile,
xx = dbenv->remove(dbenv, dbhome, dbconfig, 0);
xx = cvtdberr(dbi, "dbenv->remove", rc, _debug);
- rpmMessage(RPMMESS_DEBUG, _("removed db environment %s/%s(%s)\n"),
+ if (dbfile)
+ rpmMessage(RPMMESS_DEBUG, _("removed db environment %s/%s(%s)\n"),
dbhome, dbfile, dbsubfile);
}
@@ -466,12 +483,12 @@ static int db3_fsync_disable(int fd) {
return 0;
}
-static int db_init(dbiIndex dbi, const char *dbhome, int dbflags,
- DB_ENV **dbenvp)
+static int db_init(dbiIndex dbi, const char *dbhome, const char *dbfile,
+ const char * dbsubfile, DB_ENV **dbenvp)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
DB_ENV *dbenv = NULL;
- int mydbopenflags;
+ int eflags;
int rc;
if (dbenvp == NULL)
@@ -481,9 +498,14 @@ static int db_init(dbiIndex dbi, const char *dbhome, int dbflags,
if (rpmdb->db_errfile == NULL)
rpmdb->db_errfile = stderr;
- mydbopenflags = dbi->dbi_flags;
+ eflags = (dbi->dbi_oeflags | dbi->dbi_eflags);
+ if ( dbi->dbi_mode & O_CREAT) eflags |= DB_CREATE;
+
+ if (dbfile)
+ rpmMessage(RPMMESS_DEBUG, _("opening db environment %s/%s(%s) %s\n"),
+ dbhome, dbfile, dbsubfile, prDbiOpenFlags(eflags, 1));
- rc = db_env_create(&dbenv, 0);
+ rc = db_env_create(&dbenv, dbi->dbi_cflags);
rc = cvtdberr(dbi, "db_env_create", rc, _debug);
if (rc)
goto errxit;
@@ -526,21 +548,13 @@ static int db_init(dbiIndex dbi, const char *dbhome, int dbflags,
dbenv->mp_size = dbi->dbi_mp_size; /* XXX default is 128 Kb */
#endif /* __USE_DB3 */
-#define _DBENVMASK \
- ( DB_INIT_CDB | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | \
- DB_RECOVER | DB_RECOVER_FATAL | DB_USE_ENVIRON | DB_USE_ENVIRON_ROOT | \
- DB_CREATE | DB_LOCKDOWN | DB_NOMMAP | DB_PRIVATE | DB_SYSTEM_MEM | \
- DB_THREAD | DB_TXN_NOSYNC )
-
- mydbopenflags &= _DBENVMASK;
-
#if defined(__USE_DB3)
- rc = dbenv->open(dbenv, dbhome, NULL, mydbopenflags, dbi->dbi_perms);
+ rc = dbenv->open(dbenv, dbhome, NULL, eflags, dbi->dbi_perms);
rc = cvtdberr(dbi, "dbenv->open", rc, _debug);
if (rc)
goto errxit;
#else /* __USE_DB3 */
- rc = db_appinit(dbhome, NULL, dbenv, mydbopenflags);
+ rc = db_appinit(dbhome, NULL, dbenv, eflags);
rc = cvtdberr(dbi, "db_appinit", rc, _debug);
if (rc)
goto errxit;
@@ -568,7 +582,7 @@ errxit:
static int db3sync(dbiIndex dbi, unsigned int flags)
{
- DB * db = GetDB(dbi);
+ DB * db = dbi->dbi_db;
int rc;
#if defined(__USE_DB2) || defined(__USE_DB3)
@@ -602,10 +616,19 @@ static int db3c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp, u_int32_t flags)
static int db3c_get(dbiIndex dbi, DBC * dbcursor,
DBT * key, DBT * data, u_int32_t flags)
{
- int rc;
int _printit;
+ int rc;
+ int rmw;
+
+#ifdef NOTYET
+ if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
+ rmw = DB_RMW;
+ else
+#endif
+ rmw = 0;
+
+ rc = dbcursor->c_get(dbcursor, key, data, rmw | flags);
- rc = dbcursor->c_get(dbcursor, key, data, flags);
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
return rc;
@@ -621,7 +644,7 @@ static int db3c_put(dbiIndex dbi, DBC * dbcursor,
return rc;
}
-static int db3c_close(dbiIndex dbi, DBC * dbcursor)
+static inline int db3c_close(dbiIndex dbi, DBC * dbcursor)
{
int rc;
@@ -630,17 +653,249 @@ static int db3c_close(dbiIndex dbi, DBC * dbcursor)
return rc;
}
-static int db3c_open(dbiIndex dbi, DB_TXN * txnid, DBC ** dbcp, u_int32_t flags)
+static inline int db3c_open(dbiIndex dbi, DBC ** dbcp)
{
- DB * db = GetDB(dbi);
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ int flags;
int rc;
#if defined(__USE_DB3)
+ if ((dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
+ flags = DB_WRITECURSOR;
+ else
+ flags = 0;
rc = db->cursor(db, txnid, dbcp, flags);
#else /* __USE_DB3 */
rc = db->cursor(db, txnid, dbcp);
#endif /* __USE_DB3 */
- rc = cvtdberr(dbi, "db3c_open", rc, _debug);
+ rc = cvtdberr(dbi, "db3copen", rc, _debug);
+
+ return rc;
+}
+
+static int db3cclose(dbiIndex dbi, DBC * dbcursor)
+{
+ int rc = 0;
+
+ if (dbcursor == NULL)
+ dbcursor = dbi->dbi_rmw;
+ if (dbcursor) {
+ rc = db3c_close(dbi, dbcursor);
+ if (dbcursor == dbi->dbi_rmw)
+ dbi->dbi_rmw = NULL;
+ }
+ return rc;
+}
+
+static int db3copen(dbiIndex dbi, DBC ** dbcp)
+{
+ DBC * dbcursor;
+ int rc = 0;
+
+ if ((dbcursor = dbi->dbi_rmw) != NULL) {
+ if (dbcp) *dbcp = dbi->dbi_rmw;
+ return 0;
+ } else if ((rc = db3c_open(dbi, &dbcursor)) == 0) {
+ dbi->dbi_rmw = dbcursor;
+ }
+
+ if (dbcp)
+ *dbcp = dbcursor;
+
+ return rc;
+}
+
+static int db3cput(dbiIndex dbi, void * keyp, size_t keylen,
+ void * datap, size_t datalen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
+ int rc;
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ key.data = keyp;
+ key.size = keylen;
+ data.data = datap;
+ data.size = datalen;
+
+ if (!dbi->dbi_use_cursors) {
+ rc = db->put(db, txnid, &key, &data, 0);
+ rc = cvtdberr(dbi, "db->put", rc, _debug);
+ } else {
+ DBC * dbcursor;
+
+ if ((rc = db3copen(dbi, &dbcursor)) != 0)
+ return rc;
+
+ rc = db3c_put(dbi, dbcursor, &key, &data, DB_KEYLAST);
+
+ (void) db3cclose(dbi, dbcursor);
+ }
+
+ return rc;
+}
+
+static int db3cdel(dbiIndex dbi, void * keyp, size_t keylen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
+ int rc;
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+
+ key.data = keyp;
+ key.size = keylen;
+
+ if (!dbi->dbi_use_cursors) {
+ rc = db->del(db, txnid, &key, 0);
+ rc = cvtdberr(dbi, "db->del", rc, _debug);
+ } else {
+ DBC * dbcursor;
+
+ if ((rc = db3copen(dbi, &dbcursor)) != 0)
+ return rc;
+
+ rc = db3c_get(dbi, dbcursor, &key, &data, DB_SET);
+
+ if (rc == 0) {
+ /* XXX TODO: loop over duplicates */
+ rc = db3c_del(dbi, dbcursor, 0);
+ }
+
+ (void) db3c_close(dbi, dbcursor);
+
+ }
+
+ return rc;
+}
+
+static int db3cget(dbiIndex dbi, void ** keyp, size_t * keylen,
+ void ** datap, size_t * datalen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
+ int rc;
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+ if (keyp) key.data = *keyp;
+ if (keylen) key.size = *keylen;
+ if (datap) data.data = *datap;
+ if (datalen) data.size = *datalen;
+
+ if (!dbi->dbi_use_cursors) {
+ int _printit;
+ rc = db->get(db, txnid, &key, &data, 0);
+ _printit = (rc == DB_NOTFOUND ? 0 : _debug);
+ rc = cvtdberr(dbi, "db->get", rc, _printit);
+ } else {
+ DBC * dbcursor;
+
+ if ((rc = db3copen(dbi, &dbcursor)) != 0)
+ return rc;
+
+ /* XXX db3 does DB_FIRST on uninitialized cursor */
+ rc = db3c_get(dbi, dbcursor, &key, &data,
+ key.data == NULL ? DB_NEXT : DB_SET);
+
+ if (rc > 0) /* DB_NOTFOUND */
+ (void) db3cclose(dbi, dbcursor);
+ }
+
+ if (rc == 0) {
+ if (keyp) *keyp = key.data;
+ if (keylen) *keylen = key.size;
+ if (datap) *datap = data.data;
+ if (datalen) *datalen = data.size;
+ }
+
+ return rc;
+}
+
+static int db3get(dbiIndex dbi, void * keyp, size_t keylen,
+ void ** datap, size_t * datalen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
+ int rc;
+
+ if (datap) *datap = NULL;
+ if (datalen) *datalen = 0;
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+
+ { int _printit;
+ key.data = keyp;
+ key.size = keylen;
+ rc = db->get(db, txnid, &key, &data, 0);
+ _printit = (rc == DB_NOTFOUND ? 0 : _debug);
+ rc = cvtdberr(dbi, "db->get", rc, _printit);
+ }
+
+ if (rc == 0) {
+ if (datap) *datap = data.data;
+ if (datalen) *datalen = data.size;
+ }
+
+ return rc;
+}
+
+static int db3put(dbiIndex dbi, void * keyp, size_t keylen,
+ void * datap, size_t datalen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
+ int rc;
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
+
+ key.data = keyp;
+ key.size = keylen;
+ data.data = datap;
+ data.size = datalen;
+
+ rc = db->put(db, txnid, &key, &data, 0);
+ rc = cvtdberr(dbi, "db->put", rc, _debug);
+
+ return rc;
+}
+
+static int db3del(dbiIndex dbi, void * keyp, size_t keylen)
+{
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key;
+ int rc;
+
+ memset(&key, 0, sizeof(key));
+
+ key.data = keyp;
+ key.size = keylen;
+
+ rc = db->del(db, txnid, &key, 0);
+ rc = cvtdberr(dbi, "db->del", rc, _debug);
+
+ return rc;
+}
+
+static int db3byteswapped(dbiIndex dbi)
+{
+ DB * db = dbi->dbi_db;
+ int rc = 0;
+
+#if defined(__USE_DB3)
+ rc = db->get_byteswapped(db);
+#endif /* __USE_DB3 */
+
return rc;
}
@@ -655,25 +910,29 @@ union _dbswap {
_b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
}
-static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
- dbiIndexSet * set)
+static int db3SearchIndex(dbiIndex dbi, const void * keyp, size_t keylen,
+ dbiIndexSet * setp)
{
- DBT key, data;
- DB * db = GetDB(dbi);
int rc;
+ void * datap;
+ size_t datalen;
+
+#ifdef DYING
+ DB * db = dbi->dbi_db;
+ DB_TXN * txnid = NULL;
+ DBT key, data;
if (set) *set = NULL;
- if (len == 0) len = strlen(str);
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
+ if (keylen == 0) keylen = strlen(keyp);
+
+ memset(&key, 0, sizeof(key));
+ memset(&data, 0, sizeof(data));
- key.data = (void *)str;
- key.size = len;
+ key.data = keyp;
+ key.size = keylen;
data.data = NULL;
data.size = 0;
-#if defined(__USE_DB2) || defined(__USE_DB3)
- { DB_TXN * txnid = NULL;
if (!dbi->dbi_use_cursors) {
int _printit;
rc = db->get(db, txnid, &key, &data, 0);
@@ -681,35 +940,39 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
rc = cvtdberr(dbi, "db->get", rc, _printit);
} else {
DBC * dbcursor;
- int xx;
- rc = db3c_open(dbi, txnid, &dbcursor, 0);
- if (rc)
+ if ((rc = db3copen(dbi, &dbcursor)) != 0)
return rc;
/* XXX TODO: loop over duplicates */
rc = db3c_get(dbi, dbcursor, &key, &data, DB_SET);
- xx = db3c_close(dbi, dbcursor);
+ if (rc > 0) /* DB_NOTFOUND */
+ (void) db3cclose(dbi, dbcursor);
}
- }
-#else /* __USE_DB2 || __USE_DB3 */
- rc = db->get(db, &key, &data, 0);
-#endif /* __USE_DB2 || __USE_DB3 */
+#else
+
+ if (setp) *setp = NULL;
+ if (keylen == 0) keylen = strlen(keyp);
+
+ rc = db3cget(dbi, (void **)&keyp, &keylen, &datap, &datalen);
+
+#endif
- if (rc == 0 && set) {
- int _dbbyteswapped = db->get_byteswapped(db);
- const char * sdbir = data.data;
+ if (rc == 0 && setp) {
+ int _dbbyteswapped = db3byteswapped(dbi);
+ const char * sdbir = datap;
+ dbiIndexSet set;
int i;
- *set = xmalloc(sizeof(**set));
+ set = xmalloc(sizeof(*set));
/* Convert to database internal format */
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++) {
+ set->count = datalen / (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));
@@ -720,17 +983,17 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
_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;
+ 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++) {
+ set->count = datalen / (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));
@@ -738,46 +1001,37 @@ static int db3SearchIndex(dbiIndex dbi, const void * str, size_t len,
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 = 0;
+ set->recs[i].fpNum = 0;
+ set->recs[i].dbNum = 0;
}
break;
}
+ *setp = set;
}
return rc;
}
/*@-compmempass@*/
-static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
+static int db3UpdateIndex(dbiIndex dbi, const char * keyp, dbiIndexSet set)
{
- DB * db = GetDB(dbi);
- DBT key;
- DBT data;
- DB_TXN * txnid = NULL;
+ size_t keylen = strlen(keyp);
+ void * datap;
+ size_t datalen;
int rc;
- _mymemset(&key, 0, sizeof(key));
- key.data = (void *)str;
- key.size = strlen(str);
- _mymemset(&data, 0, sizeof(data));
-
if (set->count) {
char * tdbir;
int i;
- int _dbbyteswapped = 0;
-
-#if defined(__USE_DB3)
- _dbbyteswapped = db->get_byteswapped(db);
-#endif /* __USE_DB3 */
+ int _dbbyteswapped = db3byteswapped(dbi);
/* Convert to database internal format */
switch (dbi->dbi_jlen) {
case 2*sizeof(int_32):
- data.size = set->count * (2 * sizeof(int_32));
- data.data = tdbir = alloca(data.size);
+ datalen = set->count * (2 * sizeof(int_32));
+ datap = tdbir = alloca(datalen);
for (i = 0; i < set->count; i++) {
union _dbswap recOffset, fileNumber;
@@ -795,8 +1049,8 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
break;
default:
case 1*sizeof(int_32):
- data.size = set->count * (1 * sizeof(int_32));
- data.data = tdbir = alloca(data.size);
+ datalen = set->count * (1 * sizeof(int_32));
+ datap = tdbir = alloca(datalen);
for (i = 0; i < set->count; i++) {
union _dbswap recOffset;
@@ -810,218 +1064,17 @@ static int db3UpdateIndex(dbiIndex dbi, const char * str, dbiIndexSet set)
break;
}
-#if defined(__USE_DB2) || defined(__USE_DB3)
- if (!dbi->dbi_use_cursors) {
- rc = db->put(db, txnid, &key, &data, 0);
- rc = cvtdberr(dbi, "db->put", rc, _debug);
- } else {
- DBC * dbcursor;
-
- rc = db3c_open(dbi, txnid, &dbcursor, 0);
- if (rc)
- return rc;
-
- /* XXX TODO: loop over duplicates */
- rc = db3c_put(dbi, dbcursor, &key, &data, DB_KEYLAST);
-
- (void) db3c_close(dbi, dbcursor);
- }
-#else /* __USE_DB2 || __USE_DB3 */
- rc = db->put(db, &key, &data, 0);
-#endif /* __USE_DB2 || __USE_DB3 */
+ rc = db3cput(dbi, (void *)keyp, keylen, datap, datalen);
} else {
-#if defined(__USE_DB2) || defined(__USE_DB3)
- if (!dbi->dbi_use_cursors) {
- rc = db->del(db, txnid, &key, 0);
- rc = cvtdberr(dbi, "db->del", rc, _debug);
- } else {
- DBC * dbcursor;
-
- rc = db3c_open(dbi, txnid, &dbcursor, 0);
- if (rc)
- return rc;
-
- rc = db3c_get(dbi, dbcursor, &key, &data, DB_SET);
-
- /* XXX TODO: loop over duplicates */
- rc = db3c_del(dbi, dbcursor, 0);
-
- (void) db3c_close(dbi, dbcursor);
- }
-#else /* __USE_DB2 || __USE_DB3 */
- rc = db->del(db, &key, 0);
-#endif /* __USE_DB2 || __USE_DB3 */
-
+ rc = db3cdel(dbi, (void *)keyp, keylen);
}
return rc;
}
/*@=compmempass@*/
-static int db3copen(dbiIndex dbi)
-{
- DBC * dbcursor;
- int rc = 0;
-
- if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
- DB_TXN * txnid = NULL;
- rc = db3c_open(dbi, txnid, &dbcursor, 0);
- if (rc == 0)
- dbi->dbi_dbcursor = dbcursor;
- }
- dbi->dbi_lastoffset = 0;
- return rc;
-}
-
-static int db3cclose(dbiIndex dbi)
-{
- DBC * dbcursor;
- int rc = 0;
-
- if ((dbcursor = dbi->dbi_dbcursor) != NULL) {
- rc = db3c_close(dbi, dbcursor);
- dbi->dbi_dbcursor = NULL;
- }
- if ((dbcursor = dbi->dbi_dbjoin) != NULL) {
- rc = db3c_close(dbi, dbcursor);
- dbi->dbi_dbjoin = NULL;
- }
- dbi->dbi_lastoffset = 0;
- return rc;
-}
-
-static int db3join(dbiIndex dbi)
-{
- DB * db = GetDB(dbi);
- int rc;
-
- { DBC * dbjoin;
- DBC * dbcs[2];
- dbcs[0] = dbi->dbi_dbcursor;
- dbcs[1] = NULL;
- rc = db->join(db, dbcs, &dbjoin, 0);
- rc = cvtdberr(dbi, "db->join", rc, _debug);
- if (rc == 0)
- dbi->dbi_dbjoin = dbjoin;
- }
-
- return rc;
-}
-
-static int db3cget(dbiIndex dbi, void ** keyp, size_t * keylen,
- void ** datap, size_t * datalen)
-{
- DBT key, data;
- int rc;
-
- if (keyp) *keyp = NULL;
- if (keylen) *keylen = 0;
- if (datap) *datap = NULL;
- if (datalen) *datalen = 0;
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
-
- { DBC * dbcursor;
-
- if ((dbcursor = dbi->dbi_dbcursor) == NULL) {
- rc = db3copen(dbi);
- if (rc)
- return rc;
- dbcursor = dbi->dbi_dbcursor;
- }
-
- /* XXX db3 does DB_FIRST on uninitialized cursor */
- rc = db3c_get(dbi, dbcursor, &key, &data, DB_NEXT);
- if (rc == 0) {
- if (keyp)
- *keyp = key.data;
- if (keylen)
- *keylen = key.size;
- if (datap)
- *datap = data.data;
- if (datalen)
- *datalen = data.size;
- } else if (rc > 0) { /* DB_NOTFOUND */
- (void) db3cclose(dbi);
- }
- }
-
- return rc;
-}
-
-static int db3get(dbiIndex dbi, void * keyp, size_t keylen,
- void ** datap, size_t * datalen)
-{
- DB_TXN * txnid = NULL;
- DBT key, data;
- DB * db = GetDB(dbi);
- int rc;
-
- if (datap) *datap = NULL;
- if (datalen) *datalen = 0;
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
-
- { int _printit;
- key.data = keyp;
- key.size = keylen;
- rc = db->get(db, txnid, &key, &data, 0);
- _printit = (rc == DB_NOTFOUND ? 0 : _debug);
- rc = cvtdberr(dbi, "db->get", rc, _printit);
- }
-
- if (rc == 0) {
- if (datap)
- *datap = data.data;
- if (datalen)
- *datalen = data.size;
- }
-
- return rc;
-}
-
-static int db3put(dbiIndex dbi, void * keyp, size_t keylen,
- void * datap, size_t datalen)
-{
- DB_TXN * txnid = NULL;
- DBT key, data;
- DB * db = GetDB(dbi);
- int rc;
-
- _mymemset(&key, 0, sizeof(key));
- _mymemset(&data, 0, sizeof(data));
-
- key.data = keyp;
- key.size = keylen;
- data.data = datap;
- data.size = datalen;
-
- rc = db->put(db, txnid, &key, &data, 0);
- rc = cvtdberr(dbi, "db->get", rc, _debug);
-
- return rc;
-}
-
-static int db3del(dbiIndex dbi, void * keyp, size_t keylen)
-{
- DB_TXN * txnid = NULL;
- DBT key;
- DB * db = GetDB(dbi);
- int rc;
-
- _mymemset(&key, 0, sizeof(key));
-
- key.data = keyp;
- key.size = keylen;
-
- rc = db->del(db, txnid, &key, 0);
- rc = cvtdberr(dbi, "db->del", rc, _debug);
-
- return rc;
-}
-
static int db3close(dbiIndex dbi, unsigned int flags)
{
rpmdb rpmdb = dbi->dbi_rpmdb;
@@ -1029,25 +1082,39 @@ static int db3close(dbiIndex dbi, unsigned int flags)
const char * dbhome;
const char * dbfile;
const char * dbsubfile;
- DB * db = GetDB(dbi);
+ DB * db = dbi->dbi_db;
int rc = 0, xx;
- urlfn = rpmGenPath(rpmdb->db_root, rpmdb->db_home, NULL);
+ urlfn = rpmGenPath(
+ (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root),
+ (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home),
+ NULL);
(void) urlPath(urlfn, &dbhome);
- dbfile = db3basename;
- dbsubfile = tagName(dbi->dbi_rpmtag);
+ if (dbi->dbi_temporary) {
+ dbfile = NULL;
+ dbsubfile = NULL;
+ } else {
+#ifdef HACK
+ dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
+ dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
+#else
+ dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
+ dbsubfile = NULL;
+#endif
+ }
#if defined(__USE_DB2) || defined(__USE_DB3)
- if (dbi->dbi_dbcursor)
- db3cclose(dbi);
+ if (dbi->dbi_rmw)
+ db3cclose(dbi, NULL);
if (db) {
rc = db->close(db, 0);
rc = cvtdberr(dbi, "db->close", rc, _debug);
db = dbi->dbi_db = NULL;
- rpmMessage(RPMMESS_DEBUG, _("closed db index %s/%s(%s)\n"),
+ if (dbfile)
+ rpmMessage(RPMMESS_DEBUG, _("closed db index %s/%s(%s)\n"),
dbhome, dbfile, dbsubfile);
}
@@ -1087,28 +1154,48 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
DB * db = NULL;
DB_ENV * dbenv = NULL;
DB_TXN * txnid = NULL;
- u_int32_t dbflags;
+ u_int32_t oflags;
if (dbip)
*dbip = NULL;
if ((dbi = db3New(rpmdb, rpmtag)) == NULL)
return 1;
- urlfn = rpmGenPath(rpmdb->db_root, rpmdb->db_home, NULL);
+ urlfn = rpmGenPath(
+ (dbi->dbi_root ? dbi->dbi_root : rpmdb->db_root),
+ (dbi->dbi_home ? dbi->dbi_home : rpmdb->db_home),
+ NULL);
(void) urlPath(urlfn, &dbhome);
- dbfile = db3basename;
- dbsubfile = tagName(dbi->dbi_rpmtag);
+ if (dbi->dbi_temporary) {
+ dbfile = NULL;
+ dbsubfile = NULL;
+ } else {
+#ifdef HACK
+ dbfile = (dbi->dbi_file ? dbi->dbi_file : db3basename);
+ dbsubfile = (dbi->dbi_subfile ? dbi->dbi_subfile : tagName(dbi->dbi_rpmtag));
+#else
+ dbfile = (dbi->dbi_file ? dbi->dbi_file : tagName(dbi->dbi_rpmtag));
+ dbsubfile = NULL;
+#endif
+ }
- dbflags = dbi->dbi_flags;
- if (!dbi->dbi_mode & O_RDWR) dbflags |= DB_RDONLY;
- if ( dbi->dbi_mode & O_CREAT) dbflags |= DB_CREATE;
+ oflags = (dbi->dbi_oeflags | dbi->dbi_oflags);
+#if NOTYET
+ if ( dbi->dbi_mode & O_EXCL) oflags |= DB_EXCL;
+#endif
+ if (!dbi->dbi_mode & O_RDWR) oflags |= DB_RDONLY;
+ if ( dbi->dbi_mode & O_CREAT) oflags |= DB_CREATE;
+ if ( dbi->dbi_mode & O_TRUNC) oflags |= DB_TRUNCATE;
- rc = db_init(dbi, dbhome, dbflags, &dbenv);
+ rc = db_init(dbi, dbhome, dbfile, dbsubfile, &dbenv);
dbi->dbi_dbinfo = NULL;
if (rc == 0) {
+ if (dbfile)
+ rpmMessage(RPMMESS_DEBUG, _("opening db index %s/%s(%s) %s\n"),
+ dbhome, dbfile, dbsubfile, prDbiOpenFlags(oflags, 0));
#if defined(__USE_DB3)
- rc = db_create(&db, dbenv, 0);
+ rc = db_create(&db, dbenv, dbi->dbi_cflags);
rc = cvtdberr(dbi, "db_create", rc, _debug);
if (rc == 0) {
if (dbi->dbi_lorder) {
@@ -1127,7 +1214,7 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
rc = db->set_malloc(db, rpmdb->db_malloc);
rc = cvtdberr(dbi, "db->set_malloc", rc, _debug);
}
- if (dbflags & DB_CREATE) {
+ if (oflags & DB_CREATE) {
switch(dbi->dbi_type) {
default:
case DB_HASH:
@@ -1160,24 +1247,19 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
}
dbi->dbi_dbinfo = NULL;
-#define _DBOPENMASK \
- ( DB_CREATE | DB_EXCL | DB_NOMMAP | DB_RDONLY | DB_THREAD | DB_TRUNCATE | DB_UPGRADE )
-
- dbflags &= _DBOPENMASK;
-
rc = db->open(db, dbfile, dbsubfile,
- dbi->dbi_type, dbflags, dbi->dbi_perms);
+ dbi->dbi_type, oflags, dbi->dbi_perms);
rc = cvtdberr(dbi, "db->open", rc, _debug);
if (dbi->dbi_get_rmw_cursor) {
DBC * dbcursor = NULL;
int xx;
xx = db->cursor(db, txnid, &dbcursor,
- ((dbflags & DB_RDONLY) ? 0 : DB_WRITECURSOR));
+ ((oflags & DB_RDONLY) ? 0 : DB_WRITECURSOR));
xx = cvtdberr(dbi, "db->cursor", xx, _debug);
- dbi->dbi_dbcursor = dbcursor;
+ dbi->dbi_rmw = dbcursor;
} else
- dbi->dbi_dbcursor = NULL;
+ dbi->dbi_rmw = NULL;
}
#else
{ DB_INFO * dbinfo = xcalloc(1, sizeof(*dbinfo));
@@ -1185,7 +1267,7 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
dbinfo->db_lorder = dbi->dbi_lorder;
dbinfo->db_pagesize = dbi->dbi_pagesize;
dbinfo->db_malloc = rpmdb->db_malloc;
- if (dbflags & DB_CREATE) {
+ if (oflags & DB_CREATE) {
switch(dbi->dbi_type) {
default:
case DB_HASH:
@@ -1197,7 +1279,7 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
}
}
dbi->dbi_dbinfo = dbinfo;
- rc = db_open(dbfile, dbi->dbi_type, dbflags,
+ rc = db_open(dbfile, dbi->dbi_type, oflags,
dbi->dbi_perms, dbenv, dbinfo, &db);
rc = cvtdberr(dbi, "db_open", rc, _debug);
}
@@ -1222,8 +1304,6 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
if (rc == 0 && dbi->dbi_db != NULL && dbip != NULL) {
rc = 0;
*dbip = dbi;
- rpmMessage(RPMMESS_DEBUG, _("opened %s/%s(%s) %s\n"),
- dbhome, dbfile, dbsubfile, prDbiOpenFlags(dbi->dbi_flags));
} else {
rc = 1;
db3Free(dbi);
@@ -1238,7 +1318,8 @@ static int db3open(rpmdb rpmdb, int rpmtag, dbiIndex * dbip)
struct _dbiVec db3vec = {
DB_VERSION_MAJOR, DB_VERSION_MINOR, DB_VERSION_PATCH,
db3open, db3close, db3sync, db3SearchIndex, db3UpdateIndex,
- db3del, db3get, db3put, db3copen, db3cclose, db3join, db3cget
+ db3del, db3get, db3put, db3copen, db3cclose, db3cdel, db3cget, db3cput,
+ db3byteswapped
};
#endif /* DB_VERSION_MAJOR == 3 */
diff --git a/lib/depends.c b/lib/depends.c
index f5b9ef71f..12cbf7f18 100644
--- a/lib/depends.c
+++ b/lib/depends.c
@@ -3,9 +3,9 @@
#include <rpmlib.h>
#include "depends.h"
+#include "rpmdb.h"
#include "misc.h"
-/*@access rpmdb@*/
/*@access rpmTransactionSet@*/
int headerNVR(Header h, const char **np, const char **vp, const char **rp)
@@ -20,35 +20,40 @@ int headerNVR(Header h, const char **np, const char **vp, const char **rp)
return 0;
}
-static /*@only@*/ char *printDepend(const char * key, const char * keyEVR,
+static /*@only@*/ char *printDepend(const char * depend, const char * key, const char * keyEVR,
int keyFlags)
{
char *tbuf, *t;
size_t nb;
nb = 0;
+ if (depend) nb += strlen(depend) + 1;
if (key) nb += strlen(key);
- if (keyFlags) {
+ if (keyFlags & RPMSENSE_SENSEMASK) {
if (nb) nb++;
if (keyFlags & RPMSENSE_LESS) nb++;
if (keyFlags & RPMSENSE_GREATER) nb++;
if (keyFlags & RPMSENSE_EQUAL) nb++;
}
- if (keyEVR) {
+ if (keyEVR && *keyEVR) {
if (nb) nb++;
nb += strlen(keyEVR);
}
t = tbuf = xmalloc(nb + 1);
+ if (depend) {
+ while(*depend) *t++ = *depend++;
+ *t++ = ' ';
+ }
if (key)
while(*key) *t++ = *key++;
- if (keyFlags) {
+ if (keyFlags & RPMSENSE_SENSEMASK) {
if (t != tbuf) *t++ = ' ';
if (keyFlags & RPMSENSE_LESS) *t++ = '<';
if (keyFlags & RPMSENSE_GREATER) *t++ = '>';
if (keyFlags & RPMSENSE_EQUAL) *t++ = '=';
}
- if (keyEVR) {
+ if (keyEVR && *keyEVR) {
if (t != tbuf) *t++ = ' ';
while(*keyEVR) *t++ = *keyEVR++;
}
@@ -394,8 +399,8 @@ int rpmFLAGS = RPMSENSE_EQUAL;
static int rangesOverlap(const char *AName, const char *AEVR, int AFlags,
const char *BName, const char *BEVR, int BFlags)
{
- const char *aDepend = printDepend(AName, AEVR, AFlags);
- const char *bDepend = printDepend(BName, BEVR, BFlags);
+ const char *aDepend = printDepend(NULL, AName, AEVR, AFlags);
+ const char *bDepend = printDepend(NULL, BName, BEVR, BFlags);
char *aEVR, *bEVR;
const char *aE, *aV, *aR, *bE, *bV, *bR;
int result;
@@ -884,6 +889,15 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
if (suggestion) *suggestion = NULL;
+ { mi = rpmdbInitIterator(rpmdep->db, 1, keyDepend, 0);
+ if (mi) {
+ rc = rpmdbGetIteratorOffset(mi);
+ rpmdbFreeIterator(mi);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by Depends cache.\n"), keyType, keyDepend+2);
+ return rc;
+ }
+ }
+
{ const char * rcProvidesString;
const char * start;
@@ -892,7 +906,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
i = strlen(keyName);
while ((start = strstr(rcProvidesString, keyName))) {
if (isspace(start[i]) || start[i] == '\0' || start[i] == ',') {
- rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmrc provides.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmrc provides.\n"), keyType, keyDepend+2);
goto exit;
}
rcProvidesString = start + 1;
@@ -920,7 +934,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
}
rpmdbFreeIterator(mi);
if (h) {
- rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db file lists.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db file lists.\n"), keyType, keyDepend+2);
goto exit;
}
}
@@ -938,7 +952,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
}
rpmdbFreeIterator(mi);
if (h) {
- rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db provides.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db provides.\n"), keyType, keyDepend+2);
goto exit;
}
@@ -956,7 +970,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
}
rpmdbFreeIterator(mi);
if (h) {
- rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db packages.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by db packages.\n"), keyType, keyDepend+2);
goto exit;
}
#endif
@@ -969,7 +983,7 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
if (!strcmp(keyName, rpmNAME)) {
i = rangesOverlap(keyName, keyEVR, keyFlags, rpmNAME, rpmEVR, rpmFLAGS);
if (i) {
- rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmlib version.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s satisfied by rpmlib version.\n"), keyType, keyDepend+2);
goto exit;
}
}
@@ -979,10 +993,14 @@ static int unsatisfiedDepend(rpmTransactionSet rpmdep,
*suggestion = alSatisfiesDepend(&rpmdep->availablePackages, NULL, NULL,
keyName, keyEVR, keyFlags);
- rpmMessage(RPMMESS_DEBUG, _("%s: %s unsatisfied.\n"), keyType, keyDepend);
+ rpmMessage(RPMMESS_DEBUG, _("%s: %s unsatisfied.\n"), keyType, keyDepend+2);
rc = 1; /* dependency is unsatisfied */
exit:
+ { dbiIndex dbi;
+ if ((dbi = dbiOpen(rpmdep->db, 1)) != NULL)
+ (void) dbiPut(dbi, keyDepend, 0, &rc, sizeof(rc));
+ }
return rc;
}
@@ -1018,7 +1036,7 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
if (keyName && strcmp(keyName, requires[i]))
continue;
- keyDepend = printDepend(requires[i], requiresEVR[i], requireFlags[i]);
+ keyDepend = printDepend("R", requires[i], requiresEVR[i], requireFlags[i]);
rc = unsatisfiedDepend(rpmdep, " requires", keyDepend,
requires[i], requiresEVR[i], requireFlags[i], &suggestion);
@@ -1081,7 +1099,7 @@ static int checkPackageDeps(rpmTransactionSet rpmdep, struct problemsSet * psp,
if (keyName && strcmp(keyName, conflicts[i]))
continue;
- keyDepend = printDepend(conflicts[i], conflictsEVR[i], conflictFlags[i]);
+ keyDepend = printDepend("C", conflicts[i], conflictsEVR[i], conflictFlags[i]);
rc = unsatisfiedDepend(rpmdep, "conflicts", keyDepend,
conflicts[i], conflictsEVR[i], conflictFlags[i], NULL);
diff --git a/lib/header.c b/lib/header.c
index 769db10f6..162e7aba7 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -511,9 +511,11 @@ static void *doHeaderUnload(Header h, /*@out@*/int * lengthPtr)
void *headerUnload(Header h)
{
+ void * uh;
int length;
- return doHeaderUnload(h, &length);
+ uh = doHeaderUnload(h, &length);
+ return uh;
}
/********************************************************************/
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 8d3b8913c..99fb15003 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -102,7 +102,6 @@ static void dbiTagsInit(void)
}
#define dbiSync(_dbi) (*(_dbi)->dbi_vec->sync) ((_dbi), 0)
-#define dbiClose(_dbi) (*(_dbi)->dbi_vec->close) ((_dbi), 0)
/**
* Create and initialize element of index database set.
@@ -111,7 +110,7 @@ static void dbiTagsInit(void)
* @return new element
*/
static inline dbiIndexRecord dbiReturnIndexRecordInstance(unsigned int recOffset, unsigned int fileNumber) {
- dbiIndexRecord rec = xmalloc(sizeof(*rec));
+ dbiIndexRecord rec = xcalloc(1, sizeof(*rec));
rec->recOffset = recOffset;
rec->fileNumber = fileNumber;
return rec;
@@ -264,27 +263,30 @@ static inline void dbiIndexRecordOffsetSave(dbiIndexSet set, int recno, unsigned
set->recs[recno].recOffset = recoff;
}
-#ifdef DYING
-dbiIndex dbiNew(rpmdb rpmdb, int rpmtag) {
- dbiIndex dbi = xcalloc(1, sizeof(*dbi));
-
- dbi->dbi_rpmdb = rpmdb;
- dbi->dbi_rpmtag = rpmtag;
- dbi->dbi_perms = 0644;
- dbi->dbi_jlen = (rpmtag == RPMTAG_BASENAMES ? 2 : 1) * sizeof(int_32);
- return dbi;
+int dbiClose(dbiIndex dbi, int flag) {
+ int rc;
+
+ rc = (*dbi->dbi_vec->close) (dbi, flag);
+ return rc;
}
-void dbiFree( /*@only@*/ /*@null@*/ dbiIndex dbi) {
- if (dbi) {
- if (dbi->dbi_errpfx) xfree(dbi->dbi_errpfx);
- if (dbi->dbi_re_source) xfree(dbi->dbi_re_source);
- if (dbi->dbi_dbenv) free(dbi->dbi_dbenv);
- if (dbi->dbi_dbinfo) free(dbi->dbi_dbinfo);
- xfree(dbi);
- }
+int dbiPut(dbiIndex dbi, const void * key, size_t keylen,
+ const void * data, size_t datalen)
+{
+ dbiIndexSet set = xcalloc(1, sizeof(*set));
+ size_t nb = (datalen < sizeof(*set->recs) ? datalen : sizeof(*set->recs));
+ int rc;
+
+ set->count = 1;
+ set->recs = dbiReturnIndexRecordInstance(0, 0);
+ memcpy(set->recs, data, nb);
+
+ rc = (*dbi->dbi_vec->UpdateIndex) (dbi, key, set);
+
+ dbiFreeIndexSet(set);
+
+ return rc;
}
-#endif
static struct _dbiVec *mydbvecs[] = {
DB0vec, DB1vec, DB2vec, DB3vec, NULL
@@ -296,7 +298,7 @@ static struct _dbiVec *mydbvecs[] = {
* @param dbix dbi template to use
* @return index database handle
*/
-static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag)
+dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag)
{
int dbix;
dbiIndex dbi = NULL;
@@ -355,7 +357,7 @@ static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag)
if (rc == 0) {
rpmdb->_dbi[dbix] = dbi;
} else if (dbi) {
- rpmError(RPMERR_DBOPEN, _("dbiOpenIndex: cannot open %s index"),
+ rpmError(RPMERR_DBOPEN, _("dbiOpen: cannot open %s index"),
tagName(rpmtag));
db3Free(dbi);
dbi = NULL;
@@ -364,20 +366,6 @@ static dbiIndex dbiOpenIndex(rpmdb rpmdb, int rpmtag)
return dbi;
}
-#ifdef DYING
-/**
- * Close index database.
- * @param dbi index database handle
- */
-static int dbiClose(dbiIndex dbi) {
- int rc;
-
- rc = (*dbi->dbi_vec->close) (dbi, 0);
- db3Free(dbi);
- return rc;
-}
-#endif
-
/* XXX depends.c, install.c, query.c, rpminstall.c, transaction.c */
void dbiFreeIndexSet(dbiIndexSet set) {
if (set) {
@@ -390,17 +378,21 @@ void dbiFreeIndexSet(dbiIndexSet set) {
static sigset_t signalMask;
-static void blockSignals(void)
+static void blockSignals(rpmdb rpmdb)
{
sigset_t newMask;
- sigfillset(&newMask); /* block all signals */
- sigprocmask(SIG_BLOCK, &newMask, &signalMask);
+ if (!(rpmdb && rpmdb->db_major == 3)) {
+ sigfillset(&newMask); /* block all signals */
+ sigprocmask(SIG_BLOCK, &newMask, &signalMask);
+ }
}
-static void unblockSignals(void)
+static void unblockSignals(rpmdb rpmdb)
{
- sigprocmask(SIG_SETMASK, &signalMask, NULL);
+ if (!(rpmdb && rpmdb->db_major == 3)) {
+ sigprocmask(SIG_SETMASK, &signalMask, NULL);
+ }
}
#define _DB_ROOT "/"
@@ -427,7 +419,7 @@ void rpmdbClose (rpmdb rpmdb)
for (dbix = rpmdb->db_ndbi; --dbix >= 0; ) {
if (rpmdb->_dbi[dbix] == NULL)
continue;
- dbiClose(rpmdb->_dbi[dbix]);
+ dbiClose(rpmdb->_dbi[dbix], 0);
rpmdb->_dbi[dbix] = NULL;
}
if (rpmdb->db_errpfx) {
@@ -526,7 +518,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
int rpmtag;
rpmtag = dbiTags[dbix];
- dbi = (justCheck ? NULL : dbiOpenIndex(rpmdb, rpmtag));
+ dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL)
continue;
@@ -551,6 +543,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
*/
if (justCheck)
break;
+ xx = (*dbi->dbi_vec->copen) (dbi, NULL);
xx = (*dbi->dbi_vec->cget) (dbi, &keyp, NULL, NULL, NULL);
if (xx == 0) {
const char * akey = keyp;
@@ -560,7 +553,7 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
rc |= 1;
}
}
- xx = (*dbi->dbi_vec->cclose) (dbi);
+ xx = (*dbi->dbi_vec->cclose) (dbi, NULL);
} break;
default:
break;
@@ -569,10 +562,10 @@ static int openDatabase(const char * prefix, const char * dbpath, rpmdb *dbp,
}
exit:
- if (!(rc || justCheck || dbp == NULL))
- *dbp = rpmdb;
- else
+ if (rc || justCheck || dbp == NULL)
rpmdbClose(rpmdb);
+ else
+ *dbp = rpmdb;
return rc;
}
@@ -614,7 +607,7 @@ Header rpmdbGetRecord(rpmdb rpmdb, unsigned int offset)
int rc;
rpmtag = 0; /* RPMDBI_PACKAGES */
- dbi = dbiOpenIndex(rpmdb, rpmtag);
+ dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL)
return NULL;
rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen);
@@ -654,7 +647,7 @@ static int rpmdbFindByFile(rpmdb rpmdb, const char * filespec,
fpc = fpCacheCreate(20);
fp1 = fpLookup(fpc, dirName, baseName, 1);
- dbi = dbiOpenIndex(rpmdb, RPMTAG_BASENAMES);
+ dbi = dbiOpen(rpmdb, RPMTAG_BASENAMES);
rc = dbiSearchIndex(dbi, baseName, 0, &allMatches);
if (rc) {
dbiFreeIndexSet(allMatches);
@@ -797,7 +790,8 @@ void rpmdbFreeIterator(rpmdbMatchIterator mi)
} else {
int dbix = 0; /* RPMDBI_PACKAGES */
dbiIndex dbi = mi->mi_rpmdb->_dbi[dbix];
- (void) (*dbi->dbi_vec->cclose) (dbi);
+ if (dbi)
+ (void) (*dbi->dbi_vec->cclose) (dbi, NULL);
}
if (mi->mi_key) {
xfree(mi->mi_key);
@@ -848,8 +842,8 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
{
dbiIndex dbi;
int rpmtag;
- void * uh;
- size_t uhlen;
+ void * uh = NULL;
+ size_t uhlen = 0;
void * keyp;
size_t keylen;
int rc;
@@ -858,16 +852,16 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
return NULL;
rpmtag = 0; /* RPMDBI_PACKAGES */
- dbi = dbiOpenIndex(mi->mi_rpmdb, rpmtag);
+ dbi = dbiOpen(mi->mi_rpmdb, rpmtag);
if (dbi == NULL)
return NULL;
- keyp = &mi->mi_offset;
- keylen = sizeof(mi->mi_offset);
top:
/* XXX skip over instances with 0 join key */
do {
if (mi->mi_set) {
+ keyp = &mi->mi_offset;
+ keylen = sizeof(mi->mi_offset);
if (!(mi->mi_setx < mi->mi_set->count))
return NULL;
if (mi->mi_dbix != 0) { /* RPMDBI_PACKAGES */
@@ -875,8 +869,12 @@ top:
mi->mi_filenum = dbiIndexRecordFileNumber(mi->mi_set, mi->mi_setx);
}
} else {
- rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, NULL, NULL);
- if (keyp)
+ keyp = NULL;
+ keylen = 0;
+
+ rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &uh, &uhlen);
+
+ if (rc == 0 && keyp && mi->mi_setx)
memcpy(&mi->mi_offset, keyp, sizeof(mi->mi_offset));
/* Terminate on error or end of keys */
@@ -890,9 +888,11 @@ top:
return mi->mi_h;
/* Retrieve header */
- rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, &uh, &uhlen);
- if (rc)
- return NULL;
+ if (uh == NULL) {
+ rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &uh, &uhlen);
+ if (rc)
+ return NULL;
+ }
if (mi->mi_h) {
headerFree(mi->mi_h);
@@ -1001,7 +1001,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
dbix = dbiTagToDbix(rpmtag);
if (dbix < 0)
return NULL;
- dbi = dbiOpenIndex(rpmdb, rpmtag);
+ dbi = dbiOpen(rpmdb, rpmtag);
if (dbi == NULL)
return NULL;
@@ -1040,13 +1040,12 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb rpmdb, int rpmtag,
} else {
mi->mi_key = NULL;
mi->mi_keylen = 0;
+ if (dbi)
+ dbi->dbi_lastoffset = 0; /* db0: rewind to beginning */
}
mi->mi_rpmdb = rpmdb;
mi->mi_dbi = dbi;
- /* XXX falloc has dbi == NULL ) */
- assert(!(dbi && dbi->dbi_dbcursor));
-
mi->mi_dbix = dbix;
mi->mi_set = set;
mi->mi_setx = 0;
@@ -1118,7 +1117,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
rpmMessage(RPMMESS_VERBOSE, " --- %s-%s-%s\n", n, v, r);
}
- blockSignals();
+ blockSignals(rpmdb);
{ int dbix;
dbiIndexRecord rec = dbiReturnIndexRecordInstance(offset, 0);
@@ -1132,7 +1131,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
/* XXX FIXME: this forces all indices open */
rpmtag = dbiTags[dbix];
- dbi = dbiOpenIndex(rpmdb, rpmtag);
+ dbi = dbiOpen(rpmdb, rpmtag);
if (dbi->dbi_rpmtag == 0) {
(void) (*dbi->dbi_vec->del) (dbi, &offset, sizeof(offset));
@@ -1206,7 +1205,7 @@ int rpmdbRemove(rpmdb rpmdb, unsigned int offset, int tolerant)
}
}
- unblockSignals();
+ unblockSignals(rpmdb);
headerFree(h);
@@ -1267,7 +1266,7 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
if (_noDirTokens)
expandFilelist(h);
- blockSignals();
+ blockSignals(rpmdb);
{
unsigned int firstkey = 0;
@@ -1278,29 +1277,33 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
int rc;
rpmtag = 0; /* RPMDBI_PACKAGES */
- dbi = dbiOpenIndex(rpmdb, rpmtag);
+ dbi = dbiOpen(rpmdb, rpmtag);
- /* XXX hack to pass sizeof header to fadAlloc */
+ /* XXX db0: hack to pass sizeof header to fadAlloc */
datap = h;
datalen = headerSizeof(h, HEADER_MAGIC_NO);
+ (void) (*dbi->dbi_vec->copen) (dbi, NULL);
+
/* Retrieve join key for next header instance. */
- rc = (*dbi->dbi_vec->get) (dbi, keyp, keylen, (void *)&datap, &datalen);
+ rc = (*dbi->dbi_vec->cget) (dbi, &keyp, &keylen, &datap, &datalen);
offset = 0;
if (rc == 0 && datap)
memcpy(&offset, datap, sizeof(offset));
-
++offset;
- if (datap) {
+ if (rc == 0 && datap) {
memcpy(datap, &offset, sizeof(offset));
} else {
datap = &offset;
datalen = sizeof(offset);
}
- rc = (*dbi->dbi_vec->put) (dbi, keyp, keylen, datap, datalen);
+ rc = (*dbi->dbi_vec->cput) (dbi, keyp, keylen, datap, datalen);
+
+ (void) (*dbi->dbi_vec->cclose) (dbi, NULL);
+
}
if (rc) {
@@ -1320,11 +1323,12 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
/* XXX FIXME: this forces all indices open */
rpmtag = dbiTags[dbix];
- dbi = dbiOpenIndex(rpmdb, rpmtag);
+ dbi = dbiOpen(rpmdb, rpmtag);
if (dbi->dbi_rpmtag == 0) {
size_t uhlen = headerSizeof(h, HEADER_MAGIC_NO);
void * uh = headerUnload(h);
+
(void) (*dbi->dbi_vec->put) (dbi, &offset, sizeof(offset), uh, uhlen);
free(uh);
@@ -1421,7 +1425,7 @@ int rpmdbAdd(rpmdb rpmdb, Header h)
}
exit:
- unblockSignals();
+ unblockSignals(rpmdb);
return rc;
}
@@ -1666,7 +1670,7 @@ int findMatches(rpmdb rpmdb, const char * name, const char * version,
int rc;
int i;
- dbi = dbiOpenIndex(rpmdb, RPMTAG_NAME);
+ dbi = dbiOpen(rpmdb, RPMTAG_NAME);
rc = dbiSearchIndex(dbi, name, 0, matches);
if (rc != 0) {
diff --git a/lib/rpmdb.h b/lib/rpmdb.h
index 6ecb704af..c240baa26 100644
--- a/lib/rpmdb.h
+++ b/lib/rpmdb.h
@@ -42,6 +42,14 @@ struct _dbiIndexSet {
int count; /*!< number of records */
};
+/* XXX hack to get prototypes correct */
+#if !defined(DB_VERSION_MAJOR)
+#define DB_ENV void
+#define DBC void
+#define DBT void
+#define DB_LSN void
+#endif
+
/**
* Private methods for accessing an index database.
*/
@@ -120,18 +128,22 @@ struct _dbiVec {
/**
*/
- int (*copen) (dbiIndex dbi);
+ int (*copen) (dbiIndex dbi, DBC ** dbcp);
/**
*/
- int (*cclose) (dbiIndex dbi);
+ int (*cclose) (dbiIndex dbi, DBC * dbcursor);
/**
+ * Delete item using db->del or dbcursor->c_del.
+ * @param dbi index database handle
+ * @param keyp key data
+ * @param keylen key data length
*/
- int (*join) (dbiIndex dbi);
+ int (*cdel) (dbiIndex dbi, void * keyp, size_t keylen);
/**
- * Retrieve item using dbcursor->c_get.
+ * Retrieve item using db->get or dbcursor->c_get.
* @param dbi index database handle
* @param keyp address of key data
* @param keylen address of key data length
@@ -141,20 +153,38 @@ struct _dbiVec {
int (*cget) (dbiIndex dbi, void ** keyp, size_t * keylen,
void ** datap, size_t * datalen);
-};
+/**
+ * Save item using db->put or dbcursor->c_put.
+ * @param dbi index database handle
+ * @param keyp key data
+ * @param keylen key data length
+ * @param datap data pointer
+ * @param datalen data length
+ */
+ int (*cput) (dbiIndex dbi, void * keyp, size_t keylen,
+ void * datap, size_t datalen);
-/* XXX hack to get prototypes correct */
-#if !defined(DB_VERSION_MAJOR)
-#define DB_ENV void
-#define DBT void
-#define DB_LSN void
-#endif
+/**
+ */
+ int (*byteswapped) (dbiIndex dbi);
+
+};
/**
* Describes an index database (implemented on Berkeley db[123] API).
*/
struct _dbiIndex {
- int dbi_flags; /*<! */
+ const char * dbi_root;
+ const char * dbi_home;
+ const char * dbi_file;
+ const char * dbi_subfile;
+
+ int dbi_cflags; /*<! db_create/db_env_create flags */
+ int dbi_oeflags; /*<! common (db,dbenv}->open flags */
+ int dbi_eflags; /*<! dbenv->open flags */
+ int dbi_oflags; /*<! db->open flags */
+ int dbi_tflags; /*<! dbenv->txn_begin flags */
+
int dbi_type; /*<! db index type */
int dbi_mode; /*<! mode to use on open */
int dbi_perms; /*<! file permission to use on open */
@@ -164,6 +194,7 @@ struct _dbiIndex {
int dbi_use_cursors;
int dbi_get_rmw_cursor;
int dbi_no_fsync;
+ int dbi_temporary;
/* dbenv parameters */
int dbi_lorder;
@@ -221,8 +252,7 @@ struct _dbiIndex {
void * dbi_db; /*<! Berkeley db[123] handle */
void * dbi_dbenv;
void * dbi_dbinfo;
- void * dbi_dbjoin;
- void * dbi_dbcursor;
+ void * dbi_rmw; /*<! db cursor (with DB_WRITECURSOR) */
void * dbi_pkgs;
/*@observer@*/ const struct _dbiVec * dbi_vec; /*<! private methods */
@@ -235,7 +265,8 @@ struct _dbiIndex {
struct rpmdb_s {
const char * db_root; /*<! path prefix */
const char * db_home; /*<! directory path */
- int db_flags; /*<! */
+ int db_flags;
+
int db_mode; /*<! open mode */
int db_perms; /*<! open permissions */
@@ -264,46 +295,84 @@ extern "C" {
#endif
/**
- * Return base file name for legacy index databases.
- * @param rpmtag rpm tag
- * @return base file name
+ * Return new configured index database handle instance.
+ * @param rpmdb rpm database
*/
-char * db0basename(int rpmtag);
-
/*@only@*/ /*@null@*/ dbiIndex db3New(rpmdb rpmdb, int rpmtag);
+/**
+ * Destroy index database handle instance.
+ * @param dbi index database handle
+ */
void db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi);
/**
- * @param db rpm database
+ * Return handle for an index database.
+ * @param rpmdb rpm database
+ * @param rpmtag rpm tag
+ * @return index database handle
+ */
+dbiIndex dbiOpen(rpmdb rpmdb, int rpmtag);
+
+/**
+ * Store (key,data) pair in index database.
+ * @param dbi index database handle
+ * @param rpmdb rpm database
+ * @return 0 on success
+ */
+int dbiPut(dbiIndex dbi, const void * key, size_t keylen, const void * data, size_t datalen);
+
+/**
+ * Close index database.
+ * @param dbi index database handle
+ * @param flag (unused)
+ * @return 0 on success
+ */
+int dbiClose(dbiIndex dbi, int flag);
+
+/**
+ * Return base file name for index database (legacy).
+ * @param rpmtag rpm tag
+ * @return base file name
+ */
+char * db0basename(int rpmtag);
+
+/**
+ * Remove package header from rpm database and indices.
+ * @param rpmdb rpm database
+ * @param offset location in Packages dbi
+ * @param tolerant (legacy) print error messages?
+ * @return 0 on success
*/
int rpmdbRemove(rpmdb db, unsigned int offset, int tolerant);
/**
- * @param db rpm database
+ * Add package header to rpm database and indices.
+ * @param rpmdb rpm database
+ * @param rpmtag rpm tag
*/
-int rpmdbAdd(rpmdb db, Header dbentry);
+int rpmdbAdd(rpmdb rpmdb, Header dbentry);
/**
- * @param db rpm database
+ * @param rpmdb rpm database
*/
-int rpmdbUpdateRecord(rpmdb db, int secOffset, Header secHeader);
+int rpmdbUpdateRecord(rpmdb rpmdb, int secOffset, Header secHeader);
/**
*/
unsigned int rpmdbGetIteratorFileNum(rpmdbMatchIterator mi);
/**
- * @param db rpm database
+ * @param rpmdb rpm database
*/
-int rpmdbFindFpList(rpmdb db, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
+int rpmdbFindFpList(rpmdb rpmdb, fingerPrint * fpList, /*@out@*/dbiIndexSet * matchList,
int numItems);
/* XXX only for the benefit of runTransactions() */
/**
- * @param db rpm database
+ * @param rpmdb rpm database
*/
-int findMatches(rpmdb db, const char * name, const char * version,
+int findMatches(rpmdb rpmdb, const char * name, const char * version,
const char * release, /*@out@*/ dbiIndexSet * matches);
#ifdef __cplusplus
diff --git a/lib/rpmmalloc.c b/lib/rpmmalloc.c
index 5e1b60211..b4b4f1db9 100644
--- a/lib/rpmmalloc.c
+++ b/lib/rpmmalloc.c
@@ -4,9 +4,9 @@
#define EXIT_FAILURE 1
#endif
-void *vmefail(void)
+void *vmefail(size_t size)
{
- fprintf(stderr, _("memory alloc returned NULL.\n"));
+ fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), size);
exit(EXIT_FAILURE);
/*@notreached@*/
return NULL;
@@ -20,7 +20,7 @@ void * xmalloc (size_t size)
if (size == 0) size++;
value = malloc (size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
@@ -31,7 +31,7 @@ void * xcalloc (size_t nmemb, size_t size)
if (nmemb == 0) nmemb++;
value = calloc (nmemb, size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
@@ -41,15 +41,16 @@ void * xrealloc (void *ptr, size_t size)
if (size == 0) size++;
value = realloc (ptr, size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
char * xstrdup (const char *str)
{
- char *newstr = (char *) malloc (strlen(str) + 1);
+ size_t size = strlen(str) + 1;
+ char *newstr = (char *) malloc (size);
if (newstr == 0)
- newstr = (char *) vmefail();
+ newstr = (char *) vmefail(size);
strcpy (newstr, str);
return newstr;
}
diff --git a/macros.in b/macros.in
index e3fe27c6a..dd1187c5d 100644
--- a/macros.in
+++ b/macros.in
@@ -1,4 +1,4 @@
-# $Id: macros.in,v 1.53 2000/04/23 20:37:57 jbj Exp $
+# $Id: macros.in,v 1.54 2000/04/25 19:41:37 jbj Exp $
#==============================================================================
# Macro naming conventions (preliminary):
#
@@ -212,10 +212,9 @@
# 3 native db3 interface.
# -1 db3 -> db2 -> db1 -> db0 (as available).
# There are two macros so that --rebuilddb can convert old_db_api -> new_db_api.
-%_dbapi 3
+%_dbapi 0
%_dbapi_rebuild 3
-# This is a colon separated list of tokens for Berkeley db configuration.
#
# token Berkeley db flag or value
# =================================================
@@ -235,21 +234,26 @@
# txn_nosync DB_TXN_NOSYNC
# hash DB_HASH
#
+# See http://www.sleepycat.com for Berkeley db-3.0.55 configuration.
+#
# The (intended) default value for Red Hat Linux is
# hash:mpool:shared:lock
#
+# Additional rpm specific configuration:
# teardown Should the DB3 environment be removed after use (experimental)?
# usecursors Should DB3 cursors be used in get/put/del (experimental)?
#
-%__dbi_flags create:mpool
+%__dbi_flags mpool
%__dbi_type hash
%__dbi_perms perms=0644
%__dbi_major db%{_dbapi}
-%__dbi_other teardown:usecursors
+%__dbi_other usecursors
%__dbi_verbose verbose
%__dbi_mp_mmapsize mp_mmapsize=16Mb
%__dbi_mp_size mp_size=2Mb
+# This is a colon (or white space) separated list of tokens for Berkeley
+# dbi configuration.
%_dbi_config \
%{__dbi_flags}\
%{__dbi_type}\
@@ -261,6 +265,7 @@
%{__dbi_mp_size}\
%{nil}
+# This is the list of tags for which indices will be built.
%_dbi_indices Packages:Name:Basenames:Group:Requirename:Providename:Conflictname:Triggername
#==============================================================================
diff --git a/po/rpm.pot b/po/rpm.pot
index f21b52223..1d170199e 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-23 16:19-0400\n"
+"POT-Creation-Date: 2000-04-25 15:13-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"
@@ -1987,156 +1987,166 @@ msgid " failed - "
msgstr ""
#. XXX legacy epoch-less requires/conflicts compatibility
-#: lib/depends.c:434
+#: lib/depends.c:439
#, c-format
msgid ""
"the \"B\" dependency needs an epoch (assuming same as \"A\")\n"
"\tA %s\tB %s\n"
msgstr ""
-#: lib/depends.c:463
+#: lib/depends.c:468
#, c-format
msgid " %s A %s\tB %s\n"
msgstr ""
-#: lib/depends.c:792
+#: lib/depends.c:797
#, c-format
msgid "%s: %s satisfied by added file list.\n"
msgstr ""
-#: lib/depends.c:841
+#: lib/depends.c:846
#, c-format
msgid "%s: %s satisfied by added package.\n"
msgstr ""
-#: lib/depends.c:844
+#: lib/depends.c:849
#, c-format
msgid "%s: %s satisfied by added package (shouldn't happen).\n"
msgstr ""
-#: lib/depends.c:862
+#: lib/depends.c:867
#, c-format
msgid "%s: %s satisfied by added provide.\n"
msgstr ""
-#: lib/depends.c:895
+#: lib/depends.c:896
+#, c-format
+msgid "%s: %s satisfied by Depends cache.\n"
+msgstr ""
+
+#: lib/depends.c:909
#, c-format
msgid "%s: %s satisfied by rpmrc provides.\n"
msgstr ""
-#: lib/depends.c:923
+#: lib/depends.c:937
#, c-format
msgid "%s: %s satisfied by db file lists.\n"
msgstr ""
-#: lib/depends.c:941
+#: lib/depends.c:955
#, c-format
msgid "%s: %s satisfied by db provides.\n"
msgstr ""
-#: lib/depends.c:959
+#: lib/depends.c:973
#, c-format
msgid "%s: %s satisfied by db packages.\n"
msgstr ""
-#: lib/depends.c:972
+#: lib/depends.c:986
#, c-format
msgid "%s: %s satisfied by rpmlib version.\n"
msgstr ""
-#: lib/depends.c:982
+#: lib/depends.c:996
#, c-format
msgid "%s: %s unsatisfied.\n"
msgstr ""
#. requirements are not satisfied.
-#: lib/depends.c:1030
+#: lib/depends.c:1048
#, c-format
msgid "package %s require not satisfied: %s\n"
msgstr ""
#. conflicts exist.
-#: lib/depends.c:1092
+#: lib/depends.c:1110
#, c-format
msgid "package %s conflicts: %s\n"
msgstr ""
-#: lib/depends.c:1222
+#: lib/depends.c:1240
#, c-format
msgid "loop in prerequisite chain: %s"
msgstr ""
-#: lib/depends.c:1426
+#: lib/depends.c:1444
#, c-format
msgid "cannot read header at %d for dependency check"
msgstr ""
-#: lib/db0.c:608
+#: lib/db0.c:565
#, c-format
msgid "bad db file %s"
msgstr ""
-#: lib/db0.c:617
+#: lib/db0.c:574
#, c-format
msgid "opening database mode 0x%x in %s\n"
msgstr ""
-#: lib/db0.c:622 lib/url.c:445
+#: lib/db0.c:579 lib/url.c:445
#, c-format
msgid "failed to open %s: %s\n"
msgstr ""
-#: lib/db0.c:634
+#: lib/db0.c:591
#, c-format
msgid "cannot get %s lock on database"
msgstr ""
-#: lib/db0.c:635
+#: lib/db0.c:592
msgid "exclusive"
msgstr ""
-#: lib/db0.c:635
+#: lib/db0.c:592
msgid "shared"
msgstr ""
-#: lib/db3.c:243
+#: lib/db3.c:249
#, c-format
msgid "dbiSetConfig: unrecognized db option: \"%s\" ignored\n"
msgstr ""
-#: lib/db3.c:269
+#: lib/db3.c:277
#, c-format
msgid "%s has invalid numeric value, skipped\n"
msgstr ""
-#: lib/db3.c:277
+#: lib/db3.c:285
#, c-format
msgid "%s has too large or too small long value, skipped\n"
msgstr ""
-#: lib/db3.c:285
+#: lib/db3.c:293
#, c-format
msgid "%s has too large or too small integer value, skipped\n"
msgstr ""
-#: lib/db3.c:440
+#: lib/db3.c:456
#, c-format
msgid "closed db environment %s/%s(%s)\n"
msgstr ""
-#: lib/db3.c:451
+#: lib/db3.c:468
#, c-format
msgid "removed db environment %s/%s(%s)\n"
msgstr ""
-#: lib/db3.c:1050
+#: lib/db3.c:505
+#, c-format
+msgid "opening db environment %s/%s(%s) %s\n"
+msgstr ""
+
+#: lib/db3.c:1117
#, c-format
-msgid "closed db index %s/%s(%s)\n"
+msgid "closed db index %s/%s(%s)\n"
msgstr ""
-#: lib/db3.c:1225
+#: lib/db3.c:1195
#, c-format
-msgid "opened %s/%s(%s) %s\n"
+msgid "opening db index %s/%s(%s) %s\n"
msgstr ""
#: lib/falloc.c:135
@@ -2150,7 +2160,7 @@ msgid ""
msgstr ""
#: lib/formats.c:69 lib/formats.c:86 lib/formats.c:106 lib/formats.c:138
-#: lib/header.c:2188 lib/header.c:2204 lib/header.c:2223
+#: lib/header.c:2190 lib/header.c:2206 lib/header.c:2225
msgid "(not a number)"
msgstr ""
@@ -2183,74 +2193,74 @@ msgstr ""
msgid "grabData() RPM_STRING_TYPE count must be 1.\n"
msgstr ""
-#: lib/header.c:250 lib/header.c:813
+#: lib/header.c:250 lib/header.c:815
#, c-format
msgid "Data type %d not supported\n"
msgstr ""
-#: lib/header.c:1172
+#: lib/header.c:1174
#, c-format
msgid "Bad count for headerAddEntry(): %d\n"
msgstr ""
-#: lib/header.c:1581
+#: lib/header.c:1583
#, c-format
msgid "missing { after %"
msgstr ""
-#: lib/header.c:1609
+#: lib/header.c:1611
msgid "missing } after %{"
msgstr ""
-#: lib/header.c:1621
+#: lib/header.c:1623
msgid "empty tag format"
msgstr ""
-#: lib/header.c:1631
+#: lib/header.c:1633
msgid "empty tag name"
msgstr ""
-#: lib/header.c:1646
+#: lib/header.c:1648
msgid "unknown tag"
msgstr ""
-#: lib/header.c:1672
+#: lib/header.c:1674
msgid "] expected at end of array"
msgstr ""
-#: lib/header.c:1688
+#: lib/header.c:1690
msgid "unexpected ]"
msgstr ""
-#: lib/header.c:1690
+#: lib/header.c:1692
msgid "unexpected }"
msgstr ""
-#: lib/header.c:1744
+#: lib/header.c:1746
msgid "? expected in expression"
msgstr ""
-#: lib/header.c:1751
+#: lib/header.c:1753
msgid "{ expected after ? in expression"
msgstr ""
-#: lib/header.c:1761 lib/header.c:1796
+#: lib/header.c:1763 lib/header.c:1798
msgid "} expected in expression"
msgstr ""
-#: lib/header.c:1769
+#: lib/header.c:1771
msgid ": expected following ? subexpression"
msgstr ""
-#: lib/header.c:1783
+#: lib/header.c:1785
msgid "{ expected after : in expression"
msgstr ""
-#: lib/header.c:1804
+#: lib/header.c:1806
msgid "| expected at end of expression"
msgstr ""
-#: lib/header.c:1972
+#: lib/header.c:1974
msgid "(unknown type)"
msgstr ""
@@ -2827,22 +2837,22 @@ msgstr ""
msgid "dbiTagsInit: unrecognized tag name: \"%s\" ignored\n"
msgstr ""
-#: lib/rpmdb.c:136
+#: lib/rpmdb.c:135
#, c-format
msgid "error getting record %s from %s index"
msgstr ""
-#: lib/rpmdb.c:157
+#: lib/rpmdb.c:156
#, c-format
msgid "error storing record %s into %s"
msgstr ""
-#: lib/rpmdb.c:162
+#: lib/rpmdb.c:161
#, c-format
msgid "error removing record %s from %s"
msgstr ""
-#: lib/rpmdb.c:343
+#: lib/rpmdb.c:345
msgid ""
"\n"
"--> Please run \"rpm --rebuilddb\" as root to convert your database from\n"
@@ -2850,145 +2860,145 @@ msgid ""
"\n"
msgstr ""
-#: lib/rpmdb.c:358
+#: lib/rpmdb.c:360
#, c-format
-msgid "dbiOpenIndex: cannot open %s index"
+msgid "dbiOpen: cannot open %s index"
msgstr ""
-#: lib/rpmdb.c:481 lib/rpmdb.c:1791
+#: lib/rpmdb.c:473 lib/rpmdb.c:1795
msgid "no dbpath has been set"
msgstr ""
-#: lib/rpmdb.c:558
+#: lib/rpmdb.c:551
msgid ""
"old format database is present; use --rebuilddb to generate a new format "
"database"
msgstr ""
#. error
-#: lib/rpmdb.c:743
+#: lib/rpmdb.c:736
#, c-format
msgid "cannot retrieve package \"%s\" from db"
msgstr ""
-#: lib/rpmdb.c:1077
+#: lib/rpmdb.c:1076
#, c-format
msgid "key \"%s\" not found in %s"
msgstr ""
-#: lib/rpmdb.c:1085
+#: lib/rpmdb.c:1084
#, c-format
msgid "key \"%s\" not removed from %s"
msgstr ""
-#: lib/rpmdb.c:1111
+#: lib/rpmdb.c:1110
#, c-format
msgid "rpmdbRemove: cannot read header at 0x%x"
msgstr ""
-#: lib/rpmdb.c:1145
+#: lib/rpmdb.c:1144
#, c-format
msgid "removing 0 %s entries.\n"
msgstr ""
-#: lib/rpmdb.c:1152
+#: lib/rpmdb.c:1151
#, c-format
msgid "removing \"%s\" from %s index.\n"
msgstr ""
-#: lib/rpmdb.c:1160
+#: lib/rpmdb.c:1159
#, c-format
msgid "removing %d entries in %s index:\n"
msgstr ""
-#: lib/rpmdb.c:1164
+#: lib/rpmdb.c:1163
#, c-format
msgid "\t%6d %s\n"
msgstr ""
-#: lib/rpmdb.c:1307
+#: lib/rpmdb.c:1310
msgid "cannot allocate new instance in database"
msgstr ""
-#: lib/rpmdb.c:1355
+#: lib/rpmdb.c:1359
#, c-format
msgid "adding 0 %s entries.\n"
msgstr ""
-#: lib/rpmdb.c:1368
+#: lib/rpmdb.c:1372
#, c-format
msgid "adding \"%s\" to %s index.\n"
msgstr ""
-#: lib/rpmdb.c:1375
+#: lib/rpmdb.c:1379
#, c-format
msgid "adding %d entries to %s index:\n"
msgstr ""
-#: lib/rpmdb.c:1379
+#: lib/rpmdb.c:1383
#, c-format
msgid "%6d %s\n"
msgstr ""
-#: lib/rpmdb.c:1697
+#: lib/rpmdb.c:1701
#, c-format
msgid "cannot read header at %d for lookup"
msgstr ""
-#: lib/rpmdb.c:1816
+#: lib/rpmdb.c:1820
#, c-format
msgid "rebuilding database %s into %s\n"
msgstr ""
-#: lib/rpmdb.c:1820
+#: lib/rpmdb.c:1824
#, c-format
msgid "temporary database %s already exists"
msgstr ""
-#: lib/rpmdb.c:1826
+#: lib/rpmdb.c:1830
#, c-format
msgid "creating directory: %s\n"
msgstr ""
-#: lib/rpmdb.c:1828
+#: lib/rpmdb.c:1832
#, c-format
msgid "error creating directory %s: %s"
msgstr ""
-#: lib/rpmdb.c:1835
+#: lib/rpmdb.c:1839
#, c-format
msgid "opening old database with dbi_major %d\n"
msgstr ""
-#: lib/rpmdb.c:1844
+#: lib/rpmdb.c:1848
#, c-format
msgid "opening new database with dbi_major %d\n"
msgstr ""
-#: lib/rpmdb.c:1866
+#: lib/rpmdb.c:1870
#, c-format
msgid "record number %d in database is bad -- skipping."
msgstr ""
-#: lib/rpmdb.c:1898
+#: lib/rpmdb.c:1902
#, c-format
msgid "cannot add record originally at %d"
msgstr ""
-#: lib/rpmdb.c:1916
+#: lib/rpmdb.c:1920
msgid "failed to rebuild database; original database remains in place\n"
msgstr ""
-#: lib/rpmdb.c:1924
+#: lib/rpmdb.c:1928
msgid "failed to replace old database with new database!\n"
msgstr ""
-#: lib/rpmdb.c:1926
+#: lib/rpmdb.c:1930
#, c-format
msgid "replace files in %s with files from %s to recover"
msgstr ""
-#: lib/rpmdb.c:1932
+#: lib/rpmdb.c:1936
#, c-format
msgid "failed to remove directory %s: %s\n"
msgstr ""
diff --git a/rpmio/rpmmalloc.c b/rpmio/rpmmalloc.c
index 5e1b60211..b4b4f1db9 100644
--- a/rpmio/rpmmalloc.c
+++ b/rpmio/rpmmalloc.c
@@ -4,9 +4,9 @@
#define EXIT_FAILURE 1
#endif
-void *vmefail(void)
+void *vmefail(size_t size)
{
- fprintf(stderr, _("memory alloc returned NULL.\n"));
+ fprintf(stderr, _("memory alloc (%u bytes) returned NULL.\n"), size);
exit(EXIT_FAILURE);
/*@notreached@*/
return NULL;
@@ -20,7 +20,7 @@ void * xmalloc (size_t size)
if (size == 0) size++;
value = malloc (size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
@@ -31,7 +31,7 @@ void * xcalloc (size_t nmemb, size_t size)
if (nmemb == 0) nmemb++;
value = calloc (nmemb, size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
@@ -41,15 +41,16 @@ void * xrealloc (void *ptr, size_t size)
if (size == 0) size++;
value = realloc (ptr, size);
if (value == 0)
- value = vmefail();
+ value = vmefail(size);
return value;
}
char * xstrdup (const char *str)
{
- char *newstr = (char *) malloc (strlen(str) + 1);
+ size_t size = strlen(str) + 1;
+ char *newstr = (char *) malloc (size);
if (newstr == 0)
- newstr = (char *) vmefail();
+ newstr = (char *) vmefail(size);
strcpy (newstr, str);
return newstr;
}
diff --git a/system.h b/system.h
index 8a03d5542..a6bb90ba7 100644
--- a/system.h
+++ b/system.h
@@ -204,7 +204,7 @@ char *alloca ();
/*@only@*/ void * xcalloc (size_t nmemb, size_t size);
/*@only@*/ void * xrealloc (void *ptr, size_t size);
/*@only@*/ char * xstrdup (const char *str);
-void *vmefail(void);
+void *vmefail(size_t size);
#if HAVE_MCHECK_H
#include <mcheck.h>
@@ -213,10 +213,10 @@ void *vmefail(void);
/* Memory allocation via macro defs to get meaningful locations from mtrace() */
#if HAVE_MCHECK_H && defined(__GNUC__)
-#define xmalloc(_size) (malloc(_size) ? : vmefail())
-#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail())
-#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail())
-#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail()), (_str)))
+#define xmalloc(_size) (malloc(_size) ? : vmefail(_size))
+#define xcalloc(_nmemb, _size) (calloc((_nmemb), (_size)) ? : vmefail(_size))
+#define xrealloc(_ptr, _size) (realloc((_ptr), (_size)) ? : vmefail(_size))
+#define xstrdup(_str) (strcpy((malloc(strlen(_str)+1) ? : vmefail(strlen(_str)+1)), (_str)))
#endif /* HAVE_MCHECK_H && defined(__GNUC__) */
/* Retrofit glibc __progname */