summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-10-14 17:03:14 +0300
committerPanu Matilainen <pmatilai@redhat.com>2009-10-14 17:03:14 +0300
commitbdfb54bd238ab2d09175d2b921435b7a059ac25c (patch)
treec7450487d4b04fe645bef5ac761a9be728881d2d
parent1ff10e3d68417ebdeac329c79299187710afb697 (diff)
downloadrpm-bdfb54bd238ab2d09175d2b921435b7a059ac25c.tar.gz
rpm-bdfb54bd238ab2d09175d2b921435b7a059ac25c.tar.bz2
rpm-bdfb54bd238ab2d09175d2b921435b7a059ac25c.zip
Remove cpio stuff from FD_t
- only the FSM cares about cpio position, move it there - there's only ever one fd active inside FSM, no need to track it per-fd
-rw-r--r--lib/fsm.c21
-rw-r--r--lib/fsm.h1
-rw-r--r--rpmio/rpmio.c3
-rw-r--r--rpmio/rpmio_internal.h20
4 files changed, 10 insertions, 35 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index 8dc2ba762..838e70339 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -10,7 +10,7 @@
#include <rpm/rpmsq.h>
#include <rpm/rpmlog.h>
-#include "rpmio/rpmio_internal.h" /* fdGet/SetCpioPos, fdInit/FiniDigest */
+#include "rpmio/rpmio_internal.h" /* fdInit/FiniDigest */
#include "lib/cpio.h"
#include "lib/fsm.h"
#define fsmUNSAFE fsmStage
@@ -529,15 +529,13 @@ int fsmSetup(FSM_t fsm, fileStage goal,
rpmts ts, rpmte te, rpmfi fi, FD_t cfd,
rpm_loff_t * archiveSize, char ** failedFile)
{
- rpm_loff_t pos = 0;
int rc, ec = 0;
fsm->goal = goal;
if (cfd != NULL) {
fsm->cfd = fdLink(cfd, RPMDBG_M("persist (fsm)"));
- pos = fdGetCpioPos(fsm->cfd);
- fdSetCpioPos(fsm->cfd, 0);
}
+ fsm->cpioPos = 0;
fsm->iter = mapInitIterator(ts, te, fi);
fsm->digestalgo = rpmfiDigestAlgo(fi);
@@ -569,7 +567,7 @@ int fsmSetup(FSM_t fsm, fileStage goal,
if (rc && !ec) ec = rc;
if (fsm->archiveSize && ec == 0)
- *fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos);
+ *fsm->archiveSize = fsm->cpioPos;
/* FIX: *fsm->failedFile may be NULL */
return ec;
@@ -1756,9 +1754,8 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
rpmte te = fsmGetTe(fsm);
rpmfi fi = fsmGetFi(fsm);
void * ptr;
- rpm_loff_t archivePos = fdGetCpioPos(fsm->cfd);
- if (archivePos > fsm->archivePos) {
- fsm->archivePos = archivePos;
+ if (fsm->cpioPos > fsm->archivePos) {
+ fsm->archivePos = fsm->cpioPos;
ptr = rpmtsNotify(ts, te, RPMCALLBACK_INST_PROGRESS,
fsm->archivePos, fi->archiveSize);
}
@@ -2223,14 +2220,14 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
}
break;
case FSM_POS:
- left = (modulo - (fdGetCpioPos(fsm->cfd) % modulo)) % modulo;
+ left = (modulo - (fsm->cpioPos % modulo)) % modulo;
if (left) {
fsm->wrlen = left;
(void) fsmNext(fsm, FSM_DREAD);
}
break;
case FSM_PAD:
- left = (modulo - (fdGetCpioPos(fsm->cfd) % modulo)) % modulo;
+ left = (modulo - (fsm->cpioPos % modulo)) % modulo;
if (left) {
memset(fsm->rdbuf, 0, left);
/* XXX DWRITE uses rdnb for I/O length. */
@@ -2258,7 +2255,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (fsm->rdnb != fsm->wrlen || Ferror(fsm->cfd))
rc = CPIOERR_READ_FAILED;
if (fsm->rdnb > 0)
- fdSetCpioPos(fsm->cfd, fdGetCpioPos(fsm->cfd) + fsm->rdnb);
+ fsm->cpioPos += fsm->rdnb;
break;
case FSM_DWRITE:
fsm->wrnb = Fwrite(fsm->rdbuf, sizeof(*fsm->rdbuf), fsm->rdnb, fsm->cfd);
@@ -2269,7 +2266,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (fsm->rdnb != fsm->wrnb || Ferror(fsm->cfd))
rc = CPIOERR_WRITE_FAILED;
if (fsm->wrnb > 0)
- fdSetCpioPos(fsm->cfd, fdGetCpioPos(fsm->cfd) + fsm->wrnb);
+ fsm->cpioPos += fsm->wrnb;
break;
case FSM_ROPEN:
diff --git a/lib/fsm.h b/lib/fsm.h
index 3c819b489..d43cb88e9 100644
--- a/lib/fsm.h
+++ b/lib/fsm.h
@@ -133,6 +133,7 @@ struct fsm_s {
hardLink_t li; /*!< Current hard linked file(s). */
rpm_loff_t * archiveSize; /*!< Pointer to archive size. */
rpm_loff_t archivePos; /*!< Current archive position. */
+ rpm_loff_t cpioPos;
char ** failedFile; /*!< First file name that failed. */
const char * subdir; /*!< Current file sub-directory. */
const char * osuffix; /*!< Old, preserved, file suffix. */
diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c
index 860f154e2..2e3e4ec48 100644
--- a/rpmio/rpmio.c
+++ b/rpmio/rpmio.c
@@ -96,7 +96,6 @@ static FD_t c2f(void * cookie)
#define FDNREFS(fd) (fd ? ((FD_t)fd)->nrefs : -9)
#define FDTO(fd) (fd ? ((FD_t)fd)->rd_timeoutsecs : -99)
-#define FDCPIOPOS(fd) (fd ? ((FD_t)fd)->fd_cpioPos : -99)
#define FDONLY(fd) assert(fdGetIo(fd) == fdio)
#define GZDONLY(fd) assert(fdGetIo(fd) == gzdio)
@@ -401,8 +400,6 @@ FD_t fdNew(const char * msg)
fd->stats = xcalloc(1, sizeof(*fd->stats));
fd->digests = NULL;
- fd->fd_cpioPos = 0;
-
return fdLink(fd, msg);
}
diff --git a/rpmio/rpmio_internal.h b/rpmio/rpmio_internal.h
index 92720c9c9..313f96805 100644
--- a/rpmio/rpmio_internal.h
+++ b/rpmio/rpmio_internal.h
@@ -51,8 +51,6 @@ struct _FD_s {
FDSTAT_t stats; /* I/O statistics */
rpmDigestBundle digests;
-
- rpm_loff_t fd_cpioPos; /* cpio: */
};
#define FDSANE(fd) assert(fd && fd->magic == FDMAGIC)
@@ -61,24 +59,6 @@ struct _FD_s {
extern "C" {
#endif
-/** \ingroup rpmio
- */
-static inline
-rpm_loff_t fdGetCpioPos(FD_t fd)
-{
- FDSANE(fd);
- return fd->fd_cpioPos;
-}
-
-/** \ingroup rpmio
- */
-static inline
-void fdSetCpioPos(FD_t fd, rpm_loff_t cpioPos)
-{
- FDSANE(fd);
- fd->fd_cpioPos = cpioPos;
-}
-
static inline
void fdSetBundle(FD_t fd, rpmDigestBundle bundle)
{