Make fingerprint struct opaque outside fprint.c
- rpmfi cannot know anything about the storage, so rpmfiFpxIndex() cannot be... change it to rpmfiFps() which only returns the pointer we got from fpLookupList() - Change fpCacheGetByFp() to assume it gets passed an array of fps, and take an additional index argument. Return the fingerprint pointer on success, NULL on not found to allow further operations on the fp without knowing its internals.
This commit is contained in:
parent
9e7adb8f14
commit
3d65369920
28
lib/fprint.c
28
lib/fprint.c
|
@ -51,6 +51,18 @@ struct fprintCacheEntry_s {
|
|||
ino_t ino; /*!< stat(2) inode number */
|
||||
};
|
||||
|
||||
/**
|
||||
* Associates a trailing sub-directory and final base name with an existing
|
||||
* directory finger print.
|
||||
*/
|
||||
struct fingerPrint_s {
|
||||
/*! directory finger print entry (the directory path is stat(2)-able */
|
||||
const struct fprintCacheEntry_s * entry;
|
||||
/*! trailing sub-directory path (directories that are not stat(2)-able */
|
||||
const char * subDir;
|
||||
const char * baseName; /*!< file base name */
|
||||
};
|
||||
|
||||
#define FP_ENTRY_EQUAL(a, b) (((a)->dev == (b)->dev) && ((a)->ino == (b)->ino))
|
||||
|
||||
#define FP_EQUAL(a, b) ( \
|
||||
|
@ -326,7 +338,7 @@ static void fpLookupSubdir(rpmFpHash symlinks, fingerPrintCache fpc, rpmte p, in
|
|||
struct rpmffi_s * recs;
|
||||
int numRecs;
|
||||
int i;
|
||||
fingerPrint *fp = rpmfiFpsIndex(fi, filenr);
|
||||
fingerPrint *fp = rpmfiFps(fi) + filenr;
|
||||
int symlinkcount = 0;
|
||||
struct rpmffi_s ffi = { p, filenr};
|
||||
|
||||
|
@ -434,10 +446,14 @@ static void fpLookupSubdir(rpmFpHash symlinks, fingerPrintCache fpc, rpmte p, in
|
|||
|
||||
}
|
||||
|
||||
int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
|
||||
struct rpmffi_s ** recs, int * numRecs)
|
||||
fingerPrint * fpCacheGetByFp(fingerPrintCache cache,
|
||||
struct fingerPrint_s * fp, int ix,
|
||||
struct rpmffi_s ** recs, int * numRecs)
|
||||
{
|
||||
return rpmFpHashGetEntry(cache->fp, fp, recs, numRecs, NULL);
|
||||
if (rpmFpHashGetEntry(cache->fp, fp + ix, recs, numRecs, NULL))
|
||||
return fp + ix;
|
||||
else
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
|
||||
|
@ -456,6 +472,7 @@ void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
|
|||
|
||||
pi = rpmtsiInit(ts);
|
||||
while ((p = rpmtsiNext(pi, 0)) != NULL) {
|
||||
fingerPrint *fpList;
|
||||
(void) rpmdbCheckSignals();
|
||||
|
||||
if ((fi = rpmteFI(p)) == NULL)
|
||||
|
@ -465,6 +482,7 @@ void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
|
|||
rpmfiFpLookup(fi, fpc);
|
||||
fs = rpmteGetFileStates(p);
|
||||
fc = rpmfsFC(fs);
|
||||
fpList = rpmfiFps(fi);
|
||||
/* collect symbolic links */
|
||||
for (i = 0; i < fc; i++) {
|
||||
struct rpmffi_s ffi;
|
||||
|
@ -476,7 +494,7 @@ void fpCachePopulate(fingerPrintCache fpc, rpmts ts, int fileCount)
|
|||
continue;
|
||||
ffi.p = p;
|
||||
ffi.fileno = i;
|
||||
rpmFpHashAddEntry(symlinks, rpmfiFpsIndex(fi, i), ffi);
|
||||
rpmFpHashAddEntry(symlinks, fpList + i, ffi);
|
||||
}
|
||||
(void) rpmswExit(rpmtsOp(ts, RPMTS_OP_FINGERPRINT), fc);
|
||||
|
||||
|
|
17
lib/fprint.h
17
lib/fprint.h
|
@ -17,18 +17,6 @@ typedef struct fprintCache_s * fingerPrintCache;
|
|||
*/
|
||||
typedef struct fingerPrint_s fingerPrint;
|
||||
|
||||
/**
|
||||
* Associates a trailing sub-directory and final base name with an existing
|
||||
* directory finger print.
|
||||
*/
|
||||
struct fingerPrint_s {
|
||||
/*! directory finger print entry (the directory path is stat(2)-able */
|
||||
const struct fprintCacheEntry_s * entry;
|
||||
/*! trailing sub-directory path (directories that are not stat(2)-able */
|
||||
const char * subDir;
|
||||
const char * baseName; /*!< file base name */
|
||||
};
|
||||
|
||||
struct rpmffi_s {
|
||||
rpmte p;
|
||||
int fileno;
|
||||
|
@ -55,8 +43,9 @@ RPM_GNUC_INTERNAL
|
|||
fingerPrintCache fpCacheFree(fingerPrintCache cache);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
int fpCacheGetByFp(fingerPrintCache cache, struct fingerPrint_s * fp,
|
||||
struct rpmffi_s ** recs, int * numRecs);
|
||||
fingerPrint * fpCacheGetByFp(fingerPrintCache cache,
|
||||
struct fingerPrint_s * fp, int ix,
|
||||
struct rpmffi_s ** recs, int * numRecs);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
void fpCachePopulate(fingerPrintCache cache, rpmts ts, int fileCount);
|
||||
|
|
|
@ -403,13 +403,9 @@ const char * rpmfiFLangsIndex(rpmfi fi, int ix)
|
|||
return flangs;
|
||||
}
|
||||
|
||||
struct fingerPrint_s *rpmfiFpsIndex(rpmfi fi, int ix)
|
||||
struct fingerPrint_s *rpmfiFps(rpmfi fi)
|
||||
{
|
||||
struct fingerPrint_s * fps = NULL;
|
||||
if (fi != NULL && fi->fps != NULL && ix >= 0 && ix < fi->fc) {
|
||||
fps = fi->fps + ix;
|
||||
}
|
||||
return fps;
|
||||
return (fi != NULL) ? fi->fps : NULL;
|
||||
}
|
||||
|
||||
int rpmfiNext(rpmfi fi)
|
||||
|
|
|
@ -145,7 +145,7 @@ RPM_GNUC_INTERNAL
|
|||
const char * rpmfiFCapsIndex(rpmfi fi, int ix);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
struct fingerPrint_s *rpmfiFpsIndex(rpmfi fi, int ix);
|
||||
struct fingerPrint_s *rpmfiFps(rpmfi fi);
|
||||
|
||||
RPM_GNUC_INTERNAL
|
||||
rpmFileAction rpmfiDecideFateIndex(rpmfi ofi, int oix, rpmfi nfi, int nix,
|
||||
|
|
|
@ -448,6 +448,7 @@ static void handleOverlappedFiles(rpmts ts, fingerPrintCache fpc, rpmte p, rpmfi
|
|||
rpmfs otherFs;
|
||||
rpm_count_t fc = rpmfiFC(fi);
|
||||
int reportConflicts = !(rpmtsFilterFlags(ts) & RPMPROB_FILTER_REPLACENEWFILES);
|
||||
fingerPrint * fpList = rpmfiFps(fi);
|
||||
|
||||
for (i = 0; i < fc; i++) {
|
||||
struct fingerPrint_s * fiFps;
|
||||
|
@ -461,7 +462,6 @@ static void handleOverlappedFiles(rpmts ts, fingerPrintCache fpc, rpmte p, rpmfi
|
|||
if (XFA_SKIPPING(rpmfsGetAction(fs, i)))
|
||||
continue;
|
||||
|
||||
fiFps = rpmfiFpsIndex(fi, i);
|
||||
FFlags = rpmfiFFlagsIndex(fi, i);
|
||||
|
||||
fixupSize = 0;
|
||||
|
@ -472,7 +472,7 @@ static void handleOverlappedFiles(rpmts ts, fingerPrintCache fpc, rpmte p, rpmfi
|
|||
* will be installed and removed so the records for an overlapped
|
||||
* files will be sorted in exactly the same order.
|
||||
*/
|
||||
fpCacheGetByFp(fpc, fiFps, &recs, &numRecs);
|
||||
fiFps = fpCacheGetByFp(fpc, fpList, i, &recs, &numRecs);
|
||||
|
||||
/*
|
||||
* If this package is being added, look only at other packages
|
||||
|
@ -948,7 +948,6 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
|
|||
rpmfs fs;
|
||||
int j;
|
||||
unsigned int fileNum;
|
||||
const char * oldDir;
|
||||
|
||||
rpmdbMatchIterator mi;
|
||||
Header h, newheader;
|
||||
|
@ -994,10 +993,9 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
|
|||
headerGet(h, RPMTAG_FILESTATES, &ostates, hgflags);
|
||||
}
|
||||
|
||||
oldDir = NULL;
|
||||
/* loop over all interesting files in that package */
|
||||
do {
|
||||
int gotRecs;
|
||||
int fpIx;
|
||||
struct rpmffi_s * recs;
|
||||
int numRecs;
|
||||
const char * dirName;
|
||||
|
@ -1015,14 +1013,16 @@ void checkInstalledFiles(rpmts ts, uint64_t fileCount, fingerPrintCache fpc)
|
|||
baseName = rpmtdGetString(&bnames);
|
||||
|
||||
fpLookup(fpc, dirName, baseName, 1, &fpp);
|
||||
fpIx = 0;
|
||||
} else {
|
||||
fpp = rpmfiFpsIndex(otherFi, fileNum);
|
||||
fpp = rpmfiFps(otherFi);
|
||||
fpIx = fileNum;
|
||||
}
|
||||
|
||||
/* search for files in the transaction with same finger print */
|
||||
gotRecs = fpCacheGetByFp(fpc, fpp, &recs, &numRecs);
|
||||
fpCacheGetByFp(fpc, fpp, fpIx, &recs, &numRecs);
|
||||
|
||||
for (j=0; (j<numRecs)&&gotRecs; j++) {
|
||||
for (j = 0; j < numRecs; j++) {
|
||||
p = recs[j].p;
|
||||
fi = rpmteFI(p);
|
||||
fs = rpmteGetFileStates(p);
|
||||
|
|
Loading…
Reference in New Issue