diff options
-rw-r--r-- | lib/Makefile.am | 2 | ||||
-rw-r--r-- | lib/backend/db3.c | 6 | ||||
-rw-r--r-- | lib/backend/dbi.h | 202 | ||||
-rw-r--r-- | lib/rpmdb.c | 12 | ||||
-rw-r--r-- | lib/rpmdb_internal.h | 186 |
5 files changed, 210 insertions, 198 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am index 3284fa462..eee51f1e5 100644 --- a/lib/Makefile.am +++ b/lib/Makefile.am @@ -19,7 +19,7 @@ EXTRA_PROGRAMS = usrlibdir = $(libdir) usrlib_LTLIBRARIES = librpm.la librpm_la_SOURCES = \ - backend/dbconfig.c backend/db3.c \ + backend/dbconfig.c backend/db3.c backend/dbi.h \ headerutil.c header.c headerfmt.c header_internal.h \ poptDB.c rpmhash.c rpmhash.h rpmdb.c rpmdb_internal.h \ fprint.c fprint.h tagname.c rpmtd.c \ diff --git a/lib/backend/db3.c b/lib/backend/db3.c index 6f8f67458..b886868a7 100644 --- a/lib/backend/db3.c +++ b/lib/backend/db3.c @@ -374,6 +374,12 @@ int dbiStat(dbiIndex dbi, unsigned int flags) return rc; } +int dbiVerify(dbiIndex dbi, unsigned int flags) +{ + dbi->dbi_verify_on_close = 1; + return dbiClose(dbi, flags); +} + int dbiClose(dbiIndex dbi, unsigned int flags) { rpmdb rpmdb = dbi->dbi_rpmdb; diff --git a/lib/backend/dbi.h b/lib/backend/dbi.h new file mode 100644 index 000000000..d1dcb9ea0 --- /dev/null +++ b/lib/backend/dbi.h @@ -0,0 +1,202 @@ +#ifndef _DBI_H +#define _DBI_H + +typedef struct _dbiIndex * dbiIndex; + +/** \ingroup dbi + * Describes an index database (implemented on Berkeley db functionality). + */ +struct _dbiIndex { + const char * dbi_file; /*!< file component of path */ + + int dbi_ecflags; /*!< db_env_create flags */ + int dbi_cflags; /*!< db_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 */ + unsigned dbi_mode; /*!< mode to use on open */ + int dbi_perms; /*!< file permission to use on open */ + + int dbi_verify_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_no_dbsync; /*!< don't call dbiSync */ + int dbi_lockdbfd; /*!< do fcntl lock on db fd */ + int dbi_byteswapped; + + /* dbenv parameters */ + /* XXX db-4.3.14 adds dbenv as 1st arg. */ + int dbi_verbose; + /* mpool sub-system parameters */ + int dbi_mmapsize; /*!< (10Mb) */ + int dbi_cachesize; /*!< (128Kb) */ + /* dbinfo parameters */ + int dbi_pagesize; /*!< (fs blksize) */ + + rpmdb dbi_rpmdb; /*!< the parent rpm database */ + rpmTag dbi_rpmtag; /*!< rpm tag used for index */ + int dbi_jlen; /*!< size of join key */ + + DB * dbi_db; /*!< Berkeley DB * handle */ + DB_TXN * dbi_txnid; /*!< Bekerley DB_TXN * transaction id */ + void * dbi_stats; /*!< Berkeley db statistics */ +}; + +/** \ingroup dbi + * Return new configured index database handle instance. + * @param rpmdb rpm database + * @param rpmtag rpm tag + * @return index database handle + */ +RPM_GNUC_INTERNAL +dbiIndex dbiNew(rpmdb rpmdb, rpmTag rpmtag); + +/** \ingroup dbi + * Destroy index database handle instance. + * @param dbi index database handle + * @return NULL always + */ +RPM_GNUC_INTERNAL +dbiIndex dbiFree( dbiIndex dbi); + +/** \ingroup dbi + * Format dbi open flags for debugging print. + * @param dbflags db open flags + * @param print_dbenv_flags format db env flags instead? + * @return formatted flags (malloced) + */ +RPM_GNUC_INTERNAL +char * prDbiOpenFlags(int dbflags, int print_dbenv_flags); + +/** \ingroup dbi + * Actually open the database of the index. + * @param db rpm database + * @param rpmtag rpm tag + * @param dbiIndex address of index database handle + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiOpenDB(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip); + + +/* FIX: vector annotations */ +/** \ingroup dbi + * Open a database cursor. + * @param dbi index database handle + * @retval dbcp returned database cursor + * @param flags DB_WRITECURSOR if writing, or 0 + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCopen(dbiIndex dbi, DBC ** dbcp, unsigned int flags); + +/** \ingroup dbi + * Close a database cursor. + * @param dbi index database handle + * @param dbcursor database cursor + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCclose(dbiIndex dbi, DBC * dbcursor, unsigned int flags); + +/** \ingroup dbi + * Delete (key,data) pair(s) from index database. + * @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 + */ +RPM_GNUC_INTERNAL +int dbiDel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \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 + */ +RPM_GNUC_INTERNAL +int dbiGet(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \ingroup dbi + * Store (key,data) pair in index database. + * @param dbi index database handle + * @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 + */ +RPM_GNUC_INTERNAL +int dbiPut(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, + unsigned int flags); + +/** \ingroup dbi + * Retrieve count of (possible) duplicate items. + * @param dbi index database handle + * @param dbcursor database cursor + * @param countp address of count + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiCount(dbiIndex dbi, DBC * dbcursor, unsigned int * countp, + unsigned int flags); + +/** \ingroup dbi + * Close index database. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiClose(dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Flush pending operations to disk. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiSync (dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Verify (and close) index database. + * @param dbi index database handle + * @param flags (unused) + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiVerify(dbiIndex dbi, unsigned int flags); + +/** \ingroup dbi + * Is database byte swapped? + * @param dbi index database handle + * @return 0 same order, 1 swapped order + */ +RPM_GNUC_INTERNAL +int dbiByteSwapped(dbiIndex dbi); + +/** \ingroup dbi + * Is database byte swapped? + * @param dbi index database handle + * @param flags DB_FAST_STAT or 0 + * @return 0 on success + */ +RPM_GNUC_INTERNAL +int dbiStat(dbiIndex dbi, unsigned int flags); + +#endif /* _DBI_H */ diff --git a/lib/rpmdb.c b/lib/rpmdb.c index 057bda1f9..642ef2eb7 100644 --- a/lib/rpmdb.c +++ b/lib/rpmdb.c @@ -115,18 +115,6 @@ static inline pbm_set * PBM_REALLOC(pbm_set ** sp, int * odp, int nd) } /** \ingroup dbi - * Verify (and close) index database. - * @param dbi index database handle - * @param flags (unused) - * @return 0 on success - */ -static int dbiVerify(dbiIndex dbi, unsigned int flags) -{ - dbi->dbi_verify_on_close = 1; - return dbiClose(dbi, flags); -} - -/** \ingroup dbi * Return handle for an index database. * @param db rpm database * @param rpmtag rpm tag diff --git a/lib/rpmdb_internal.h b/lib/rpmdb_internal.h index 7c0d6e0a3..7625a4d51 100644 --- a/lib/rpmdb_internal.h +++ b/lib/rpmdb_internal.h @@ -7,51 +7,7 @@ #include <rpm/rpmsw.h> #include <rpm/rpmtypes.h> #include <rpm/rpmutil.h> - -typedef struct _dbiIndex * dbiIndex; - -/** \ingroup dbi - * Describes an index database (implemented on Berkeley db functionality). - */ -struct _dbiIndex { - const char * dbi_file; /*!< file component of path */ - - int dbi_ecflags; /*!< db_env_create flags */ - int dbi_cflags; /*!< db_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 */ - unsigned dbi_mode; /*!< mode to use on open */ - int dbi_perms; /*!< file permission to use on open */ - - int dbi_verify_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_no_dbsync; /*!< don't call dbiSync */ - int dbi_lockdbfd; /*!< do fcntl lock on db fd */ - int dbi_byteswapped; - - /* dbenv parameters */ - /* XXX db-4.3.14 adds dbenv as 1st arg. */ - int dbi_verbose; - /* mpool sub-system parameters */ - int dbi_mmapsize; /*!< (10Mb) */ - int dbi_cachesize; /*!< (128Kb) */ - /* dbinfo parameters */ - int dbi_pagesize; /*!< (fs blksize) */ - - rpmdb dbi_rpmdb; /*!< the parent rpm database */ - rpmTag dbi_rpmtag; /*!< rpm tag used for index */ - int dbi_jlen; /*!< size of join key */ - - DB * dbi_db; /*!< Berkeley DB * handle */ - DB_TXN * dbi_txnid; /*!< Bekerley DB_TXN * transaction id */ - void * dbi_stats; /*!< Berkeley db statistics */ -}; +#include "lib/backend/dbi.h" /** \ingroup rpmdb * Describes the collection of index databases used by rpm. @@ -96,146 +52,6 @@ enum rpmdbFlags { extern "C" { #endif -/** \ingroup dbi - * Return new configured index database handle instance. - * @param rpmdb rpm database - * @param rpmtag rpm tag - * @return index database handle - */ -RPM_GNUC_INTERNAL -dbiIndex dbiNew(rpmdb rpmdb, rpmTag rpmtag); - -/** \ingroup dbi - * Destroy index database handle instance. - * @param dbi index database handle - * @return NULL always - */ -RPM_GNUC_INTERNAL -dbiIndex dbiFree( dbiIndex dbi); - -/** \ingroup dbi - * Format dbi open flags for debugging print. - * @param dbflags db open flags - * @param print_dbenv_flags format db env flags instead? - * @return formatted flags (malloced) - */ -RPM_GNUC_INTERNAL -char * prDbiOpenFlags(int dbflags, int print_dbenv_flags); - -/** \ingroup dbi - * Actually open the database of the index. - * @param db rpm database - * @param rpmtag rpm tag - * @param dbiIndex address of index database handle - * @return 0 on success - */ -RPM_GNUC_INTERNAL -int dbiOpenDB(rpmdb rpmdb, rpmTag rpmtag, dbiIndex * dbip); - - -/* FIX: vector annotations */ -/** \ingroup dbi - * Open a database cursor. - * @param dbi index database handle - * @retval dbcp returned database cursor - * @param flags DB_WRITECURSOR if writing, or 0 - * @return 0 on success - */ -RPM_GNUC_INTERNAL -int dbiCopen(dbiIndex dbi, DBC ** dbcp, unsigned int flags); - -/** \ingroup dbi - * Close a database cursor. - * @param dbi index database handle - * @param dbcursor database cursor - * @param flags (unused) - * @return 0 on success - */ -RPM_GNUC_INTERNAL -int dbiCclose(dbiIndex dbi, DBC * dbcursor, unsigned int flags); - -/** \ingroup dbi - * Delete (key,data) pair(s) from index database. - * @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 - */ -RPM_GNUC_INTERNAL -int dbiDel(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, - unsigned int flags); - -/** \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 - */ -RPM_GNUC_INTERNAL -int dbiGet(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, - unsigned int flags); - -/** \ingroup dbi - * Store (key,data) pair in index database. - * @param dbi index database handle - * @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 - */ -RPM_GNUC_INTERNAL -int dbiPut(dbiIndex dbi, DBC * dbcursor, DBT * key, DBT * data, - unsigned int flags); - -/** \ingroup dbi - * Retrieve count of (possible) duplicate items. - * @param dbi index database handle - * @param dbcursor database cursor - * @param countp address of count - * @param flags (unused) - * @return 0 on success - */ -int dbiCount(dbiIndex dbi, DBC * dbcursor, unsigned int * countp, - unsigned int flags); - -/** \ingroup dbi - * Close index database. - * @param dbi index database handle - * @param flags (unused) - * @return 0 on success - */ -int dbiClose(dbiIndex dbi, unsigned int flags); - -/** \ingroup dbi - * Flush pending operations to disk. - * @param dbi index database handle - * @param flags (unused) - * @return 0 on success - */ -int dbiSync (dbiIndex dbi, unsigned int flags); - - -/** \ingroup dbi - * Is database byte swapped? - * @param dbi index database handle - * @return 0 same order, 1 swapped order - */ -int dbiByteSwapped(dbiIndex dbi); - -/** \ingroup dbi - * Is database byte swapped? - * @param dbi index database handle - * @param flags DB_FAST_STAT or 0 - * @return 0 on success - */ -int dbiStat(dbiIndex dbi, unsigned int flags); - /** \ingroup rpmdb * Return rpmdb home directory (depending on chroot state) * param db rpmdb handle |