diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2012-09-14 09:28:50 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2012-09-14 13:41:41 +0300 |
commit | 3d65369920e539b51142f981fd8faff7d7dad5ed (patch) | |
tree | 2151f12a2ee791a2d7cb11e62b4051ab33f18fb1 | |
parent | 9e7adb8f14303edf0262744cea7a7f0a650f8ca2 (diff) | |
download | librpm-tizen-3d65369920e539b51142f981fd8faff7d7dad5ed.tar.gz librpm-tizen-3d65369920e539b51142f981fd8faff7d7dad5ed.tar.bz2 librpm-tizen-3d65369920e539b51142f981fd8faff7d7dad5ed.zip |
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.
-rw-r--r-- | lib/fprint.c | 28 | ||||
-rw-r--r-- | lib/fprint.h | 17 | ||||
-rw-r--r-- | lib/rpmfi.c | 8 | ||||
-rw-r--r-- | lib/rpmfi_internal.h | 2 | ||||
-rw-r--r-- | lib/transaction.c | 16 |
5 files changed, 37 insertions, 34 deletions
diff --git a/lib/fprint.c b/lib/fprint.c index a0aef4a5b..916e66a14 100644 --- a/lib/fprint.c +++ b/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); diff --git a/lib/fprint.h b/lib/fprint.h index 2a2b7cf03..1eae4d2f2 100644 --- a/lib/fprint.h +++ b/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); diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 18363f1d1..ad021170a 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -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) diff --git a/lib/rpmfi_internal.h b/lib/rpmfi_internal.h index 555481983..24662e6b0 100644 --- a/lib/rpmfi_internal.h +++ b/lib/rpmfi_internal.h @@ -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, diff --git a/lib/transaction.c b/lib/transaction.c index 1b00194a1..3404643c5 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -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); |