rpmdb/rpmdb.c File Reference

#include "system.h"
#include <sys/file.h>
#include <rpmio.h>
#include <rpmpgp.h>
#include <rpmurl.h>
#include <rpmmacro.h>
#include <rpmsq.h>
#include <rpmevr.h>
#include "rpmdb.h"
#include "fprint.h"
#include "legacy.h"
#include "header_internal.h"
#include "debug.h"

Include dependency graph for rpmdb.c:

Go to the source code of this file.

Data Structures

struct  pbm_set
union  _dbswap
struct  _rpmdbMatchIterator

Defines

#define _USE_COPY_LOAD
#define _RPMEVR_INTERNAL
#define _RPMDB_INTERNAL
#define _MIRE_INTERNAL
#define _DB_TAGGED_FILE_INDICES   1
#define _DBI_FLAGS   0
#define _DBI_PERMS   0644
#define _DBI_MAJOR   -1
#define __PBM_NBITS   (8 * sizeof (__pbm_bits))
#define __PBM_IX(d)   ((d) / __PBM_NBITS)
#define __PBM_MASK(d)   ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))
#define __PBM_BITS(set)   ((set)->bits)
#define PBM_FREE(s)   _free(s);
#define PBM_SET(d, s)   (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))
#define PBM_CLR(d, s)   (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))
#define PBM_ISSET(d, s)   ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)
#define PBM_ALLOC(d)   xcalloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))
#define DB1vec   NULL
#define DB2vec   NULL
#define DB3vec   NULL
#define SQLITEvec   NULL
#define _DBSWAP(_a)
#define _DB_ROOT   "/"
#define _DB_HOME   "%{?_dbpath}"
#define _DB_FLAGS   0
#define _DB_MODE   0
#define _DB_PERMS   0644
#define _DB_MAJOR   -1
#define _DB_ERRPFX   "rpmdb"
#define _VARLIBRPM   "/var/lib/rpm"
#define _RECNUM   rpmdbGetIteratorOffset(mi)

Typedefs

typedef unsigned int __pbm_bits

Functions

static pbm_setPBM_REALLOC (pbm_set **sp, int *odp, int nd)
 Reallocate a bit map.
static unsigned char nibble (char c)
 Convert hex to binary nibble.
static int dbiTagToDbix (rpmdb db, int rpmtag)
 Return dbi index used for rpm tag.
static void dbiTagsInit (int **dbiTagsP, int *dbiTagsMaxP)
 Initialize database (index, tag) tuple from configuration.
dbiIndex dbiOpen (rpmdb db, rpmTag rpmtag, unsigned int flags)
static dbiIndexItem dbiIndexNewItem (unsigned int hdrNum, unsigned int tagNum)
 Create and initialize item for index database set.
static int dbt2set (dbiIndex dbi, DBT *data, dbiIndexSet *setp)
 Convert retrieved data to index set.
static int set2dbt (dbiIndex dbi, DBT *data, dbiIndexSet set)
 Convert index set to database representation.
static int hdrNumCmp (const void *one, const void *two)
static int dbiAppendSet (dbiIndexSet set, const void *recs, int nrecs, size_t recsize, int sortset)
 Append element(s) to set of index database items.
static int dbiPruneSet (dbiIndexSet set, void *recs, int nrecs, size_t recsize, int sorted)
 Remove element(s) from set of index database items.
unsigned int dbiIndexSetCount (dbiIndexSet set)
unsigned int dbiIndexRecordOffset (dbiIndexSet set, int recno)
unsigned int dbiIndexRecordFileNumber (dbiIndexSet set, int recno)
dbiIndexSet dbiFreeIndexSet (dbiIndexSet set)
int rpmdbCheckSignals (void)
 Check rpmdb signal handler for trapped signal exit.
static int blockSignals (rpmdb db, sigset_t *oldMask)
 Block all signals, returning previous signal mask.
static int unblockSignals (rpmdb db, sigset_t *oldMask)
 Restore signal mask.
static const char * queryHeader (Header h, const char *qfmt)
 Return header query string.
static int rpmdbExportInfo (rpmdb db, Header h, int adding)
 Write added/removed header info.
int rpmdbOpenAll (rpmdb db)
 Open all database indices.
int rpmdbBlockDBI (rpmdb db, int rpmtag)
 Block access to a single database index.
int rpmdbCloseDBI (rpmdb db, int rpmtag)
 Close a single database index.
int rpmdbClose (rpmdb db)
 Close all database indices and free rpmdb.
