summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Festi <ffesti@redhat.com>2010-06-04 14:30:16 +0200
committerFlorian Festi <ffesti@redhat.com>2010-07-07 16:37:25 +0200
commite3ed6eccee2c9afd4da4283702aca9e155cbfa81 (patch)
treef31b8ec8bb46d385c09ce692b79bb7bad41717c1
parent1abb4ec04804802c14dcd5fc17366cae8201c4b6 (diff)
downloadlibrpm-tizen-e3ed6eccee2c9afd4da4283702aca9e155cbfa81.tar.gz
librpm-tizen-e3ed6eccee2c9afd4da4283702aca9e155cbfa81.tar.bz2
librpm-tizen-e3ed6eccee2c9afd4da4283702aca9e155cbfa81.zip
Make FSM_LSTAT and FSM_STAT one function
-rw-r--r--lib/fsm.c47
1 files changed, 23 insertions, 24 deletions
diff --git a/lib/fsm.c b/lib/fsm.c
index 535b26681..c569ee01a 100644
--- a/lib/fsm.c
+++ b/lib/fsm.c
@@ -1004,6 +1004,25 @@ static int writeLinkedFile(FSM_t fsm)
return ec;
}
+static int fsmStat(FSM_t fsm, int dolstat)
+{
+ int rc;
+ if (dolstat){
+ rc = lstat(fsm->path, &fsm->osb);
+ } else {
+ rc = stat(fsm->path, &fsm->osb);
+ }
+ if (_fsm_debug && (FSM_STAT & FSM_SYSCALL) && rc && errno != ENOENT)
+ rpmlog(RPMLOG_DEBUG, " %8s (%s, ost) %s\n",
+ fileStageString(dolstat ? FSM_LSTAT : FSM_STAT),
+ fsm->path, (rc < 0 ? strerror(errno) : ""));
+ if (rc < 0) {
+ rc = (errno == ENOENT ? CPIOERR_ENOENT : CPIOERR_LSTAT_FAILED);
+ memset(&fsm->osb, 0, sizeof(fsm->osb)); /* XXX s390x hackery */
+ }
+ return rc;
+}
+
/** \ingroup payload
* Create pending hard links to existing file.
* @param fsm file state machine data
@@ -1246,7 +1265,7 @@ static int fsmMkdirs(FSM_t fsm)
}
/* Validate next component of path. */
- rc = fsmUNSAFE(fsm, FSM_LSTAT);
+ rc = fsmStat(fsm, 1); /* lstat */
*te = '/';
/* Directory already exists? */
@@ -1378,8 +1397,7 @@ static int fsmInit(FSM_t fsm)
if (fsm->path != NULL &&
!(fsm->goal == FSM_PKGINSTALL && S_ISREG(fsm->sb.st_mode)))
{
- rc = fsmUNSAFE(fsm, (!(fsm->mapFlags & CPIO_FOLLOW_SYMLINKS)
- ? FSM_LSTAT : FSM_STAT));
+ rc = fsmStat(fsm, (!(fsm->mapFlags & CPIO_FOLLOW_SYMLINKS)));
if (rc == CPIOERR_ENOENT) {
// errno = saveerrno; XXX temporary commented out
rc = 0;
@@ -1513,6 +1531,7 @@ static int fsmSetcap(FSM_t fsm)
#endif /* WITH_CAP */
+
/********************************************************************/
#define IS_DEV_LOG(_x) \
@@ -2110,7 +2129,7 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
} else if (S_ISDIR(st->st_mode)) {
if (S_ISDIR(ost->st_mode)) return 0;
if (S_ISLNK(ost->st_mode)) {
- rc = fsmUNSAFE(fsm, FSM_STAT);
+ rc = fsmStat(fsm, 0);
if (rc == CPIOERR_ENOENT) rc = 0;
if (rc) break;
errno = saveerrno;
@@ -2138,26 +2157,6 @@ if (!(fsm->mapFlags & CPIO_ALL_HARDLINKS)) break;
if (rc == 0) rc = CPIOERR_ENOENT;
return (rc ? rc : CPIOERR_ENOENT); /* XXX HACK */
break;
- case FSM_LSTAT:
- rc = lstat(fsm->path, ost);
- if (_fsm_debug && (stage & FSM_SYSCALL) && rc && errno != ENOENT)
- rpmlog(RPMLOG_DEBUG, " %8s (%s, ost) %s\n", cur,
- fsm->path, (rc < 0 ? strerror(errno) : ""));
- if (rc < 0) {
- rc = (errno == ENOENT ? CPIOERR_ENOENT : CPIOERR_LSTAT_FAILED);
- memset(ost, 0, sizeof(*ost)); /* XXX s390x hackery */
- }
- break;
- case FSM_STAT:
- rc = stat(fsm->path, ost);
- if (_fsm_debug && (stage & FSM_SYSCALL) && rc && errno != ENOENT)
- rpmlog(RPMLOG_DEBUG, " %8s (%s, ost) %s\n", cur,
- fsm->path, (rc < 0 ? strerror(errno) : ""));
- if (rc < 0) {
- rc = (errno == ENOENT ? CPIOERR_ENOENT : CPIOERR_STAT_FAILED);
- memset(ost, 0, sizeof(*ost)); /* XXX s390x hackery */
- }
- break;
case FSM_READLINK:
/* XXX NUL terminated result in fsm->rdbuf, len in fsm->rdnb. */
rc = readlink(fsm->path, fsm->rdbuf, fsm->rdsize - 1);