summaryrefslogtreecommitdiff
path: root/rpmdb
diff options
context:
space:
mode:
Diffstat (limited to 'rpmdb')
-rw-r--r--rpmdb/Makefile.am10
-rw-r--r--rpmdb/db3.c115
-rw-r--r--rpmdb/dbconfig.c11
-rw-r--r--rpmdb/falloc.c523
-rw-r--r--rpmdb/falloc.h82
-rw-r--r--rpmdb/legacy.c2
-rw-r--r--rpmdb/rpmdb.c101
-rw-r--r--rpmdb/rpmdb.h41
8 files changed, 124 insertions, 761 deletions
diff --git a/rpmdb/Makefile.am b/rpmdb/Makefile.am
index beb4b61d4..d7d9dcf31 100644
--- a/rpmdb/Makefile.am
+++ b/rpmdb/Makefile.am
@@ -11,7 +11,7 @@ INCLUDES = \
-I$(top_srcdir)/popt \
@INCPATH@
-EXTRA_DIST = db3.c db1.c falloc.c
+EXTRA_DIST = db3.c
EXTRA_PROGRAMS = tjfn
@@ -21,7 +21,7 @@ tjfn_LDADD = librpmdb.la
pkgincdir = $(pkgincludedir)
pkginc_HEADERS = db.h header.h hdrinline.h rpmdb.h
-noinst_HEADERS = falloc.h fprint.h header_internal.h legacy.h rpmhash.h
+noinst_HEADERS = fprint.h header_internal.h legacy.h rpmhash.h
mylibpaths = \
-L$(top_builddir)/lib \
@@ -49,9 +49,6 @@ install-data-local:
sed -e "s|^dependency_libs='|& -lrpmio|" < librpmdb.la > .librpmdb.la && \
mv .librpmdb.la librpmdb.la
-falloc.lo: falloc.c $(top_srcdir)/system.h $(top_srcdir)/rpmio/rpmio.h falloc.h
- $(LIBTOOL) --mode=compile $(COMPILE) -c $<
-
tagtbl.c: $(top_srcdir)/lib/rpmlib.h
@echo '#include "system.h"' > $@
@echo '#include "lib/rpmlib.h"' >> $@
@@ -93,6 +90,3 @@ lclint:
tdbi: librpmdb.la tdbi.o
$(LINK) -all-static $@.o $< $(mylibpaths) $(mylibs) $(LIBS)
-
-tfalloc: librpmdb.la tfalloc.o
- $(LINK) -all-static $@.o $< $(mylibpaths) $(mylibs) $(LIBS)
diff --git a/rpmdb/db3.c b/rpmdb/db3.c
index 83644011e..28bc26a2d 100644
--- a/rpmdb/db3.c
+++ b/rpmdb/db3.c
@@ -12,17 +12,6 @@ static int _debug = 1; /* XXX if < 0 debugging, > 0 unusual error returns */
#include <sys/ipc.h>
#endif
-#if defined(__LCLINT__)
-/*@-redef@*/ /* FIX: rpmio/rpmio.c also declares */
-typedef unsigned int u_int32_t;
-typedef unsigned short u_int16_t;
-typedef unsigned char u_int8_t;
-/*@-incondefs@*/ /* LCLint 3.0.0.15 */
-typedef int int32_t;
-/*@=incondefs@*/
-/*@=redef@*/
-#endif
-
#include <rpmlib.h>
#include <rpmmacro.h>
#include <rpmurl.h> /* XXX urlPath proto */
@@ -88,9 +77,7 @@ static int cvtdberr(dbiIndex dbi, const char * msg, int error, int printit)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
- int rc = 0;
-
- rc = error;
+ int rc = error;
if (printit && rc) {
/*@-moduncon@*/ /* FIX: annotate db3 methods */
@@ -313,8 +300,10 @@ static int db3sync(dbiIndex dbi, unsigned int flags)
return rc;
}
-/*@unused@*/ static int db3c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp,
- u_int32_t flags)
+#ifdef DYING
+/*@unused@*/
+static int db3c_dup(dbiIndex dbi, DBC * dbcursor, DBC ** dbcp,
+ unsigned int flags)
/*@globals fileSystem @*/
/*@modifies *dbcp, fileSystem @*/
{
@@ -327,97 +316,60 @@ static int db3sync(dbiIndex dbi, unsigned int flags)
return rc;
/*@=nullstate @*/
}
+#endif
-static inline int db3c_close(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor)
+static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
+ unsigned int flags)
/*@globals fileSystem @*/
- /*@modifies fileSystem @*/
+ /*@modifies dbi, fileSystem @*/
{
int rc;
- if (dbcursor == NULL) return -2;
-
+ assert(dbcursor != NULL);
rc = dbcursor->c_close(dbcursor);
rc = cvtdberr(dbi, "dbcursor->c_close", rc, _debug);
return rc;
}
-static inline int db3c_open(dbiIndex dbi, DB_TXN * txnid,
- /*@null@*/ /*@out@*/ DBC ** dbcp, int dbiflags)
+static int db3copen(dbiIndex dbi, DB_TXN * txnid,
+ /*@null@*/ /*@out@*/ DBC ** dbcp, unsigned int dbiflags)
/*@globals fileSystem @*/
- /*@modifies *dbcp, fileSystem @*/
+ /*@modifies dbi, *dbcp, fileSystem @*/
{
DB * db = dbi->dbi_db;
+ DBC * dbcursor = NULL;
int flags;
int rc;
- if (db == NULL) return -2;
- if ((dbiflags & DBI_WRITECURSOR) &&
+ assert(db != NULL);
+ if ((dbiflags & DB_WRITECURSOR) &&
(dbi->dbi_eflags & DB_INIT_CDB) && !(dbi->dbi_oflags & DB_RDONLY))
{
flags = DB_WRITECURSOR;
} else
flags = 0;
- if (dbcp) *dbcp = NULL;
- rc = db->cursor(db, txnid, dbcp, flags);
- rc = cvtdberr(dbi, "db3c_open", rc, _debug);
-
- return rc;
-}
-
-static int db3cclose(dbiIndex dbi, /*@only@*/ /*@null@*/ DBC * dbcursor,
- unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies dbi, fileSystem @*/
-{
- int rc = 0;
-
- /* XXX per-iterator cursors */
- if (flags & DBI_ITERATOR)
- return db3c_close(dbi, dbcursor);
-
- if (!dbi->dbi_use_cursors)
- return 0;
-
- if (dbcursor) {
- rc = db3c_close(dbi, dbcursor);
- }
- /*@-usereleased -compdef@*/ return rc; /*@=usereleased =compdef@*/
-}
-
-static int db3copen(dbiIndex dbi, DB_TXN * txnid,
- /*@null@*/ /*@out@*/ DBC ** dbcp, unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies dbi, *dbcp, fileSystem @*/
-{
- DBC * dbcursor;
- int rc = 0;
-
- /* XXX per-iterator cursors */
- if (flags & DBI_ITERATOR)
- return db3c_open(dbi, txnid, dbcp, flags);
-
- if (!dbi->dbi_use_cursors) {
- if (dbcp) *dbcp = NULL;
- return 0;
- }
- rc = db3c_open(dbi, txnid, &dbcursor, flags);
+ rc = db->cursor(db, txnid, &dbcursor, flags);
+ rc = cvtdberr(dbi, "db->cursor", rc, _debug);
if (dbcp)
/*@-onlytrans@*/ *dbcp = dbcursor; /*@=onlytrans@*/
+ else
+ (void) db3cclose(dbi, dbcursor, 0);
return rc;
}
-static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data)
+static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem @*/
/*@modifies fileSystem @*/
{
DB * db = dbi->dbi_db;
int rc;
+ assert(db != NULL);
if (dbcursor == NULL) {
- if (db == NULL) return -2;
rc = db->put(db, dbi->dbi_txnid, key, data, 0);
rc = cvtdberr(dbi, "db->put", rc, _debug);
} else {
@@ -428,53 +380,48 @@ static int db3cput(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data)
return rc;
}
-static int db3cdel(dbiIndex dbi, DBC * dbcursor, DBT * key, unsigned int flags)
+static int db3cdel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem @*/
/*@modifies *dbcursor, fileSystem @*/
{
DB * db = dbi->dbi_db;
int rc;
+ assert(db != NULL);
if (dbcursor == NULL) {
- if (db == NULL) return -2;
rc = db->del(db, dbi->dbi_txnid, key, flags);
rc = cvtdberr(dbi, "db->del", rc, _debug);
} else {
- DBT * data = alloca(sizeof(*data));
int _printit;
- memset(data, 0, sizeof(*data));
-
+ /* XXX TODO: insure that cursor is positioned with duplicates */
rc = dbcursor->c_get(dbcursor, key, data, DB_SET);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
rc = cvtdberr(dbi, "dbcursor->c_get", rc, _printit);
if (rc == 0) {
- /* XXX TODO: loop over duplicates */
rc = dbcursor->c_del(dbcursor, flags);
rc = cvtdberr(dbi, "dbcursor->c_del", rc, _debug);
}
-
}
return rc;
}
-static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data)
+static int db3cget(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem @*/
/*@modifies *dbcursor, *key, *data, fileSystem @*/
{
DB * db = dbi->dbi_db;
int rc;
+ assert(db != NULL);
if (dbcursor == NULL) {
int _printit;
- /*@-compmempass@*/
- if (db == NULL) return -2;
- /*@=compmempass@*/
-
rc = db->get(db, dbi->dbi_txnid, key, data, 0);
/* XXX DB_NOTFOUND can be returned */
_printit = (rc == DB_NOTFOUND ? 0 : _debug);
@@ -541,7 +488,7 @@ static int db3stat(dbiIndex dbi, unsigned int flags)
DB * db = dbi->dbi_db;
int rc = 0;
- if (db == NULL) return -2;
+ assert(db != NULL);
#if defined(DB_FAST_STAT)
if (flags)
flags = DB_FAST_STAT;
diff --git a/rpmdb/dbconfig.c b/rpmdb/dbconfig.c
index efd32e8fc..d442ccbf8 100644
--- a/rpmdb/dbconfig.c
+++ b/rpmdb/dbconfig.c
@@ -4,17 +4,6 @@
#include "system.h"
-#if defined(__LCLINT__)
-/*@-redef@*/
-typedef unsigned int u_int32_t;
-typedef unsigned short u_int16_t;
-typedef unsigned char u_int8_t;
-/*@-incondefs@*/ /* LCLint 3.0.0.15 */
-typedef int int32_t;
-/*@=incondefs@*/
-/*@=redef@*/
-#endif
-
#include <rpmlib.h>
#include <rpmmacro.h>
diff --git a/rpmdb/falloc.c b/rpmdb/falloc.c
deleted file mode 100644
index 469f01575..000000000
--- a/rpmdb/falloc.c
+++ /dev/null
@@ -1,523 +0,0 @@
-/** \ingroup rpmio db1
- * \file rpmdb/falloc.c
- *
- * The entire file space is thus divided into blocks with a "struct fablock"
- * at the header of each. The size fields doubly link this block list.
- *
- * There is an additional free list weaved through the block list, which
- * keeps new allocations fast.
- *
- * Much of this was inspired by Knuth vol 1.
- *
- */
-
-#include "system.h"
-#include <rpmio_internal.h>
-#include <rpmmessages.h>
-#include <rpmerr.h>
-#include "falloc.h"
-#include "debug.h"
-
-/** \ingroup db1
- */
-#define FA_MAGIC 0x02050920
-
-struct faFileHeader {
- unsigned int magic;
- unsigned int firstFree;
-};
-
-struct faHeader {
- unsigned int size;
- unsigned int freeNext; /* offset of the next free block, 0 if none */
- unsigned int freePrev;
- unsigned int isFree;
-
- /* note that the u16's appear last for alignment/space reasons */
-};
-
-struct faFooter {
- unsigned int size;
- unsigned int isFree;
-} ;
-
-/* =============================================================== */
-/*@-nullassign@*/
-static struct FDIO_s fadio_s = {
- NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
- fadOpen, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL
-};
-/*@=nullassign@*/
-FDIO_t fadio = /*@-compmempass@*/ &fadio_s /*@=compmempass@*/ ;
-/* =============================================================== */
-
-/**
- * pread(2) clone.
- */
-static
-ssize_t Pread(FD_t fd, void * buf, size_t count, _libio_off_t offset)
- /*@globals fileSystem @*/
- /*@modifies fd, *buf, fileSystem @*/
-{
- if (Fseek(fd, offset, SEEK_SET) < 0)
- return -1;
- /*@-sizeoftype@*/
- return Fread(buf, sizeof(char), count, fd);
- /*@=sizeoftype@*/
-}
-
-/**
- * pwrite(2) clone.
- */
-static
-ssize_t Pwrite(FD_t fd, const void * buf, size_t count, _libio_off_t offset)
- /*@globals fileSystem @*/
- /*@modifies fd, fileSystem @*/
-{
- if (Fseek(fd, offset, SEEK_SET) < 0)
- return -1;
- /*@-sizeoftype@*/
- return Fwrite(buf, sizeof(char), count, fd);
- /*@=sizeoftype@*/
-}
-
-/* flags are the same as for open(2) - NULL returned on error */
-FD_t fadOpen(const char * path, int flags, mode_t perms)
-{
- struct faFileHeader newHdr;
- FD_t fd;
-
- if (flags & O_WRONLY)
- return NULL;
-
- /*@-type@*/ /* FIX: cast? */
- fd = ufdio->_open(path, flags, perms);
- /*@=type@*/
- if (Ferror(fd))
- /* XXX Fstrerror */
- return NULL;
-
- /*@-modobserver -observertrans -mods @*/
- memcpy(fadio, fdio, sizeof(*fadio));
- fadio->_open = fadOpen;
- /*@=modobserver =observertrans =mods @*/
-
- fdSetIo(fd, fadio);
- fadSetFirstFree(fd, 0);
- fadSetFileSize(fd, Fseek(fd, 0, SEEK_END));
-
- /* is this file brand new? */
- if (fadGetFileSize(fd) == 0) {
- newHdr.magic = FA_MAGIC;
- newHdr.firstFree = 0;
- /*@-sizeoftype@*/
- if (Fwrite(&newHdr, sizeof(char), sizeof(newHdr), fd) != sizeof(newHdr)) {
- (void) Fclose(fd);
- return NULL;
- }
- /*@=sizeoftype@*/
- fadSetFirstFree(fd, 0);
- fadSetFileSize(fd, sizeof(newHdr));
- } else {
- memset(&newHdr, 0, sizeof(newHdr));
- if (Pread(fd, &newHdr, sizeof(newHdr), 0) != sizeof(newHdr)) {
- (void) Fclose(fd);
- return NULL;
- }
- if (newHdr.magic != FA_MAGIC) {
- (void) Fclose(fd);
- return NULL;
- }
- fadSetFirstFree(fd, newHdr.firstFree);
- fadSetFileSize(fd, Fseek(fd, 0, SEEK_END));
-
- if (fadGetFileSize(fd) < 0) {
- (void) Fclose(fd);
- return NULL;
- }
- }
-
- /*@-refcounttrans@*/ return fd /*@=refcounttrans@*/ ;
-}
-
-/* returns 0 on failure */
-unsigned int fadAlloc(FD_t fd, unsigned int size)
-{
- unsigned int nextFreeBlock;
- unsigned int newBlockOffset;
- unsigned int footerOffset;
- int failed = 0;
- struct faFileHeader faHeader;
- struct faHeader header, origHeader;
- struct faHeader * restoreHeader = NULL;
- struct faHeader nextFreeHeader, origNextFreeHeader;
- struct faHeader * restoreNextHeader = NULL;
- struct faHeader prevFreeHeader, origPrevFreeHeader;
- struct faHeader * restorePrevHeader = NULL;
- struct faFooter footer, origFooter;
- struct faFooter * restoreFooter = NULL;
- int updateHeader = 0;
-
- memset(&header, 0, sizeof(header));
-
- /* our internal idea of size includes overhead */
- /*@-sizeoftype@*/
- size += sizeof(struct faHeader) + sizeof(struct faFooter);
- /*@=sizeoftype@*/
-
- /* Make sure they are allocing multiples of 64 bytes. It'll keep
- things less fragmented that way */
- (size % 64) ? size += (64 - (size % 64)) : 0;
-
- /* find a block via first fit - see Knuth vol 1 for why */
- /* XXX this could be optimized a bit still */
-
- nextFreeBlock = fadGetFirstFree(fd);
- newBlockOffset = 0;
-
- while (nextFreeBlock && !newBlockOffset) {
- if (Pread(fd, &header, sizeof(header), nextFreeBlock) != sizeof(header)) return 0;
-
-/* XXX W2DO? exit(EXIT_FAILURE) forces the user to discover rpm --rebuilddb */
- if (!header.isFree) {
- rpmError(RPMERR_FREELIST, _("free list corrupt (%u)- please run\n"
- "\t\"rpm --rebuilddb\"\n"
- "More information is available from http://www.rpm.org "
- "or the rpm-list@redhat.com mailing list\n"
- "if \"rpm --rebuilddb\" fails to correct the problem.\n"),
- nextFreeBlock);
-
- exit(EXIT_FAILURE);
- /*@notreached@*/
- }
-
- if (header.size >= size) {
- newBlockOffset = nextFreeBlock;
- } else {
- nextFreeBlock = header.freeNext;
- }
- }
-
- if (newBlockOffset) {
- /* header should still be good from the search */
- origHeader = header;
-
- footerOffset = newBlockOffset + header.size - sizeof(footer);
-
- if (Pread(fd, &footer, sizeof(footer), footerOffset) != sizeof(footer))
- return 0;
- origFooter = footer;
-
- /* should we split this block into two? */
- /* XXX implement fragment creation here */
-
- footer.isFree = header.isFree = 0;
-
- /* remove it from the free list before */
- if (newBlockOffset == fadGetFirstFree(fd)) {
- faHeader.magic = FA_MAGIC;
- faHeader.firstFree = header.freeNext;
- fadSetFirstFree(fd, header.freeNext);
- updateHeader = 1;
- } else {
- if (Pread(fd, &prevFreeHeader, sizeof(prevFreeHeader),
- header.freePrev) != sizeof(prevFreeHeader))
- return 0;
- origPrevFreeHeader = prevFreeHeader;
-
- prevFreeHeader.freeNext = header.freeNext;
- }
-
- /* and after */
- if (header.freeNext) {
- if (Pread(fd, &nextFreeHeader, sizeof(nextFreeHeader),
- header.freeNext) != sizeof(nextFreeHeader))
- return 0;
- origNextFreeHeader = nextFreeHeader;
-
- nextFreeHeader.freePrev = header.freePrev;
- }
-
- /* if any of these fail, try and restore everything before leaving */
- if (updateHeader) {
- if (Pwrite(fd, &faHeader, sizeof(faHeader), 0) !=
- sizeof(faHeader))
- return 0;
- } else {
- if (Pwrite(fd, &prevFreeHeader, sizeof(prevFreeHeader),
- header.freePrev) != sizeof(prevFreeHeader))
- return 0;
- restorePrevHeader = &origPrevFreeHeader;
- }
-
- if (header.freeNext) {
- if (Pwrite(fd, &nextFreeHeader, sizeof(nextFreeHeader),
- header.freeNext) != sizeof(nextFreeHeader))
- return 0;
-
- restoreNextHeader = &origNextFreeHeader;
- }
-
- if (!failed) {
- if (Pwrite(fd, &header, sizeof(header), newBlockOffset) !=
- sizeof(header)) {
- failed = 1;
- restoreHeader = &origHeader;
- }
- }
-
- if (!failed) {
- if (Pwrite(fd, &footer, sizeof(footer),
- footerOffset) != sizeof(footer)) {
- failed = 1;
- restoreFooter = &origFooter;
- }
- }
-
- if (failed) {
- if (updateHeader) {
- faHeader.firstFree = newBlockOffset;
- fadSetFirstFree(fd, newBlockOffset);
- (void)Pwrite(fd, &faHeader, sizeof(faHeader), 0);
- }
-
- if (restorePrevHeader)
- (void)Pwrite(fd, restorePrevHeader, sizeof(*restorePrevHeader),
- header.freePrev);
-
- if (restoreNextHeader)
- (void)Pwrite(fd, restoreNextHeader, sizeof(*restoreNextHeader),
- header.freeNext);
-
- if (restoreHeader)
- (void)Pwrite(fd, restoreHeader, sizeof(header),
- newBlockOffset);
-
- if (restoreFooter)
- (void)Pwrite(fd, restoreFooter, sizeof(footer),
- footerOffset);
-
- return 0;
- }
- } else {
- char * space;
-
- /* make a new block */
- newBlockOffset = fadGetFileSize(fd);
- footerOffset = newBlockOffset + size - sizeof(footer);
-
- space = alloca(size);
- if (space == NULL) return 0;
- memset(space, 0, size);
-
- footer.isFree = header.isFree = 0;
- footer.size = header.size = size;
- header.freePrev = header.freeNext = 0;
-
- /* reserve all space up front */
- /* XXX TODO: check max. no. of bytes to write */
- if (Pwrite(fd, space, size, newBlockOffset) != size)
- return 0;
-
- if (Pwrite(fd, &header, sizeof(header), newBlockOffset) != sizeof(header))
- return 0;
-
- if (Pwrite(fd, &footer, sizeof(footer), footerOffset) != sizeof(footer))
- return 0;
-
- fadSetFileSize(fd, fadGetFileSize(fd) + size);
- }
-
- return newBlockOffset + sizeof(header);
-}
-
-void fadFree(FD_t fd, unsigned int offset)
-{
- struct faHeader header;
- struct faFooter footer;
- int footerOffset;
- int prevFreeOffset, nextFreeOffset;
- struct faHeader prevFreeHeader, nextFreeHeader;
- struct faFileHeader faHeader;
-
- /* any errors cause this to die, and thus result in lost space in the
- database. which is at least better then corruption */
-
- offset -= sizeof(header);
-
- /* find out where in the (sorted) free list to put this */
- prevFreeOffset = fadGetFirstFree(fd);
-
- if (!prevFreeOffset || (prevFreeOffset > offset)) {
- nextFreeOffset = fadGetFirstFree(fd);
- prevFreeOffset = 0;
- } else {
- memset(&prevFreeHeader, 0, sizeof(prevFreeHeader));
- if (Pread(fd, &prevFreeHeader, sizeof(prevFreeHeader),
- prevFreeOffset) != sizeof(prevFreeHeader))
- return;
-
- while (prevFreeHeader.freeNext && prevFreeHeader.freeNext < offset) {
- prevFreeOffset = prevFreeHeader.freeNext;
- if (Pread(fd, &prevFreeHeader, sizeof(prevFreeHeader),
- prevFreeOffset) != sizeof(prevFreeHeader))
- return;
- }
-
- nextFreeOffset = prevFreeHeader.freeNext;
- }
-
- if (nextFreeOffset) {
- memset(&nextFreeHeader, 0, sizeof(nextFreeHeader));
- if (Pread(fd, &nextFreeHeader, sizeof(nextFreeHeader),
- nextFreeOffset) != sizeof(nextFreeHeader))
- return;
- }
-
- memset(&header, 0, sizeof(header));
- if (Pread(fd, &header, sizeof(header), offset) != sizeof(header))
- return;
-
- footerOffset = offset + header.size - sizeof(footer);
-
- memset(&footer, 0, sizeof(footer));
- if (Pread(fd, &footer, sizeof(footer), footerOffset) != sizeof(footer))
- return;
-
- header.isFree = 1;
- header.freeNext = nextFreeOffset;
- header.freePrev = prevFreeOffset;
- footer.isFree = 1;
-
- /* XXX TODO: set max. no. of bytes to write */
- (void)Pwrite(fd, &header, sizeof(header), offset);
-
- (void)Pwrite(fd, &footer, sizeof(footer), footerOffset);
-
- if (nextFreeOffset) {
- nextFreeHeader.freePrev = offset;
- if (Pwrite(fd, &nextFreeHeader, sizeof(nextFreeHeader),
- nextFreeOffset) != sizeof(nextFreeHeader))
- return;
- }
-
- if (prevFreeOffset) {
- prevFreeHeader.freeNext = offset;
- if (Pwrite(fd, &prevFreeHeader, sizeof(prevFreeHeader),
- prevFreeOffset) != sizeof(prevFreeHeader))
- return;
- } else {
- fadSetFirstFree(fd, offset);
-
- faHeader.magic = FA_MAGIC;
- faHeader.firstFree = fadGetFirstFree(fd);
-
- /* XXX TODO: set max. no. of bytes to write */
- if (Pwrite(fd, &faHeader, sizeof(faHeader), 0) != sizeof(faHeader))
- return;
- }
-}
-
-static int fadSanity(FD_t fd, int offset, const struct faHeader * fh, int printit)
- /*@*/
-{
- int rc = 0;
-
- /*@-sizeoftype@*/
- /* Check size range and alignment. */
- if (!(fh->size > 0 && fh->size <= 0x00200000 && (fh->size & 0x3f) == 0))
- rc |= 0x1;
-
- /* Check forward link range, alignment and offset. */
- if (fh->freeNext &&
- !( fh->freeNext > sizeof(struct faFileHeader) &&
- fh->freeNext < fadGetFileSize(fd) &&
- (fh->freeNext & 0x3f) == sizeof(struct faFileHeader)) )
- rc |= 0x2;
-
- /* Check backward link range, alignment and offset. */
- if (fh->freePrev &&
- !( fh->freePrev > sizeof(struct faFileHeader) &&
- fh->freePrev < fadGetFileSize(fd) &&
- (fh->freePrev & 0x3f) == sizeof(struct faFileHeader)) )
- rc |= 0x4;
- /*@=sizeoftype@*/
-
- /* Check that only the isFree bit is (possibly) set. */
- if (fh->isFree & ~1)
- rc |= 0x8;
-
- if (printit && rc) {
- rpmMessage(RPMMESS_DEBUG,
- "offset %d(0x%08x) rc %d: size 0x%08x next %d(0x%08x) prev %d(0x%08x) isFree 0x%08x\n",
- offset, (unsigned) offset, rc,
- (unsigned) fh->size,
- (int) fh->freeNext, fh->freeNext,
- (int) fh->freePrev, fh->freePrev,
- (unsigned) fh->isFree);
- }
- return rc;
-}
-
-int fadFirstOffset(FD_t fd)
-{
- return fadNextOffset(fd, 0);
-}
-
-int fadNextOffset(FD_t fd, unsigned int lastoff)
-{
- struct faHeader header;
- int offset;
-
- /*@-sizeoftype@*/
- offset = (lastoff)
- ? (lastoff - sizeof(header))
- : sizeof(struct faFileHeader);
- /*@=sizeoftype@*/
-
- if (offset >= fadGetFileSize(fd))
- return 0;
-
- memset(&header, 0, sizeof(header));
- if (Pread(fd, &header, sizeof(header), offset) != sizeof(header))
- return 0;
-
- if (!lastoff && header.isFree == 0)
- return (offset + sizeof(header));
-
- /*
- * XXX Try to reconnect at next record found. This isn't perfect
- * XXX but handles many common db1 corruption problems.
- */
- if (fadSanity(fd, offset, &header, 0)) {
- struct faHeader myheader;
- int o = offset;
-
- memset(&myheader, 0, sizeof(myheader));
- do {
- o += 0x40; /* XXX allocation chunks are padded to 64b */
- if (o >= fadGetFileSize(fd))
- return 0;
- if (Pread(fd, &myheader, sizeof(myheader), o) != sizeof(header))
- return 0;
- } while (fadSanity(fd, o, &myheader, 0));
- return (o + sizeof(header));
- }
-
- do {
- offset += header.size;
- if (offset >= fadGetFileSize(fd))
- return 0;
-
- if (Pread(fd, &header, sizeof(header), offset) != sizeof(header))
- return 0;
-
- } while (header.isFree == 1);
-
- /* Sanity check this to make sure we're not going in loops */
- offset += sizeof(header);
- if (offset <= lastoff)
- return 0; /* XXX used to return -1 */
-
- return offset;
-}
diff --git a/rpmdb/falloc.h b/rpmdb/falloc.h
deleted file mode 100644
index 55c55c7a0..000000000
--- a/rpmdb/falloc.h
+++ /dev/null
@@ -1,82 +0,0 @@
-#ifndef H_FALLOC
-#define H_FALLOC
-
-/** \ingroup db1
- * \file rpmdb/falloc.h
- * File space allocation routines.
- *
- * Best fit allocation is used, free blocks are compacted. Minimal
- * fragmentation is more important then speed. This uses 32 bit
- * offsets on all platforms and should be byte order independent.
- */
-
-/*@access FD_t@*/
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*@unused@*/ static inline long int fadGetFileSize(FD_t fd) /*@*/ {
- return fd->fileSize;
-}
-
-/*@unused@*/ static inline void fadSetFileSize(FD_t fd, long int fileSize)
- /*@modifies fd @*/
-{
- fd->fileSize = fileSize;
-}
-
-/*@unused@*/ static inline unsigned int fadGetFirstFree(FD_t fd) /*@*/ {
- return fd->firstFree;
-}
-
-/*@unused@*/ static inline void fadSetFirstFree(FD_t fd, unsigned int firstFree)
- /*@modifies fd @*/
-{
- fd->firstFree = firstFree;
-}
-
-/** \ingroup db1
- */
-/*@null@*/ FD_t fadOpen(const char * path, int flags, mode_t perms)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
-
-/** \ingroup db1
- * @param fd file handle
- * @param size
- * @return 0 on failure
- */
-unsigned int fadAlloc(FD_t fd, unsigned int size)
- /*@globals fileSystem @*/
- /*@modifies fd, fileSystem @*/;
-
-/** \ingroup db1
- * @param fd file handle
- * @param offset
- */
-void fadFree(FD_t fd, unsigned int offset)
- /*@globals fileSystem @*/
- /*@modifies fd, fileSystem @*/;
-
-/** \ingroup db1
- * @param fd file handle
- */
-int fadFirstOffset(FD_t fd)
- /*@globals fileSystem @*/
- /*@modifies fd, fileSystem @*/;
-
-/** \ingroup db1
- * @param fd file handle
- * @param lastoff
- * @return next offset, 0 to terminate
- */
-int fadNextOffset(FD_t fd, unsigned int lastoff)
- /*@globals fileSystem @*/
- /*@modifies fd, fileSystem @*/;
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* H_FALLOC */
diff --git a/rpmdb/legacy.c b/rpmdb/legacy.c
index 6df200de8..f90a2983d 100644
--- a/rpmdb/legacy.c
+++ b/rpmdb/legacy.c
@@ -153,6 +153,7 @@ void compressFilelist(Header h)
needle = dirNames;
savechar = *baseName;
*baseName = '\0';
+/*@-compdef@*/
if (dirIndex < 0 ||
(needle = bsearch(&fileNames[i], dirNames, dirIndex + 1, sizeof(dirNames[0]), dncmp)) == NULL) {
char *s = alloca(len + 1);
@@ -162,6 +163,7 @@ void compressFilelist(Header h)
dirNames[dirIndex] = s;
} else
dirIndexes[i] = needle - dirNames;
+/*@=compdef@*/
*baseName = savechar;
baseNames[i] = baseName;
diff --git a/rpmdb/rpmdb.c b/rpmdb/rpmdb.c
index 927a5e8b0..aaa661297 100644
--- a/rpmdb/rpmdb.c
+++ b/rpmdb/rpmdb.c
@@ -47,10 +47,6 @@ extern void regfree (/*@only@*/ regex_t *preg)
/*@access pgpDig@*/
/*@unchecked@*/
-static int _debug = 0;
-#define INLINE
-
-/*@unchecked@*/
static int _rebuildinprogress = 0;
/*@unchecked@*/
static int _db_filter_dups = 0;
@@ -320,7 +316,7 @@ exit:
* @param tagNum tag index in header
* @return new item
*/
-static INLINE dbiIndexItem dbiIndexNewItem(unsigned int hdrNum, unsigned int tagNum)
+static dbiIndexItem dbiIndexNewItem(unsigned int hdrNum, unsigned int tagNum)
/*@*/
{
dbiIndexItem rec = xcalloc(1, sizeof(*rec));
@@ -363,12 +359,14 @@ static int dbiSearch(dbiIndex dbi, DBC * dbcursor,
if (keylen == 0) keylen = strlen(keyp);
memset(key, 0, sizeof(*key));
+/*@-temptrans@*/
key->data = (void *) keyp;
+/*@=temptrans@*/
key->size = keylen;
memset(data, 0, sizeof(*data));
data->data = datap;
data->size = datalen;
- rc = dbiGet(dbi, dbcursor, key, data);
+ rc = dbiGet(dbi, dbcursor, key, data, 0);
keyp = key->data;
keylen = key->size;
datap = data->data;
@@ -453,8 +451,8 @@ static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor,
{
DBT * key = alloca(sizeof(*key));
DBT * data = alloca(sizeof(*data));
- void * datap;
- size_t datalen;
+ void * datap = NULL;
+ size_t datalen = 0;
int rc;
if (set->count) {
@@ -504,12 +502,16 @@ static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor,
}
memset(key, 0, sizeof(*key));
+/*@-temptrans@*/
key->data = (void *) keyp;
+/*@=temptrans@*/
key->size = keylen;
memset(data, 0, sizeof(*data));
data->data = datap;
data->size = datalen;
- rc = dbiPut(dbi, dbcursor, key, data);
+/*@-compdef@*/
+ rc = dbiPut(dbi, dbcursor, key, data, 0);
+/*@=compdef@*/
if (rc) {
rpmError(RPMERR_DBPUTINDEX,
@@ -520,9 +522,16 @@ static int dbiUpdateIndex(dbiIndex dbi, DBC * dbcursor,
} else {
memset(key, 0, sizeof(*key));
+/*@-temptrans@*/
key->data = (void *) keyp;
+/*@=temptrans@*/
key->size = keylen;
- rc = dbiDel(dbi, dbcursor, key, 0);
+ memset(data, 0, sizeof(*data));
+ data->data = datap;
+ data->size = datalen;
+/*@-compdef@*/
+ rc = dbiDel(dbi, dbcursor, key, data, 0);
+/*@=compdef@*/
if (rc) {
rpmError(RPMERR_DBPUTINDEX,
@@ -553,7 +562,7 @@ static int hdrNumCmp(const void * one, const void * two)
* @param sortset should resulting set be sorted?
* @return 0 success, 1 failure (bad args)
*/
-static INLINE int dbiAppendSet(dbiIndexSet set, const void * recs,
+static int dbiAppendSet(dbiIndexSet set, const void * recs,
int nrecs, size_t recsize, int sortset)
/*@modifies *set @*/
{
@@ -594,7 +603,7 @@ static INLINE int dbiAppendSet(dbiIndexSet set, const void * recs,
* @param sorted array is already sorted?
* @return 0 success, 1 failure (no items found)
*/
-static INLINE int dbiPruneSet(dbiIndexSet set, void * recs, int nrecs,
+static int dbiPruneSet(dbiIndexSet set, void * recs, int nrecs,
size_t recsize, int sorted)
/*@modifies set, recs @*/
{
@@ -1398,18 +1407,22 @@ static int dbiUpdateRecord(dbiIndex dbi, DBC * dbcursor, int offset, Header h)
DBT * data = alloca(sizeof(*data));
memset(key, 0, sizeof(*key));
+/*@-immediatetrans@*/
key->data = (void *) &offset;
+/*@=immediatetrans@*/
key->size = sizeof(offset);
memset(data, 0, sizeof(*data));
data->data = uh;
data->size = uhlen;
(void) blockSignals(dbi->dbi_rpmdb, &signalMask);
- rc = dbiPut(dbi, dbcursor, key, data);
+ rc = dbiPut(dbi, dbcursor, key, data, 0);
xx = dbiSync(dbi, 0);
(void) unblockSignals(dbi->dbi_rpmdb, &signalMask);
+/*@-kepttrans@*/
uh = _free(uh);
+/*@=kepttrans@*/
} else
fprintf(stderr, "*** dbiUpdateRecord: uh is NULL\n");
return rc;
@@ -1486,7 +1499,7 @@ rpmdbMatchIterator rpmdbFreeIterator(rpmdbMatchIterator mi)
mi->mi_version = _free(mi->mi_version);
/*@-branchstate@*/
if (dbi && mi->mi_dbc)
- xx = dbiCclose(dbi, mi->mi_dbc, DBI_ITERATOR);
+ xx = dbiCclose(dbi, mi->mi_dbc, 0);
/*@=branchstate@*/
mi->mi_dbc = NULL;
mi->mi_set = dbiFreeIndexSet(mi->mi_set);
@@ -1887,11 +1900,11 @@ int rpmdbSetIteratorRewrite(rpmdbMatchIterator mi, int rewrite) {
int rc;
if (mi == NULL)
return 0;
- rc = (mi->mi_cflags & DBI_WRITECURSOR) ? 1 : 0;
+ rc = (mi->mi_cflags & DB_WRITECURSOR) ? 1 : 0;
if (rewrite)
- mi->mi_cflags |= DBI_WRITECURSOR;
+ mi->mi_cflags |= DB_WRITECURSOR;
else
- mi->mi_cflags &= ~DBI_WRITECURSOR;
+ mi->mi_cflags &= ~DB_WRITECURSOR;
return rc;
}
@@ -1910,6 +1923,7 @@ Header XrpmdbNextIterator(rpmdbMatchIterator mi,
return rpmdbNextIterator(mi);
}
+/*@-compmempass@*/
Header rpmdbNextIterator(rpmdbMatchIterator mi)
{
dbiIndex dbi;
@@ -1936,7 +1950,7 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
* marked with DB_WRITECURSOR as well.
*/
if (mi->mi_dbc == NULL)
- xx = dbiCopen(dbi, dbi->dbi_txnid, &mi->mi_dbc, (mi->mi_cflags | DBI_ITERATOR));
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &mi->mi_dbc, mi->mi_cflags);
dbi->dbi_lastoffset = mi->mi_prevoffset;
key = alloca(sizeof(*key));
data = alloca(sizeof(*data));
@@ -1945,6 +1959,7 @@ top:
/* XXX skip over instances with 0 join key */
do {
+ /*@-branchstate@*/
if (mi->mi_set) {
if (!(mi->mi_setx < mi->mi_set->count))
return NULL;
@@ -1960,7 +1975,7 @@ top:
memset(data, 0, sizeof(*data));
data->data = uh;
data->size = uhlen;
- rc = dbiGet(dbi, mi->mi_dbc, key, data);
+ rc = dbiGet(dbi, mi->mi_dbc, key, data, 0);
keyp = key->data;
keylen = key->size;
uh = data->data;
@@ -1988,6 +2003,7 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
if (rc || (mi->mi_setx && mi->mi_offset == 0))
return NULL;
}
+ /*@=branchstate@*/
mi->mi_setx++;
} while (mi->mi_offset == 0);
@@ -1995,6 +2011,7 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
goto exit;
/* Retrieve next header */
+ /*@-branchstate -immediatetrans @*/
if (uh == NULL) {
memset(key, 0, sizeof(*key));
key->data = keyp;
@@ -2002,7 +2019,7 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
memset(data, 0, sizeof(*data));
uh = data->data;
uhlen = data->size;
- rc = dbiGet(dbi, mi->mi_dbc, key, data);
+ rc = dbiGet(dbi, mi->mi_dbc, key, data, 0);
keyp = key->data;
keylen = key->size;
uh = data->data;
@@ -2010,6 +2027,7 @@ if (dbi->dbi_api == 1 && dbi->dbi_rpmtag == RPMDBI_PACKAGES && rc == EFAULT) {
if (rc)
return NULL;
}
+ /*@=branchstate =immediatetrans @*/
/* Free current header */
if (mi->mi_h) {
@@ -2062,6 +2080,7 @@ exit:
/*@-compdef -usereleased@*/ return mi->mi_h; /*@=compdef =usereleased@*/
/*@=retexpose =retalias@*/
}
+/*@=compmempass@*/
static void rpmdbSortIterator(/*@null@*/ rpmdbMatchIterator mi)
/*@modifies mi @*/
@@ -2254,7 +2273,7 @@ rpmdbMatchIterator rpmdbInitIterator(rpmdb db, int rpmtag,
* @param rec record to remove
* @return 0 on success
*/
-static INLINE int removeIndexEntry(dbiIndex dbi, DBC * dbcursor,
+static int removeIndexEntry(dbiIndex dbi, DBC * dbcursor,
const void * keyp, size_t keylen, dbiIndexItem rec)
/*@globals fileSystem @*/
/*@modifies *dbcursor, fileSystem @*/
@@ -2286,6 +2305,7 @@ static INLINE int removeIndexEntry(dbiIndex dbi, DBC * dbcursor,
int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
{
DBT * key = alloca(sizeof(*key));
+ DBT * data = alloca(sizeof(*data));
HGE_t hge = (HGE_t)headerGetEntryMinMemory;
HFD_t hfd = headerFreeData;
Header h;
@@ -2356,12 +2376,15 @@ int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
if (dbi != NULL) {
memset(key, 0, sizeof(*key));
+/*@-immediatetrans@*/
key->data = &hdrNum;
+/*@=immediatetrans@*/
key->size = sizeof(hdrNum);
+ memset(data, 0, sizeof(*data));
- xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DBI_WRITECURSOR);
- xx = dbiDel(dbi, dbcursor, key, 0);
- xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
+ xx = dbiDel(dbi, dbcursor, key, data, 0);
+ xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
dbcursor = NULL;
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
@@ -2386,7 +2409,7 @@ int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
}
printed = 0;
- xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DBI_WRITECURSOR);
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
for (i = 0; i < rpmcnt; i++) {
const void * valp;
size_t vallen;
@@ -2488,7 +2511,7 @@ int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
xx = removeIndexEntry(dbi, dbcursor, valp, vallen, rec);
}
- xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
+ xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
dbcursor = NULL;
if (!dbi->dbi_no_dbsync)
@@ -2521,7 +2544,7 @@ int rpmdbRemove(rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
* @param rec record to add
* @return 0 on success
*/
-static INLINE int addIndexEntry(dbiIndex dbi, DBC * dbcursor,
+static int addIndexEntry(dbiIndex dbi, DBC * dbcursor,
const char * keyp, size_t keylen, dbiIndexItem rec)
/*@globals fileSystem @*/
/*@modifies *dbcursor, fileSystem @*/
@@ -2612,7 +2635,7 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
datap = h;
datalen = headerSizeof(h, HEADER_MAGIC_NO);
- xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DBI_WRITECURSOR);
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
/* Retrieve join key for next header instance. */
@@ -2620,9 +2643,11 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
key->data = keyp;
key->size = keylen;
memset(data, 0, sizeof(*data));
- data->data = datap;
+/*@i@*/ data->data = datap;
data->size = datalen;
- rc = dbiGet(dbi, dbcursor, key, data);
+/*@-compmempass@*/
+ rc = dbiGet(dbi, dbcursor, key, data, 0);
+/*@=compmempass@*/
keyp = key->data;
keylen = key->size;
datap = data->data;
@@ -2645,13 +2670,17 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
key->data = keyp;
key->size = keylen;
memset(data, 0, sizeof(*data));
+/*@-kepttrans@*/
data->data = datap;
+/*@=kepttrans@*/
data->size = datalen;
- rc = dbiPut(dbi, dbcursor, key, data);
+/*@-compmempass@*/
+ rc = dbiPut(dbi, dbcursor, key, data, 0);
+/*@=compmempass@*/
xx = dbiSync(dbi, 0);
- xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
+ xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
dbcursor = NULL;
}
/*@=branchstate@*/
@@ -2696,9 +2725,9 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
case RPMDBI_PACKAGES:
dbi = dbiOpen(db, rpmtag, 0);
if (dbi != NULL) {
- xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DBI_WRITECURSOR);
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
xx = dbiUpdateRecord(dbi, dbcursor, hdrNum, h);
- xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
+ xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
dbcursor = NULL;
if (!dbi->dbi_no_dbsync)
xx = dbiSync(dbi, 0);
@@ -2750,7 +2779,7 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
}
printed = 0;
- xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DBI_WRITECURSOR);
+ xx = dbiCopen(dbi, dbi->dbi_txnid, &dbcursor, DB_WRITECURSOR);
for (i = 0; i < rpmcnt; i++) {
const void * valp;
size_t vallen;
@@ -2866,7 +2895,7 @@ int rpmdbAdd(rpmdb db, int iid, Header h)
}
rc += addIndexEntry(dbi, dbcursor, valp, vallen, rec);
}
- xx = dbiCclose(dbi, dbcursor, DBI_WRITECURSOR);
+ xx = dbiCclose(dbi, dbcursor, DB_WRITECURSOR);
dbcursor = NULL;
if (!dbi->dbi_no_dbsync)
diff --git a/rpmdb/rpmdb.h b/rpmdb/rpmdb.h
index e9fdde843..f3b14e386 100644
--- a/rpmdb/rpmdb.h
+++ b/rpmdb/rpmdb.h
@@ -87,7 +87,7 @@ struct _dbiVec {
int (*copen) (dbiIndex dbi, /*@null@*/ DB_TXN * txnid,
/*@out@*/ DBC ** dbcp, unsigned int flags)
/*@globals fileSystem@*/
- /*@modifies dbi, *txnidp, *dbcp, fileSystem @*/;
+ /*@modifies dbi, *txnid, *dbcp, fileSystem @*/;
/** \ingroup dbi
* Close database cursor.
@@ -105,10 +105,11 @@ struct _dbiVec {
* @param dbi index database handle
* @param dbcursor database cursor (NULL will use db->del)
* @param key delete key value/length/flags
+ * @param data delete data value/length/flags
* @param flags (unused)
* @return 0 on success
*/
- int (*cdel) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key,
+ int (*cdel) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, fileSystem @*/;
@@ -119,9 +120,11 @@ struct _dbiVec {
* @param dbcursor database cursor (NULL will use db->get)
* @param key retrieve key value/length/flags
* @param data retrieve data value/length/flags
+ * @param flags (unused)
* @return 0 on success
*/
- int (*cget) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
+ int (*cget) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, *key, *data, fileSystem @*/;
@@ -131,9 +134,11 @@ struct _dbiVec {
* @param dbcursor database cursor (NULL will use db->put)
* @param key store key value/length/flags
* @param data store data value/length/flags
+ * @param flags (unused)
* @return 0 on success
*/
- int (*cput) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
+ int (*cput) (dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, fileSystem @*/;
@@ -376,8 +381,7 @@ dbiIndex db3Free( /*@only@*/ /*@null@*/ dbiIndex dbi)
*/
/*@-redecl@*/
/*@exposed@*/
-extern const char *const prDbiOpenFlags(int dbflags,
- int print_dbenv_flags)
+extern const char *const prDbiOpenFlags(int dbflags, int print_dbenv_flags)
/*@*/;
/*@=redecl@*/
@@ -392,12 +396,13 @@ extern const char *const prDbiOpenFlags(int dbflags,
unsigned int flags)
/*@modifies db @*/;
+/*@-globuse -mods -mustmod @*/
/** \ingroup dbi
* Open a database cursor.
* @param dbi index database handle
* @param txnid database transaction handle
* @retval dbcp returned database cursor
- * @param flags DBI_WRITECURSOR, DBI_ITERATOR or 0
+ * @param flags DB_WRITECURSOR if writing, or 0
* @return 0 on success
*/
/*@unused@*/ static inline
@@ -409,9 +414,6 @@ int dbiCopen(dbiIndex dbi, /*@null@*/ DB_TXN * txnid,
return (*dbi->dbi_vec->copen) (dbi, txnid, dbcp, flags);
}
-#define DBI_WRITECURSOR (1 << 0)
-#define DBI_ITERATOR (1 << 1)
-
/** \ingroup dbi
* Close a database cursor.
* @param dbi index database handle
@@ -432,11 +434,12 @@ int dbiCclose(dbiIndex dbi, /*@only@*/ DBC * dbcursor, unsigned int flags)
* @param dbi index database handle
* @param dbcursor database cursor (NULL will use db->del)
* @param key delete key value/length/flags
+ * @param data delete data value/length/flags
* @param flags (unused)
* @return 0 on success
*/
/*@unused@*/ static inline
-int dbiDel(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key,
+int dbiDel(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, fileSystem @*/
@@ -446,22 +449,23 @@ int dbiDel(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key,
int rc;
if (NULkey) key->size++;
- rc = (dbi->dbi_vec->cdel) (dbi, dbcursor, key, flags);
+ rc = (dbi->dbi_vec->cdel) (dbi, dbcursor, key, data, flags);
if (NULkey) key->size--;
return rc;
}
-
/** \ingroup dbi
* Retrieve (key,data) pair from index database.
* @param dbi index database handle
* @param dbcursor database cursor (NULL will use db->get)
* @param key retrieve key value/length/flags
* @param data retrieve data value/length/flags
+ * @param flags (unused)
* @return 0 on success
*/
/*@unused@*/ static inline
-int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
+int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, *key, *data, fileSystem @*/
{
@@ -470,7 +474,7 @@ int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
int rc;
if (NULkey) key->size++;
- rc = (dbi->dbi_vec->cget) (dbi, dbcursor, key, data);
+ rc = (dbi->dbi_vec->cget) (dbi, dbcursor, key, data, flags);
if (NULkey) key->size--;
return rc;
}
@@ -481,10 +485,12 @@ int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
* @param dbcursor database cursor (NULL will use db->put)
* @param key store key value/length/flags
* @param data store data value/length/flags
+ * @param flags (unused)
* @return 0 on success
*/
/*@unused@*/ static inline
-int dbiPut(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
+int dbiPut(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
+ unsigned int flags)
/*@globals fileSystem@*/
/*@modifies *dbcursor, *key, fileSystem @*/
{
@@ -493,7 +499,7 @@ int dbiPut(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data)
int rc;
if (NULkey) key->size++;
- rc = (dbi->dbi_vec->cput) (dbi, dbcursor, key, data);
+ rc = (dbi->dbi_vec->cput) (dbi, dbcursor, key, data, flags);
if (NULkey) key->size--;
return rc;
}
@@ -573,6 +579,7 @@ int dbiByteSwapped(dbiIndex dbi)
/*@=mods@*/
return dbi->dbi_byteswapped;
}
+/*@=globuse =mods =mustmod @*/
/** \ingroup db1
* Return base file name for db1 database (legacy).