int rpmdbSync (rpmdb db)
 Sync all database indices.
static const char * rpmdbURIPath (const char *uri)
 Return macro expanded absolute path to rpmdb.
rpmdb rpmdbNew (const char *root, const char *home, int mode, int perms, int flags)
int rpmdbOpenDatabase (const char *prefix, const char *dbpath, int _dbapi, rpmdb *dbp, int mode, int perms, int flags)
rpmdb XrpmdbUnlink (rpmdb db, const char *msg, const char *fn, unsigned ln)
rpmdb XrpmdbLink (rpmdb db, const char *msg, const char *fn, unsigned ln)
int rpmdbOpen (const char *prefix, rpmdb *dbp, int mode, int perms)
 Open rpm database.
int rpmdbInit (const char *prefix, int perms)
 Initialize database.
int rpmdbVerifyAllDBI (rpmdb db)
 Verify all database components.
int rpmdbVerify (const char *prefix)
 Open and verify all database components.
static unsigned taghash (const char *s)
 Return a tagnum with hash on the (directory) path in upper 16 bits.
static int rpmdbFindByFile (rpmdb db, const char *filespec, DBT *key, DBT *data, dbiIndexSet *matches)
 Find file matches in database.
int rpmdbCountPackages (rpmdb db, const char *name)
 Return number of instances of package in rpm database.
static rpmRC dbiFindMatches (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, const char *name, const char *version, const char *release, dbiIndexSet *matches)
 Attempt partial matches on name[-version[-release]] strings.
static rpmRC dbiFindByLabel (dbiIndex dbi, DBC *dbcursor, DBT *key, DBT *data, const char *arg, dbiIndexSet *matches)
 Lookup by name, name-version, and finally by name-version-release.
void * dbiStatsAccumulator (dbiIndex dbi, int opx)
static int miFreeHeader (rpmdbMatchIterator mi, dbiIndex dbi)
 Rewrite a header into packages (if necessary) and free the header.
rpmdbMatchIterator rpmdbFreeIterator (rpmdbMatchIterator mi)
 Destroy rpm database iterator.
unsigned int rpmdbGetIteratorOffset (rpmdbMatchIterator mi)
 Return header join key for current position of rpm database iterator.
unsigned int rpmdbGetIteratorFileNum (rpmdbMatchIterator mi)
int rpmdbGetIteratorCount (rpmdbMatchIterator mi)
 Return number of elements in rpm database iterator.
static int mireCmp (const void *a, const void *b)
 Compare iterator selectors by rpm tag (qsort/bsearch).
static char * mireDup (rpmTag tag, rpmMireMode *modep, const char *pattern)
 Copy pattern, escaping for appropriate mode.
int rpmdbSetIteratorRE (rpmdbMatchIterator mi, rpmTag tag, rpmMireMode mode, const char *pattern)
 Add pattern to iterator selector.
static int mireSkip (const rpmdbMatchIterator mi)
 Return iterator selector match.
int rpmdbSetIteratorRewrite (rpmdbMatchIterator mi, int rewrite)
 Prepare iterator for lazy writes.
int rpmdbSetIteratorModified (rpmdbMatchIterator mi, int modified)
 Modify iterator to mark header for lazy write on release.
int rpmdbSetHdrChk (rpmdbMatchIterator mi, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, const char **msg))
 Modify iterator to verify retrieved header blobs.
Header rpmdbNextIterator (rpmdbMatchIterator mi)
 Return next package header from iteration.
static void rpmdbSortIterator (rpmdbMatchIterator mi)
static int rpmdbGrowIterator (rpmdbMatchIterator mi, int fpNum, unsigned int exclude, unsigned int tag)
int rpmdbPruneIterator (rpmdbMatchIterator mi, int *hdrNums, int nHdrNums, int sorted)
 Remove items from set of package instances to iterate.
int rpmdbAppendIterator (rpmdbMatchIterator mi, const int *hdrNums, int nHdrNums)
 Append items to set of package instances to iterate.
rpmdbMatchIterator rpmdbInitIterator (rpmdb db, rpmTag rpmtag, const void *keyp, size_t keylen)
 Return database iterator.
int rpmdbRemove (rpmdb db, int rid, unsigned int hdrNum, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, const char **msg))
 Remove package header from rpm database and indices.
int rpmdbAdd (rpmdb db, int iid, Header h, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, const char **msg))
 Add package header to rpm database and indices.
