Fix RPMTAG_FILESTATES in rpmdb
authorPanu Matilainen <pmatilai@redhat.com>
Mon, 9 Mar 2009 12:48:47 +0000 (14:48 +0200)
committerPanu Matilainen <pmatilai@redhat.com>
Mon, 9 Mar 2009 14:02:57 +0000 (16:02 +0200)
- sizeof(rpmfileState) != sizeof(char), and char is what goes to headers
  resulting in some pretty weird states despite being correct on disk
- add rpm_fstate_t type for the header presentation of states and
  use where appropriate
(cherry picked from commit 2b4507d852ac8469608bef2ce8e219d76b0c543e)

lib/psm.c
lib/rpmte.c
lib/rpmte_internal.h

index 112d344..b493b33 100644 (file)
--- a/lib/psm.c
+++ b/lib/psm.c
@@ -1417,11 +1417,11 @@ rpmRC rpmpsmStage(rpmpsm psm, pkgStage stage)
            rpm_time_t installTime = (rpm_time_t) time(NULL);
            rpmfs fs = rpmteGetFileStates(psm->te);
            rpm_count_t fc = rpmfsFC(fs);
-           rpmfileState * fileStates = rpmfsGetStates(fs);
+           rpm_fstate_t * fileStates = rpmfsGetStates(fs);
            Header h = rpmteHeader(psm->te);
 
            if (fileStates != NULL && fc > 0) {
-               headerPutChar(h, RPMTAG_FILESTATES, (char *) fileStates, fc);
+               headerPutChar(h, RPMTAG_FILESTATES, fileStates, fc);
            }
 
            headerPutUint32(h, RPMTAG_INSTALLTIME, &installTime, 1);
index 130c1d9..bda5411 100644 (file)
@@ -988,7 +988,7 @@ rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix)
     return RPMFILE_STATE_MISSING;
 }
 
-rpmfileState * rpmfsGetStates(rpmfs fs)
+rpm_fstate_t * rpmfsGetStates(rpmfs fs)
 {
     return fs->states;
 }
index 5706d56..3ce4112 100644 (file)
@@ -36,10 +36,12 @@ struct sharedFileInfo_s {
     int otherFileNum;
 };
 
+typedef char rpm_fstate_t;
+
 struct rpmfs_s {
     unsigned int fc;
 
-    rpmfileState * states;
+    rpm_fstate_t * states;
     rpmFileAction * actions;   /*!< File disposition(s). */
 
     sharedFileInfo replaced;   /*!< (TR_ADDED) to be replaced files in the rpmdb */
@@ -106,7 +108,7 @@ rpmfileState rpmfsGetState(rpmfs fs, unsigned int ix);
  * May return NULL
  */
 RPM_GNUC_INTERNAL
-rpmfileState * rpmfsGetStates(rpmfs fs);
+rpm_fstate_t * rpmfsGetStates(rpmfs fs);
 
 RPM_GNUC_INTERNAL
 rpmFileAction rpmfsGetAction(rpmfs fs, unsigned int ix);