From: Panu Matilainen Date: Fri, 14 Sep 2012 04:45:44 +0000 (+0300) Subject: Make fingerprint cache entry opaque, add some kind of API for the needed bits X-Git-Tag: rpm-4.11.0-alpha~124 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=ab180dacb9badaef882a098639eb50196cff8f57;p=platform%2Fupstream%2Frpm.git Make fingerprint cache entry opaque, add some kind of API for the needed bits - Only disk-space calculations need the actual entry contents, add getter for dir name and device. We're passing the cache to these getters too: its not currently unusedd but will be needed for directory name pool id->string translation once we get there... --- diff --git a/lib/fprint.c b/lib/fprint.c index f7f6f66..a31e546 100644 --- a/lib/fprint.c +++ b/lib/fprint.c @@ -39,6 +39,18 @@ #undef HTKEYTYPE #undef HTDATATYPE +/** + * Finger print cache entry. + * This is really a directory and symlink cache. We don't differentiate between + * the two. We can prepopulate it, which allows us to easily conduct "fake" + * installs of a system w/o actually mounting filesystems. + */ +struct fprintCacheEntry_s { + const char * dirName; /*!< path to existing directory */ + dev_t dev; /*!< stat(2) device number */ + ino_t ino; /*!< stat(2) inode number */ +}; + #define FP_ENTRY_EQUAL(a, b) (((a)->dev == (b)->dev) && ((a)->ino == (b)->ino)) #define FP_EQUAL(a, b) ( \ @@ -251,8 +263,18 @@ int fpEqual(const fingerPrint * k1, const fingerPrint * k2) } +const char * fpEntryDir(fingerPrintCache cache, fingerPrint *fp) +{ + return (fp && fp->entry) ? fp->entry->dirName : NULL; +} + +dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp) +{ + return (fp && fp->entry) ? fp->entry->dev : 0; +} + int fpLookupEquals(fingerPrintCache cache, fingerPrint *fp, - const char * dirName, const char * baseName) + const char * dirName, const char * baseName) { struct fingerPrint_s ofp; fpLookup(cache, dirName, baseName, 1, &ofp); diff --git a/lib/fprint.h b/lib/fprint.h index cb14c77..1486753 100644 --- a/lib/fprint.h +++ b/lib/fprint.h @@ -29,18 +29,6 @@ const char * subDir; const char * baseName; /*!< file base name */ }; -/** - * Finger print cache entry. - * This is really a directory and symlink cache. We don't differentiate between - * the two. We can prepopulate it, which allows us to easily conduct "fake" - * installs of a system w/o actually mounting filesystems. - */ -struct fprintCacheEntry_s { - const char * dirName; /*!< path to existing directory */ - dev_t dev; /*!< stat(2) device number */ - ino_t ino; /*!< stat(2) inode number */ -}; - struct rpmffi_s { rpmte p; int fileno; @@ -78,6 +66,12 @@ RPM_GNUC_INTERNAL int fpLookupEquals(fingerPrintCache cache, fingerPrint * fp, const char * dirName, const char * baseName); +RPM_GNUC_INTERNAL +const char *fpEntryDir(fingerPrintCache cache, fingerPrint *fp); + +RPM_GNUC_INTERNAL +dev_t fpEntryDev(fingerPrintCache cache, fingerPrint *fp); + /** * Return finger print of a file path. * @param cache pointer to fingerprint cache diff --git a/lib/transaction.c b/lib/transaction.c index a8b9606..8bcf5aa 100644 --- a/lib/transaction.c +++ b/lib/transaction.c @@ -612,7 +612,7 @@ assert(otherFi != NULL); } /* Update disk space info for a file. */ - rpmtsUpdateDSI(ts, fiFps->entry->dev, fiFps->entry->dirName, + rpmtsUpdateDSI(ts, fpEntryDev(fpc, fiFps), fpEntryDir(fpc, fiFps), rpmfiFSizeIndex(fi, i), rpmfiFReplacedSizeIndex(fi, i), fixupSize, rpmfsGetAction(fs, i));