int rpmdbFindFpList (rpmdb db, fingerPrint *fpList, dbiIndexSet *matchList, int numItems, unsigned int exclude)
 Find fingerprint matches in database.
static int rpmioFileExists (const char *urlfn)
 Check if file esists using stat(2).
static int rpmdbRemoveDatabase (const char *prefix, const char *dbpath, int _dbapi, const int *dbiTags, int dbiTagsMax)
static int rpmdbMoveDatabase (const char *prefix, const char *olddbpath, int _olddbapi, const char *newdbpath, int _newdbapi, const int *dbiTags, int dbiTagsMax)
int rpmdbRebuild (const char *prefix, rpmts ts, rpmRC(*hdrchk)(rpmts ts, const void *uh, size_t uc, const char **msg))
 Rebuild database indices from package headers.

Variables

int _rpmdb_debug = 0
int _rsegfault = 0
int _wsegfault = 0
static int _rebuildinprogress = 0
static int _db_filter_dups = 0
static int _db_tagged_file_indices = 1
static struct _dbiVec * mydbvecs []
static rpmdb rpmdbRock
static rpmdbMatchIterator rpmmiRock
static struct rpmdb_s dbTemplate


Detailed Description

Definition in file rpmdb.c.


Define Documentation

#define __PBM_BITS ( set   )     ((set)->bits)

Definition at line 71 of file rpmdb.c.

Referenced by PBM_REALLOC().

#define __PBM_IX (  )     ((d) / __PBM_NBITS)

Definition at line 64 of file rpmdb.c.

Referenced by PBM_REALLOC().

#define __PBM_MASK (  )     ((__pbm_bits) 1 << (((unsigned)(d)) % __PBM_NBITS))

Definition at line 65 of file rpmdb.c.

#define __PBM_NBITS   (8 * sizeof (__pbm_bits))

Definition at line 63 of file rpmdb.c.

#define _DB_ERRPFX   "rpmdb"

Definition at line 851 of file rpmdb.c.

Referenced by rpmdbNew().

#define _DB_FLAGS   0

Definition at line 846 of file rpmdb.c.

#define _DB_HOME   "%{?_dbpath}"

Definition at line 845 of file rpmdb.c.

Referenced by rpmdbNew().

#define _DB_MAJOR   -1

Definition at line 850 of file rpmdb.c.

#define _DB_MODE   0

Definition at line 847 of file rpmdb.c.

#define _DB_PERMS   0644

Definition at line 848 of file rpmdb.c.

#define _DB_ROOT   "/"

Definition at line 844 of file rpmdb.c.

Referenced by rpmdbNew().

#define _DB_TAGGED_FILE_INDICES   1

Definition at line 51 of file rpmdb.c.

#define _DBI_FLAGS   0

Definition at line 55 of file rpmdb.c.

#define _DBI_MAJOR   -1

Definition at line 57 of file rpmdb.c.

#define _DBI_PERMS   0644

Definition at line 56 of file rpmdb.c.

#define _DBSWAP ( _a   ) 

Value:

/*@-bounds@*/ \
  { unsigned char _b, *_c = (_a).uc; \
    _b = _c[3]; _c[3] = _c[0]; _c[0] = _b; \
    _b = _c[2]; _c[2] = _c[1]; _c[1] = _b; \
/*@=bounds@*/ \
  }

Definition at line 396 of file rpmdb.c.

Referenced by dbt2set(), rpmdbAdd(), rpmdbInitIterator(), rpmdbNextIterator(), rpmdbRemove(), and set2dbt().

#define _MIRE_INTERNAL

Definition at line 21 of file rpmdb.c.

#define _RECNUM   rpmdbGetIteratorOffset(mi)

Referenced by rpmdbRebuild().

#define _RPMDB_INTERNAL

Definition at line 20 of file rpmdb.c.

#define _RPMEVR_INTERNAL

Definition at line 17 of file rpmdb.c.

#define _USE_COPY_LOAD

Definition at line 7 of file rpmdb.c.

Referenced by rpmdbNextIterator().

#define _VARLIBRPM   "/var/lib/rpm"

Referenced by rpmdbNew().

#define DB1vec   NULL

Definition at line 242 of file rpmdb.c.

#define DB2vec   NULL

Definition at line 243 of file rpmdb.c.

#define DB3vec   NULL

Definition at line 253 of file rpmdb.c.

#define PBM_ALLOC (  )     xcalloc(__PBM_IX (d) + 1, sizeof(__pbm_bits))

