Make fingerprint cache entry opaque, add some kind of API for the needed bits
authorPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Sep 2012 04:45:44 +0000 (07:45 +0300)
committerPanu Matilainen <pmatilai@redhat.com>
Fri, 14 Sep 2012 10:38:52 +0000 (13:38 +0300)
- 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...

lib/fprint.c
lib/fprint.h
lib/transaction.c

index f7f6f66..a31e546 100644 (file)
 #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);
index cb14c77..1486753 100644 (file)
@@ -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
index a8b9606..8bcf5aa 100644 (file)
@@ -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));