*/
#include <assert.h>
-#include <rpmlib.h>
-#include <db.h>
+#include "rpmlib.h"
+#include "rpmsw.h"
+#include "db.h"
+
+/*@-exportlocal@*/
+/*@unchecked@*/
+extern int _rpmdb_debug;
+/*@=exportlocal@*/
#ifdef NOTYET
/** \ingroup rpmdb
int dbi_api; /*!< Berkeley API type */
int dbi_verify_on_close;
- int dbi_tear_down; /*!< tear down dbenv on close */
int dbi_use_dbenv; /*!< use db environment? */
int dbi_permit_dups; /*!< permit duplicate entries? */
int dbi_no_fsync; /*!< no-op fsync for db */
int dbi_region_init;
int dbi_tas_spins;
/* mpool sub-system parameters */
- int dbi_mp_mmapsize; /*!< (10Mb) */
- int dbi_mp_size; /*!< (128Kb) */
+ int dbi_mmapsize; /*!< (10Mb) */
+ int dbi_cachesize; /*!< (128Kb) */
/* lock sub-system parameters */
unsigned int dbi_lk_max;
unsigned int dbi_lk_detect;
/*@modifies fileSystem @*/;
#endif
/* dbinfo parameters */
- int dbi_cachesize; /*!< */
int dbi_pagesize; /*!< (fs blksize) */
/*@unused@*/ /*@null@*/
void * (*dbi_malloc) (size_t nbytes)
unsigned int dbi_q_extentsize;
/*@refcounted@*/
- rpmdb dbi_rpmdb;
+ rpmdb dbi_rpmdb; /*!< the parent rpm database */
rpmTag dbi_rpmtag; /*!< rpm tag used for index */
int dbi_jlen; /*!< size of join key */
/*@*/;
void (*db_free) (/*@only@*/ void * ptr)
/*@modifies *ptr @*/;
+/*@only@*/ /*@null@*/
+ unsigned char * db_bits; /*!< package instance bit mask. */
+ int db_nbits; /*!< no. of bits in mask. */
+ rpmdb db_next;
int db_opens;
/*@only@*/ /*@null@*/
- void * db_dbenv; /*!< Berkeley DB_ENV handle */
+ void * db_dbenv; /*!< Berkeley DB_ENV handle. */
int db_ndbi; /*!< No. of tag indices. */
- dbiIndex * _dbi; /*!< Tag indices. */
+ dbiIndex * _dbi; /*!< Tag indices. */
+
+ struct rpmop_s db_getops;
+ struct rpmop_s db_putops;
+ struct rpmop_s db_delops;
/*@refs@*/
int nrefs; /*!< Reference count. */
*/
/*@only@*/ /*@null@*/ dbiIndex dbiOpen(/*@null@*/ rpmdb db, rpmTag rpmtag,
unsigned int flags)
- /*@modifies db @*/;
+ /*@globals rpmGlobalMacroContext, errno @*/
+ /*@modifies db, rpmGlobalMacroContext, errno @*/;
/*@-globuse -mustmod @*/ /* FIX: vector annotations */
/** \ingroup dbi
/*@unused@*/ static inline
int dbiDel(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies *dbcursor, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies dbi, *dbcursor, fileSystem, internalState @*/
{
+ int rc;
assert(key->data != NULL && key->size > 0);
- return (dbi->dbi_vec->cdel) (dbi, dbcursor, key, data, flags);
+ (void) rpmswEnter(&dbi->dbi_rpmdb->db_delops, 0);
+ rc = (dbi->dbi_vec->cdel) (dbi, dbcursor, key, data, flags);
+ (void) rpmswExit(&dbi->dbi_rpmdb->db_delops, data->size);
+ return rc;
}
/** \ingroup dbi
/*@unused@*/ static inline
int dbiGet(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies *dbcursor, *key, *data, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies dbi, *dbcursor, *key, *data, fileSystem, internalState @*/
{
+ int rc;
assert((flags == DB_NEXT) || (key->data != NULL && key->size > 0));
- return (dbi->dbi_vec->cget) (dbi, dbcursor, key, data, flags);
+ (void) rpmswEnter(&dbi->dbi_rpmdb->db_getops, 0);
+ rc = (dbi->dbi_vec->cget) (dbi, dbcursor, key, data, flags);
+ (void) rpmswExit(&dbi->dbi_rpmdb->db_getops, data->size);
+ return rc;
}
/** \ingroup dbi
/*@unused@*/ static inline
int dbiPget(dbiIndex dbi, /*@null@*/ DBC * dbcursor,
DBT * key, DBT * pkey, DBT * data, unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies *dbcursor, *key, *pkey, *data, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies dbi, *dbcursor, *key, *pkey, *data, fileSystem, internalState @*/
{
+ int rc;
assert((flags == DB_NEXT) || (key->data != NULL && key->size > 0));
- return (dbi->dbi_vec->cpget) (dbi, dbcursor, key, pkey, data, flags);
+ (void) rpmswEnter(&dbi->dbi_rpmdb->db_getops, 0);
+ rc = (dbi->dbi_vec->cpget) (dbi, dbcursor, key, pkey, data, flags);
+ (void) rpmswExit(&dbi->dbi_rpmdb->db_getops, data->size);
+ return rc;
}
/** \ingroup dbi
/*@unused@*/ static inline
int dbiPut(dbiIndex dbi, /*@null@*/ DBC * dbcursor, DBT * key, DBT * data,
unsigned int flags)
- /*@globals fileSystem @*/
- /*@modifies *dbcursor, *key, fileSystem @*/
+ /*@globals fileSystem, internalState @*/
+ /*@modifies dbi, *dbcursor, *key, fileSystem, internalState @*/
{
+ int rc;
assert(key->data != NULL && key->size > 0 && data->data != NULL && data->size > 0);
- return (dbi->dbi_vec->cput) (dbi, dbcursor, key, data, flags);
+ (void) rpmswEnter(&dbi->dbi_rpmdb->db_putops, 0);
+ rc = (dbi->dbi_vec->cput) (dbi, dbcursor, key, data, flags);
+ (void) rpmswExit(&dbi->dbi_rpmdb->db_putops, data->size);
+ return rc;
}
/** \ingroup dbi
/** \ingroup dbi
* Is database byte swapped?
* @param dbi index database handle
- * @return 0 no
+ * @return 0 same order, 1 swapped order
*/
/*@unused@*/ static inline
int dbiByteSwapped(dbiIndex dbi)
dbi->dbi_byteswapped = (*dbi->dbi_vec->byteswapped) (dbi);
return dbi->dbi_byteswapped;
}
+/** \ingroup dbi
+ * Is database byte swapped?
+ * @param dbi index database handle
+ * @param flags DB_FAST_STAT or 0
+ * @return 0 on success
+ */
+/*@unused@*/ static inline
+int dbiStat(dbiIndex dbi, unsigned int flags)
+ /*@modifies dbi @*/
+{
+ return (*dbi->dbi_vec->stat) (dbi, flags);
+}
/*@=globuse =mustmod @*/
/*@=exportlocal@*/
*/
int rpmdbOpen (/*@null@*/ const char * prefix, /*@null@*/ /*@out@*/ rpmdb * dbp,
int mode, int perms)
- /*@globals fileSystem @*/
- /*@modifies *dbp, fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies *dbp, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Initialize database.
* @return 0 on success
*/
int rpmdbInit(/*@null@*/ const char * prefix, int perms)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Verify database components.
* @return 0 on success
*/
int rpmdbVerify(/*@null@*/ const char * prefix)
- /*@globals fileSystem @*/
- /*@modifies fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;
/**
* Close a single database index.
*/
/*@-exportlocal@*/
int rpmdbOpenAll (/*@null@*/ rpmdb db)
- /*@modifies db @*/;
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies db, rpmGlobalMacroContext @*/;
/*@=exportlocal@*/
/** \ingroup rpmdb
* @return number of instances
*/
int rpmdbCountPackages(/*@null@*/ rpmdb db, const char * name)
- /*@globals fileSystem @*/
- /*@modifies db, fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies db, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Return header join key for current position of rpm database iterator.
*/
int rpmdbSetIteratorRE(/*@null@*/ rpmdbMatchIterator mi, rpmTag tag,
rpmMireMode mode, /*@null@*/ const char * pattern)
- /*@modifies mi, mode @*/;
+ /*@globals rpmGlobalMacroContext @*/
+ /*@modifies mi, mode, rpmGlobalMacroContext @*/;
/** \ingroup rpmdb
* Prepare iterator for lazy writes.
/*@modifies mi @*/;
/** \ingroup rpmdb
+ * Modify iterator to verify retrieved header blobs.
+ * @param mi rpm database iterator
+ * @param ts transaction set
+ * @param (*hdrchk) headerCheck() vector
+ * @return 0 always
+ */
+int rpmdbSetHdrChk(/*@null@*/ rpmdbMatchIterator mi, /*@null@*/ rpmts ts,
+ /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void * uh, size_t uc, const char ** msg))
+ /*@modifies mi @*/;
+
+/** \ingroup rpmdb
* Return database iterator.
* @param db rpm database
* @param rpmtag rpm tag
/*@only@*/ /*@null@*/
rpmdbMatchIterator rpmdbInitIterator(/*@null@*/ rpmdb db, rpmTag rpmtag,
/*@null@*/ const void * keyp, size_t keylen)
- /*@globals fileSystem @*/
- /*@modifies db, fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies db, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Return next package header from iteration.
*/
/*@null@*/
Header rpmdbNextIterator(/*@null@*/ rpmdbMatchIterator mi)
- /*@globals fileSystem @*/
- /*@modifies mi, fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
+
+/** \ingroup rpmdb
+ * Check rpmdb signal handler for trapped signal exit.
+ */
+/*@mayexit@*/
+int rpmdbCheckSignals(void)
+ /*@globals fileSystem, internalState @*/
+ /*@modifies fileSystem, internalState @*/;
/** \ingroup rpmdb
* Destroy rpm database iterator.
*/
/*@null@*/
rpmdbMatchIterator rpmdbFreeIterator(/*@only@*/ /*@null@*/rpmdbMatchIterator mi)
- /*@globals fileSystem @*/
- /*@modifies mi, fileSystem @*/;
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies mi, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Add package header to rpm database and indices.
* @param db rpm database
* @param iid install transaction id (iid = 0 or -1 to skip)
* @param h header
+ * @param ts (unused) transaction set (or NULL)
+ * @param (*hdrchk) (unused) headerCheck() vector (or NULL)
* @return 0 on success
*/
-int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h)
- /*@globals fileSystem @*/
- /*@modifies db, h, fileSystem @*/;
+int rpmdbAdd(/*@null@*/ rpmdb db, int iid, Header h, /*@null@*/ rpmts ts,
+ /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, const char ** msg))
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies db, h, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Remove package header from rpm database and indices.
* @param db rpm database
- * @param rid remove transaction id (rid = 0 or -1 to skip)
+ * @param rid (unused) remove transaction id (rid = 0 or -1 to skip)
* @param hdrNum package instance number in database
+ * @param ts (unused) transaction set (or NULL)
+ * @param (*hdrchk) (unused) headerCheck() vector (or NULL)
* @return 0 on success
*/
-int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum)
- /*@globals fileSystem @*/
- /*@modifies db, fileSystem @*/;
+int rpmdbRemove(/*@null@*/ rpmdb db, /*@unused@*/ int rid, unsigned int hdrNum,
+ /*@null@*/ rpmts ts,
+ /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, const char ** msg))
+ /*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
+ /*@modifies db, rpmGlobalMacroContext, fileSystem, internalState @*/;
/** \ingroup rpmdb
* Rebuild database indices from package headers.
* @param prefix path to top of install tree
+ * @param ts transaction set (or NULL)
+ * @param (*hdrchk) headerCheck() vector (or NULL)
* @return 0 on success
*/
-int rpmdbRebuild(/*@null@*/ const char * prefix)
+int rpmdbRebuild(/*@null@*/ const char * prefix, /*@null@*/ rpmts ts,
+ /*@null@*/ rpmRC (*hdrchk) (rpmts ts, const void *uh, size_t uc, const char ** msg))
/*@globals rpmGlobalMacroContext, fileSystem, internalState @*/
/*@modifies rpmGlobalMacroContext, fileSystem, internalState @*/;