summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2012-09-14 00:10:45 +0300
committerPanu Matilainen <pmatilai@redhat.com>2012-09-14 13:36:42 +0300
commit5d89aac5d2f271267c642a64e631263dbdfdeacf (patch)
treea8d272e4b4070f9af992c9cb2b5d1b6bbfb0997d
parentae38f0a977ded4da48b71caac6f796505ef5456a (diff)
downloadlibrpm-tizen-5d89aac5d2f271267c642a64e631263dbdfdeacf.tar.gz
librpm-tizen-5d89aac5d2f271267c642a64e631263dbdfdeacf.tar.bz2
librpm-tizen-5d89aac5d2f271267c642a64e631263dbdfdeacf.zip
Add internal API for fingerprint lookup-and-compare
- Replace the direct hackery in rpmdb internals with a little less direct hackery...
-rw-r--r--lib/fprint.c8
-rw-r--r--lib/fprint.h5
-rw-r--r--lib/rpmdb.c6
3 files changed, 15 insertions, 4 deletions
diff --git a/lib/fprint.c b/lib/fprint.c
index e4566a842..037fc6a99 100644
--- a/lib/fprint.c
+++ b/lib/fprint.c
@@ -241,6 +241,14 @@ int fpEqual(const fingerPrint * k1, const fingerPrint * k2)
}
+int fpLookupEquals(fingerPrintCache cache, fingerPrint *fp,
+ const char * dirName, const char * baseName)
+{
+ struct fingerPrint_s ofp;
+ fpLookup(cache, dirName, baseName, 1, &ofp);
+ return FP_EQUAL(*fp, ofp);
+}
+
void fpLookupList(fingerPrintCache cache, rpmstrPool pool,
rpmsid * dirNames, rpmsid * baseNames,
const uint32_t * dirIndexes,
diff --git a/lib/fprint.h b/lib/fprint.h
index c68a49f30..5866df2e7 100644
--- a/lib/fprint.h
+++ b/lib/fprint.h
@@ -85,6 +85,11 @@ int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
RPM_GNUC_INTERNAL
void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
+/* compare an existing fingerprint with a looked-up fingerprint for db/bn */
+RPM_GNUC_INTERNAL
+int fpLookupEquals(fingerPrintCache cache, fingerPrint * fp,
+ const char * dirName, const char * baseName);
+
/**
* Return finger print of a file path.
* @param cache pointer to fingerprint cache
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index 7d906dab8..a6600cd31 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -985,7 +985,6 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec,
headerGet(h, RPMTAG_FILESTATES, &fs, HEADERGET_MINMEM);
do {
- fingerPrint fp2;
int num = dbiIndexRecordFileNumber(allMatches, i);
int skip = 0;
@@ -997,9 +996,8 @@ static int rpmdbFindByFile(rpmdb db, dbiIndex dbi, const char *filespec,
}
if (!skip) {
- fpLookup(fpc,
- dirNames[dirIndexes[num]], baseNames[num], 1, &fp2);
- if (FP_EQUAL(fp1, fp2)) {
+ const char *dirName = dirNames[dirIndexes[num]];
+ if (fpLookupEquals(fpc, &fp1, dirName, baseNames[num])) {
struct dbiIndexItem rec = {
.hdrNum = dbiIndexRecordOffset(allMatches, i),
.tagNum = dbiIndexRecordFileNumber(allMatches, i),