Definition at line 78 of file rpmdb.c.

Referenced by dbiOpen().

#define PBM_CLR ( d,
 )     (__PBM_BITS (s)[__PBM_IX (d)] &= ~__PBM_MASK (d))

Definition at line 75 of file rpmdb.c.

#define PBM_FREE (  )     _free(s);

Definition at line 73 of file rpmdb.c.

Referenced by rpmdbClose().

#define PBM_ISSET ( d,
 )     ((__PBM_BITS (s)[__PBM_IX (d)] & __PBM_MASK (d)) != 0)

Definition at line 76 of file rpmdb.c.

Referenced by rpmdbNextIterator().

#define PBM_SET ( d,
 )     (__PBM_BITS (s)[__PBM_IX (d)] |= __PBM_MASK (d))

Definition at line 74 of file rpmdb.c.

Referenced by rpmdbNextIterator().

#define SQLITEvec   NULL

Definition at line 265 of file rpmdb.c.


Typedef Documentation

typedef unsigned int __pbm_bits

Definition at line 61 of file rpmdb.c.


Function Documentation

static int blockSignals ( rpmdb  db,
sigset_t *  oldMask 
) [static]

Block all signals, returning previous signal mask.

Parameters:
db rpm database
Return values:
*oldMask previous sigset
Returns:
0 on success

Definition at line 739 of file rpmdb.c.

Referenced by miFreeHeader(), rpmdbAdd(), and rpmdbRemove().

static int dbiAppendSet ( dbiIndexSet  set,
const void *  recs,
int  nrecs,
size_t  recsize,
int  sortset 
) [static]

Append element(s) to set of index database items.

Parameters:
set set of index database items
recs array of items to append to set
nrecs number of items
recsize size of an array item
sortset should resulting set be sorted?
Returns:
0 success, 1 failure (bad args)

Definition at line 558 of file rpmdb.c.

References hdrNumCmp(), and xrealloc().

Referenced by rpmdbAdd(), rpmdbAppendIterator(), rpmdbFindByFile(), and rpmdbFindFpList().

static rpmRC dbiFindByLabel ( dbiIndex  dbi,
DBC *  dbcursor,
DBT *  key,
DBT *  data,
const char *  arg,
dbiIndexSet matches 
) [static]

Lookup by name, name-version, and finally by name-version-release.

Both version and release can be patterns.

Todo:
Name must be an exact match, as name is a db key.
Parameters:
dbi index database handle (always RPMTAG_NAME)
dbcursor index database cursor
key search key/length/flags
data search data/length/flags
arg name[-version[-release]] string
Return values:
matches set of header instances that match
Returns:
RPMRC_OK on match, RPMRC_NOMATCH or RPMRC_FAIL

Definition at line 1686 of file rpmdb.c.

References alloca(), dbiFindMatches(), dbiFreeIndexSet(), RPMRC_NOTFOUND, and stpcpy().

Referenced by rpmdbInitIterator().

static rpmRC dbiFindMatches ( dbiIndex  dbi,
DBC *  dbcursor,
DBT *  key,
DBT *  data,
const char *  name,
const char *  version,
const char *  release,
dbiIndexSet matches 
) [static]

Attempt partial matches on name[-version[-release]] strings.

Parameters:
dbi index database handle (always RPMTAG_NAME)
dbcursor index database cursor
key search key/length/flags
data search data/length/flags
name package name
version package version (can be a pattern)
release package release (can be a pattern)
Return values:
matches set of header instances that match
Returns:
RPMRC_OK on match, RPMRC_NOMATCH or RPMRC_FAIL

Definition at line 1586 of file rpmdb.c.

References _, dbiFreeIndexSet(), dbiIndexRecordOffset(), dbiIndexSetCount(), dbt2set(), rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), rpmdbSetIteratorRE(), RPMERR_DBGETINDEX, rpmError, RPMRC_FAIL, RPMRC_NOTFOUND, RPMRC_OK, RPMTAG_RELEASE, RPMTAG_VERSION, and tagName().

Referenced by dbiFindByLabel().

dbiIndexSet dbiFreeIndexSet ( dbiIndexSet  set  ) 

Definition at line 639 of file rpmdb.c.

References _free().

