- Rename addFingerprints() to fpCachePopulate() and move into fprint.c.
This doesn't really belong here as it requires fprint becoming aware
of transactions and all, but at least these are all controlled API
accesses unlike where in transaction.c this was messing with somebody
elses data structures directly.
- Move the by-fingerprint creation to fpCachePopulate() so it gets
lazily done as needed and copy the original hash-size heuristics
back here.
#include "system.h"
#include <rpm/rpmfileutil.h> /* for rpmCleanPath */
+#include <rpm/rpmts.h>
+#include <rpm/rpmdb.h>
#include "lib/rpmdb_internal.h"
#include "lib/rpmfi_internal.h"
+#include "lib/rpmte_internal.h"
#include "lib/fprint.h"
#include "lib/misc.h"
#include "debug.h"
fpc->ht = rpmFpEntryHashCreate(sizeHint, rstrhash, strcmp,
(rpmFpEntryHashFreeKey)free,
(rpmFpEntryHashFreeData)free);
- fpc->fp = rpmFpHashCreate(sizeHint, fpHashFunction, fpEqual,
- NULL, NULL);
return fpc;
}
{
return rpmFpHashGetEntry(cache->fp, fp, recs, numRecs, NULL);
}
+
+void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
+{
+ rpmtsi pi;
+ rpmte p;
+ rpmfs fs;
+ rpmfi fi;
+ int i, fc;
+
+ if (fpc->fp == NULL)
+ fpc->fp = rpmFpHashCreate(fileCount/2 + 10001, fpHashFunction, fpEqual,
+ NULL, NULL);
+
+ rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
+
+ pi = rpmtsiInit(ts);
+ while ((p = rpmtsiNext(pi, 0)) != NULL) {
+ (void) rpmdbCheckSignals();
+
+ if ((fi = rpmteFI(p)) == NULL)
+ continue; /* XXX can't happen */
+
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ rpmfiFpLookup(fi, fpc);
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
+ /* collect symbolic links */
+ for (i = 0; i < fc; i++) {
+ struct rpmffi_s ffi;
+ char const *linktarget;
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ continue;
+ linktarget = rpmfiFLinkIndex(fi, i);
+ if (!(linktarget && *linktarget != '\0'))
+ continue;
+ ffi.p = p;
+ ffi.fileno = i;
+ rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
+ }
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
+
+ }
+ rpmtsiFree(pi);
+
+ /* ===============================================
+ * Check fingerprints if they contain symlinks
+ * and add them to the hash table
+ */
+
+ pi = rpmtsiInit(ts);
+ while ((p = rpmtsiNext(pi, 0)) != NULL) {
+ (void) rpmdbCheckSignals();
+
+ fs = rpmteGetFileStates(p);
+ fc = rpmfsFC(fs);
+ (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ for (i = 0; i < fc; i++) {
+ if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
+ continue;
+ fpLookupSubdir(symlinks, fpc, p, i);
+ }
+ (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
+ }
+ rpmtsiFree(pi);
+
+ rpmFpHashFree(symlinks);
+}
+
int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
struct rpmffi_s ** recs, int * numRecs);
+RPM_GNUC_INTERNAL
+void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
+
/**
* Return finger print of a file path.
* @param cache pointer to fingerprint cache
return 0;
}
-/* Add fingerprint for each file not skipped. */
-static void addFingerprints(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
-{
- rpmtsi pi;
- rpmte p;
- rpmfs fs;
- rpmfi fi;
- int i, fc;
-
- rpmFpHash symlinks = rpmFpHashCreate(fileCount/16+16, fpHashFunction, fpEqual, NULL, NULL);
-
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL) {
- (void) rpmdbCheckSignals();
-
- if ((fi = rpmteFI(p)) == NULL)
- continue; /* XXX can't happen */
-
- (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- rpmfiFpLookup(fi, fpc);
- fs = rpmteGetFileStates(p);
- fc = rpmfsFC(fs);
- /* collect symbolic links */
- for (i = 0; i < fc; i++) {
- struct rpmffi_s ffi;
- char const *linktarget;
- if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
- continue;
- linktarget = rpmfiFLinkIndex(fi, i);
- if (!(linktarget && *linktarget != '\0'))
- continue;
- ffi.p = p;
- ffi.fileno = i;
- rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
- }
- (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
-
- }
- rpmtsiFree(pi);
-
- /* ===============================================
- * Check fingerprints if they contain symlinks
- * and add them to the hash table
- */
-
- pi = rpmtsiInit(ts);
- while ((p = rpmtsiNext(pi, 0)) != NULL) {
- (void) rpmdbCheckSignals();
-
- fs = rpmteGetFileStates(p);
- fc = rpmfsFC(fs);
- (void) rpmswEnter(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- for (i = 0; i < fc; i++) {
- if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
- continue;
- fpLookupSubdir(symlinks, fpc, p, i);
- }
- (void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), 0);
- }
- rpmtsiFree(pi);
-
- rpmFpHashFree(symlinks);
-}
-
static int rpmtsSetup(rpmts ts, rpmprobFilterFlags ignoreSet)
{
rpm_tid_t tid = (rpm_tid_t) time(NULL);
}
rpmtsNotify(ts, NULL, RPMCALLBACK_TRANS_START, 6, tsmem->orderCount);
- addFingerprints(ts, fileCount, fpc);
+ /* Add fingerprint for each file not skipped. */
+ fpCachePopulate(fpc, ts, fileCount);
/* check against files in the rpmdb */
checkInstalledFiles(ts, fileCount, fpc);