Referenced by dbiFindByLabel(), dbiFindMatches(), rpmdbAdd(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbFreeIterator(), rpmdbInitIterator(), rpmdbRemove(), and rpmtsRun().

static dbiIndexItem dbiIndexNewItem ( unsigned int  hdrNum,
unsigned int  tagNum 
) [static]

Create and initialize item for index database set.

Parameters:
hdrNum header instance in db
tagNum tag index in header
Returns:
new item

Definition at line 382 of file rpmdb.c.

References xcalloc().

Referenced by rpmdbAdd(), rpmdbFindByFile(), and rpmdbRemove().

unsigned int dbiIndexRecordFileNumber ( dbiIndexSet  set,
int  recno 
)

Definition at line 634 of file rpmdb.c.

Referenced by rpmdbFindByFile(), rpmdbNextIterator(), and rpmtsRun().

unsigned int dbiIndexRecordOffset ( dbiIndexSet  set,
int  recno 
)

Definition at line 629 of file rpmdb.c.

Referenced by dbiFindMatches(), rpmdbFindByFile(), rpmdbNextIterator(), and rpmtsRun().

unsigned int dbiIndexSetCount ( dbiIndexSet  set  ) 

Definition at line 624 of file rpmdb.c.

Referenced by dbiFindMatches(), rpmdbCountPackages(), and rpmtsRun().

dbiIndex dbiOpen ( rpmdb  db,
rpmTag  rpmtag,
unsigned int  flags 
)

Definition at line 275 of file rpmdb.c.

References _, _rebuildinprogress, _rpmdb_debug, db3Free(), dbiTagToDbix(), errno, PBM_ALLOC, RPMDBI_PACKAGES, RPMERR_DBOPEN, rpmError, rpmExpandNumeric(), RPMMESS_DEBUG, rpmMessage, strerror, and tagName().

Referenced by rpmdbAdd(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbFreeIterator(), rpmdbGrowIterator(), rpmdbInitIterator(), rpmdbNextIterator(), rpmdbOpenAll(), rpmdbOpenDatabase(), rpmdbRemove(), rpmpsmStage(), and unsatisfiedDepend().

static int dbiPruneSet ( dbiIndexSet  set,
void *  recs,
int  nrecs,
size_t  recsize,
int  sorted 
) [static]

Remove element(s) from set of index database items.

Parameters:
set set of index database items
recs array of items to remove from set
nrecs number of items
recsize size of an array item
sorted array is already sorted?
Returns:
0 success, 1 failure (no items found)

Definition at line 597 of file rpmdb.c.

References hdrNumCmp().

Referenced by rpmdbPruneIterator(), and rpmdbRemove().

void* dbiStatsAccumulator ( dbiIndex  dbi,
int  opx 
)

Definition at line 1774 of file rpmdb.c.

static void dbiTagsInit ( int **  dbiTagsP,
int *  dbiTagsMaxP 
) [static]

Initialize database (index, tag) tuple from configuration.

Definition at line 169 of file rpmdb.c.

References _, _free(), RPMDBI_PACKAGES, rpmExpand(), RPMMESS_WARNING, rpmMessage, tagValue(), xcalloc(), xisspace(), xrealloc(), and xstrdup().

Referenced by rpmdbNew(), and rpmdbRebuild().

static int dbiTagToDbix ( rpmdb  db,
int  rpmtag 
) [static]

Return dbi index used for rpm tag.

Parameters:
db rpm database
rpmtag rpm header tag
Returns:
dbi index, -1 on error

Definition at line 149 of file rpmdb.c.

Referenced by dbiOpen().

static int dbt2set ( dbiIndex  dbi,
DBT *  data,
dbiIndexSet setp 
) [static]

Convert retrieved data to index set.

Parameters:
dbi index database handle
data retrieved data
Return values:
setp (malloc'ed) index set
Returns:
0 on success

Definition at line 411 of file rpmdb.c.

References _DBSWAP, _dbswap::ui, and xmalloc().

Referenced by dbiFindMatches(), rpmdbAdd(), rpmdbCountPackages(), rpmdbFindByFile(), rpmdbGrowIterator(), rpmdbInitIterator(), and rpmdbRemove().

static int hdrNumCmp ( const void *  one,
const void *  two 
) [static]

Definition at line 542 of file rpmdb.c.

Referenced by dbiAppendSet(), dbiPruneSet(), and rpmdbSortIterator().

static int miFreeHeader ( rpmdbMatchIterator  mi,
dbiIndex  dbi 
) [static]

Rewrite a header into packages (if necessary) and free the header.

Note: this is called from a markReplacedFiles iteration, and *must* preserve the "join key" (i.e. offset) for the header.

Parameters:
mi database iterator
dbi index database handle
Returns:
0 on success

Definition at line 1800 of file rpmdb.c.

References _, _free(), blockSignals(), HEADER_MAGIC_NO, headerFree(), headerSizeof(), headerUnload(), _rpmdbMatchIterator::mi_data, _rpmdbMatchIterator::mi_dbc, _rpmdbMatchIterator::mi_h, _rpmdbMatchIterator::mi_hdrchk, _rpmdbMatchIterator::mi_key, _rpmdbMatchIterator::mi_modified, _rpmdbMatchIterator::mi_prevoffset, _rpmdbMatchIterator::mi_ts, RPMERR_DBPUTINDEX, rpmError, RPMMESS_DEBUG, RPMMESS_ERROR, rpmMessage, RPMRC_FAIL, RPMRC_NOTFOUND, tagName(), and unblockSignals().

Referenced by rpmdbFreeIterator(), and rpmdbNextIterator().

static int mireCmp ( const void *  a,
const void *  b 
) [static]

Compare iterator selectors by rpm tag (qsort/bsearch).

Parameters:
a 1st iterator selector
b 2nd iterator selector
Returns:
result of comparison

Definition at line 1920 of file rpmdb.c.

Referenced by rpmdbSetIteratorRE().

static char* mireDup ( rpmTag  tag,
rpmMireMode *  modep,
const char *  pattern 
) [static]

Copy pattern, escaping for appropriate mode.

Parameters:
tag rpm tag
Return values:
modep type of pattern match
Parameters:
pattern pattern to duplicate
Returns:
duplicated pattern

Definition at line 1934 of file rpmdb.c.

References RPMTAG_BASENAMES, RPMTAG_DIRNAMES, xmalloc(), and xstrdup().

Referenced by rpmdbSetIteratorRE().

static int mireSkip ( const rpmdbMatchIterator  mi  )  [static]

Return iterator selector match.

Parameters:
mi rpm database iterator
Returns:
1 if header should be skipped

Definition at line 2104 of file rpmdb.c.

References argv, headerFreeData(), headerGetEntryMinMemory(), _rpmdbMatchIterator::mi_h, _rpmdbMatchIterator::mi_nre, _rpmdbMatchIterator::mi_re, RPM_BIN_TYPE, RPM_CHAR_TYPE, RPM_I18NSTRING_TYPE, RPM_INT16_TYPE, RPM_INT32_TYPE, RPM_INT8_TYPE, RPM_NULL_TYPE, RPM_STRING_ARRAY_TYPE, RPM_STRING_TYPE, and RPMTAG_EPOCH.

Referenced by rpmdbNextIterator().

static unsigned char nibble ( char  c  )  [inline, static]

Convert hex to binary nibble.

Parameters:
c hex character
Returns:
binary nibble

Definition at line 114 of file rpmdb.c.

static pbm_set* PBM_REALLOC ( pbm_set **  sp,
int *  odp,
int  nd 
) [inline, static]

Reallocate a bit map.

Return values:
sp address of bit map pointer
odp no. of bits in map
Parameters:
nd desired no. of bits

Definition at line 87 of file rpmdb.c.

References __PBM_BITS, __PBM_IX, and xrealloc().

Referenced by rpmdbNextIterator().

static const char* queryHeader ( Header  h,
const char *  qfmt 
) [inline, static]

Return header query string.

Warning:
Only default header extensions are available here.
Parameters:
h header
qfmt header sprintf format
Returns:
header query string

Definition at line 777 of file rpmdb.c.

References _, headerDefaultFormats, headerSprintf(), RPMERR_QFMT, rpmError, and rpmTagTable.

int rpmdbBlockDBI ( rpmdb  db,
int  rpmtag 
)

Block access to a single database index.

Parameters:
db rpm database
rpmtag rpm tag (negative to block)
Returns:
0 on success

Definition at line 889 of file rpmdb.c.

Referenced by rpmgiNext().

int rpmdbCloseDBI ( rpmdb  db,
int  rpmtag 
)

Close a single database index.

Parameters:
db rpm database
rpmtag rpm tag
Returns:
0 on success

Definition at line 907 of file rpmdb.c.

Referenced by rpmtsCheck().

static int rpmdbExportInfo ( rpmdb  db,
Header  h,
int  adding 
) [static]

Write added/removed header info.

Parameters:
db rpm database
h header
adding adding an rpmdb header?
Returns:
0 on success

Definition at line 799 of file rpmdb.c.

References _free(), Fclose(), Fopen(), headerGetEntry(), queryHeader(), rpmGetPath(), RPMMESS_DEBUG, rpmMessage, RPMTAG_INSTALLTID, Unlink(), and Utime().

Referenced by rpmdbNew().

static int rpmdbFindByFile ( rpmdb  db,
const char *  filespec,
DBT *  key,
DBT *  data,
dbiIndexSet matches 
) [static]

Find file matches in database.

Parameters:
db rpm database
filespec 
key 
data 
matches 
Returns:
0 on success, 1 on not found, -2 on error

Definition at line 1360 of file rpmdb.c.

References _, _db_tagged_file_indices, _free(), alloca(), dbiAppendSet(), dbiFreeIndexSet(), dbiIndexNewItem(), dbiIndexRecordFileNumber(), dbiIndexRecordOffset(), dbiOpen(), dbt2set(), dirName, FP_EQUAL, fpCacheCreate(), fpCacheFree(), fpLookup(), headerFree(), headerFreeData(), headerGetEntryMinMemory(), headerLink(), rpmdbFreeIterator(), RPMDBI_PACKAGES, rpmdbInitIterator(), rpmdbNextIterator(), RPMERR_DBGETINDEX, rpmError, RPMTAG_BASENAMES, RPMTAG_DIRINDEXES, RPMTAG_DIRNAMES, tagName(), and xcalloc().

Referenced by rpmdbInitIterator().

unsigned int rpmdbGetIteratorFileNum ( rpmdbMatchIterator  mi  ) 

Definition at line 1906 of file rpmdb.c.

References _rpmdbMatchIterator::mi_filenum.

Referenced by rpmtsFindPubkey().

static int rpmdbGrowIterator ( rpmdbMatchIterator  mi,
int  fpNum,
unsigned int  exclude,
unsigned int  tag 
) [static]

Definition at line 2484 of file rpmdb.c.

References _, _db_tagged_file_indices, dbiOpen(), dbt2set(), _rpmdbMatchIterator::mi_data, _rpmdbMatchIterator::mi_db, _rpmdbMatchIterator::mi_dbc, _rpmdbMatchIterator::mi_key, _rpmdbMatchIterator::mi_rpmtag, RPMERR_DBGETINDEX, rpmError, and tagName().

Referenced by rpmdbFindFpList().

static int rpmdbMoveDatabase ( const char *  prefix,
const char *  olddbpath,
int  _olddbapi,
const char *  newdbpath,
int  _newdbapi,
const int *  dbiTags,
int  dbiTagsMax 
) [static]

Definition at line 3738 of file rpmdb.c.

References alloca(), rpmCleanPath(), RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_REMOVED, rpmioFileExists(), and tagName().

Referenced by rpmdbRebuild().

rpmdb rpmdbNew ( const char *  root,
const char *  home,
int  mode,
int  perms,
int  flags 
)

Definition at line 1071 of file rpmdb.c.

References _, _DB_ERRPFX, _db_filter_dups, _DB_HOME, _DB_ROOT, _free(), _rpmdb_debug, _VARLIBRPM, dbiTagsInit(), dbTemplate, rpmdbExportInfo(), rpmdbLink, rpmdbURIPath(), RPMERR_DBOPEN, rpmError, rpmExpand(), rpmExpandNumeric(), rpmGetPath(), urlPath(), and xcalloc().

Referenced by rpmdbOpenDatabase().

int rpmdbOpenDatabase ( const char *  prefix,
const char *  dbpath,
int  _dbapi,
rpmdb dbp,
int  mode,
int  perms,
int  flags 
)

Definition at line 1145 of file rpmdb.c.

References dbiOpen(), RPMDB_FLAG_JUSTCHECK, RPMDB_FLAG_MINIMAL, RPMDBI_ADDED, RPMDBI_AVAILABLE, RPMDBI_DEPENDS, RPMDBI_PACKAGES, RPMDBI_REMOVED, rpmdbNew(), rpmsqEnable(), and RPMTAG_NAME.

Referenced by rpmdbInit(), rpmdbOpen(), rpmdbRebuild(), and rpmdbVerify().

static int rpmdbRemoveDatabase ( const char *  prefix,
const char *  dbpath,
int  _dbapi,
const int *  dbiTags,
int  dbiTagsMax 
) [static]

Definition at line 3679 of file rpmdb.c.

References alloca(), rpmCleanPath(), rpmioFileExists(), and tagName().

Referenced by rpmdbRebuild().

static void rpmdbSortIterator ( rpmdbMatchIterator  mi  )  [static]

Definition at line 2462 of file rpmdb.c.

References hdrNumCmp(), mergesort(), _rpmdbMatchIterator::mi_set, and _rpmdbMatchIterator::mi_sorted.

Referenced by rpmdbFindFpList().

static const char* rpmdbURIPath ( const char *  uri  )  [static]

Return macro expanded absolute path to rpmdb.

Parameters:
uri desired path
Returns:
macro expanded absolute path

Definition at line 1019 of file rpmdb.c.

References _free(), PATH_MAX, realpath(), rpmGetPath(), stpncpy(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by rpmdbNew().

static int rpmioFileExists ( const char *  urlfn  )  [static]

Check if file esists using stat(2).

Parameters:
urlfn file name (may be URL)
Returns:
1 if file exists, 0 if not

Definition at line 3644 of file rpmdb.c.

References errno, Stat(), URL_IS_DASH, URL_IS_FTP, URL_IS_HKP, URL_IS_HTTP, URL_IS_HTTPS, URL_IS_PATH, URL_IS_UNKNOWN, and urlPath().

Referenced by rpmdbMoveDatabase(), and rpmdbRemoveDatabase().

static int set2dbt ( dbiIndex  dbi,
DBT *  data,
dbiIndexSet  set 
) [static]

Convert index set to database representation.

Parameters:
dbi index database handle
data retrieved data
set index set
Returns:
0 on success

Definition at line 481 of file rpmdb.c.

References _DBSWAP, and xmalloc().

Referenced by rpmdbAdd(), and rpmdbRemove().

static unsigned taghash ( const char *  s  )  [inline, static]

Return a tagnum with hash on the (directory) path in upper 16 bits.

Parameters:
s (directory) path
Returns:
tagnum with (directory) path hash

Definition at line 1339 of file rpmdb.c.

Referenced by rpmdbAdd(), and rpmdbFindFpList().

static int unblockSignals ( rpmdb  db,
sigset_t *  oldMask 
) [static]

Restore signal mask.

Parameters:
db rpm database
oldMask previous sigset
Returns:
0 on success

Definition at line 762 of file rpmdb.c.

References rpmdbCheckSignals().

Referenced by miFreeHeader().

rpmdb XrpmdbLink ( rpmdb  db,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Todo:
Remove debugging entry from the ABI.

Definition at line 1254 of file rpmdb.c.

References _rpmdb_debug.

rpmdb XrpmdbUnlink ( rpmdb  db,
const char *  msg,
const char *  fn,
unsigned  ln 
)

Todo:
Remove debugging entry from the ABI.

Definition at line 1244 of file rpmdb.c.

References _rpmdb_debug.


Variable Documentation

int _db_filter_dups = 0 [static]

Definition at line 46 of file rpmdb.c.

Referenced by rpmdbNew(), and rpmdbRebuild().

int _db_tagged_file_indices = 1 [static]

Definition at line 53 of file rpmdb.c.

Referenced by rpmdbAdd(), rpmdbFindByFile(), rpmdbFindFpList(), and rpmdbGrowIterator().

int _rebuildinprogress = 0 [static]

Definition at line 44 of file rpmdb.c.

Referenced by dbiOpen(), and rpmdbRebuild().

int _rpmdb_debug = 0

Definition at line 35 of file rpmdb.c.

int _rsegfault = 0

Definition at line 38 of file rpmdb.c.

int _wsegfault = 0

Definition at line 41 of file rpmdb.c.

struct rpmdb_s dbTemplate [static]

Initial value:

 {
     "/" ,       "%{?_dbpath}" ,  0 ,  0 ,  0644 ,
     -1 ,        "rpmdb" 
}

Definition at line 855 of file rpmdb.c.

Referenced by rpmdbNew().

struct _dbiVec* mydbvecs[] [static]

Initial value:

 {
     NULL ,  NULL ,  NULL ,  NULL ,  NULL , NULL
}

Definition at line 270 of file rpmdb.c.

rpmdb rpmdbRock [static]

Definition at line 681 of file rpmdb.c.

Referenced by rpmdbClose().

rpmdbMatchIterator rpmmiRock [static]

Definition at line 684 of file rpmdb.c.

Referenced by rpmdbCheckSignals(), rpmdbFreeIterator(), and rpmdbInitIterator().


Generated on Fri Aug 31 10:50:52 2007 for rpm by  doxygen 1.5.1