fsm.c | fsm.c | |||
---|---|---|---|---|
skipping to change at line 50 | skipping to change at line 50 | |||
/*@access FSMI_t @*/ | /*@access FSMI_t @*/ | |||
/*@access IOSM_t @*/ | /*@access IOSM_t @*/ | |||
/*@access IOSMI_t @*/ | /*@access IOSMI_t @*/ | |||
/*@access rpmfi @*/ | /*@access rpmfi @*/ | |||
/*@access rpmsx @*/ /* XXX cast */ | /*@access rpmsx @*/ /* XXX cast */ | |||
/*@access rpmte @*/ /* XXX cast */ | /*@access rpmte @*/ /* XXX cast */ | |||
/*@access rpmts @*/ /* XXX cast */ | /*@access rpmts @*/ /* XXX cast */ | |||
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) | #ifdef __cplusplus | |||
GENfree(const void *) | ||||
GENfree(unsigned short *) | ||||
GENfree(DNLI_t) | ||||
GENfree(FSMI_t) | ||||
#endif /* __cplusplus */ | ||||
#define alloca_strdup(_s) strcpy((char *)alloca(strlen(_s)+1), | ||||
(_s)) | ||||
#define _FSM_DEBUG 0 | #define _FSM_DEBUG 0 | |||
/*@unchecked@*/ | /*@unchecked@*/ | |||
int _fsm_debug = _FSM_DEBUG; | int _fsm_debug = _FSM_DEBUG; | |||
/*@-exportheadervar@*/ | /*@-exportheadervar@*/ | |||
/*@unchecked@*/ | /*@unchecked@*/ | |||
int _fsm_threads = 0; | int _fsm_threads = 0; | |||
/*@=exportheadervar@*/ | /*@=exportheadervar@*/ | |||
/** | /** | |||
* Retrieve transaction set from file state machine iterator. | * Retrieve transaction set from file state machine iterator. | |||
* @param fsm file state machine | * @param fsm file state machine | |||
* @return transaction set | * @return transaction set | |||
*/ | */ | |||
static rpmts fsmGetTs(const IOSM_t fsm) | static rpmts fsmGetTs(const IOSM_t fsm) | |||
/*@*/ | /*@*/ | |||
{ | { | |||
const FSMI_t iter = fsm->iter; | const FSMI_t iter = fsm->iter; | |||
/*@-compdef -refcounttrans -retexpose -usereleased @*/ | /*@-compdef -refcounttrans -retexpose -usereleased @*/ | |||
return (iter ? iter->ts : NULL); | return (rpmts) (iter ? iter->ts : NULL); | |||
/*@=compdef =refcounttrans =retexpose =usereleased @*/ | /*@=compdef =refcounttrans =retexpose =usereleased @*/ | |||
} | } | |||
/** | /** | |||
* Retrieve transaction element file info from file state machine iterator. | * Retrieve transaction element file info from file state machine iterator. | |||
* @param fsm file state machine | * @param fsm file state machine | |||
* @return transaction element file info | * @return transaction element file info | |||
*/ | */ | |||
static rpmfi fsmGetFi(const IOSM_t fsm) | static rpmfi fsmGetFi(const IOSM_t fsm) | |||
/*@*/ | /*@*/ | |||
{ | { | |||
const FSMI_t iter = fsm->iter; | const FSMI_t iter = fsm->iter; | |||
/*@-compdef -refcounttrans -retexpose -usereleased @*/ | /*@-compdef -refcounttrans -retexpose -usereleased @*/ | |||
return (iter ? iter->fi : NULL); | return (rpmfi) (iter ? iter->fi : NULL); | |||
/*@=compdef =refcounttrans =retexpose =usereleased @*/ | /*@=compdef =refcounttrans =retexpose =usereleased @*/ | |||
} | } | |||
#define SUFFIX_RPMORIG ".rpmorig" | #define SUFFIX_RPMORIG ".rpmorig" | |||
#define SUFFIX_RPMSAVE ".rpmsave" | #define SUFFIX_RPMSAVE ".rpmsave" | |||
#define SUFFIX_RPMNEW ".rpmnew" | #define SUFFIX_RPMNEW ".rpmnew" | |||
/** \ingroup payload | /** \ingroup payload | |||
* Build path to file from file info, ornamented with subdir and suffix. | * Build path to file from file info, ornamented with subdir and suffix. | |||
* @param fsm file state machine data | * @param fsm file state machine data | |||
skipping to change at line 118 | skipping to change at line 125 | |||
{ | { | |||
const char * s = NULL; | const char * s = NULL; | |||
if (fsm) { | if (fsm) { | |||
char * t; | char * t; | |||
int nb; | int nb; | |||
nb = strlen(fsm->dirName) + | nb = strlen(fsm->dirName) + | |||
(st && !S_ISDIR(st->st_mode) ? (subdir ? strlen(subdir) : 0) : 0 ) + | (st && !S_ISDIR(st->st_mode) ? (subdir ? strlen(subdir) : 0) : 0 ) + | |||
(st && !S_ISDIR(st->st_mode) ? (suffix ? strlen(suffix) : 0) : 0 ) + | (st && !S_ISDIR(st->st_mode) ? (suffix ? strlen(suffix) : 0) : 0 ) + | |||
strlen(fsm->baseName) + 1; | strlen(fsm->baseName) + 1; | |||
s = t = xmalloc(nb); | s = t = (char *) xmalloc(nb); | |||
t = stpcpy(t, fsm->dirName); | t = stpcpy(t, fsm->dirName); | |||
if (st && !S_ISDIR(st->st_mode)) | if (st && !S_ISDIR(st->st_mode)) | |||
if (subdir) t = stpcpy(t, subdir); | if (subdir) t = stpcpy(t, subdir); | |||
t = stpcpy(t, fsm->baseName); | t = stpcpy(t, fsm->baseName); | |||
if (st && !S_ISDIR(st->st_mode)) | if (st && !S_ISDIR(st->st_mode)) | |||
if (suffix) t = stpcpy(t, suffix); | if (suffix) t = stpcpy(t, suffix); | |||
} | } | |||
return s; | return s; | |||
} | } | |||
/** \ingroup payload | /** \ingroup payload | |||
* Destroy file info iterator. | * Destroy file info iterator. | |||
* @param p file info iterator | * @param _iter file info iterator | |||
* @retval NULL always | * @retval NULL always | |||
*/ | */ | |||
static /*@null@*/ void * mapFreeIterator(/*@only@*//*@null@*/ void * p) | static /*@null@*/ void * mapFreeIterator(/*@only@*//*@null@*/ void * _iter) | |||
/*@globals fileSystem @*/ | /*@globals fileSystem @*/ | |||
/*@modifies fileSystem @*/ | /*@modifies fileSystem @*/ | |||
{ | { | |||
FSMI_t iter = p; | FSMI_t iter = (FSMI_t) _iter; | |||
if (iter) { | if (iter) { | |||
iter->fi = rpmfiUnlink(iter->fi, "mapIterator"); | iter->fi = rpmfiUnlink(iter->fi, "mapIterator"); | |||
/*@-internalglobs@*/ /* XXX rpmswExit() */ | /*@-internalglobs@*/ /* XXX rpmswExit() */ | |||
(void)rpmtsFree(iter->ts); | (void)rpmtsFree(iter->ts); | |||
iter->ts = NULL; | iter->ts = NULL; | |||
/*@=internalglobs@*/ | /*@=internalglobs@*/ | |||
} | } | |||
return _free(p); | return _free(iter); | |||
} | } | |||
/** \ingroup payload | /** \ingroup payload | |||
* Create file info iterator. | * Create file info iterator. | |||
* @param fi transaction element file info | * @param fi transaction element file info | |||
* @param reverse iterate in reverse order? | * @param reverse iterate in reverse order? | |||
* @return file info iterator | * @return file info iterator | |||
*/ | */ | |||
static void * | static void * | |||
mapInitIterator(rpmfi fi, int reverse) | mapInitIterator(rpmfi fi, int reverse) | |||
/*@modifies fi @*/ | /*@modifies fi @*/ | |||
{ | { | |||
FSMI_t iter = NULL; | FSMI_t iter = NULL; | |||
iter = xcalloc(1, sizeof(*iter)); | iter = (FSMI_t) xcalloc(1, sizeof(*iter)); | |||
/*@-assignexpose -castexpose @*/ | /*@-assignexpose -castexpose @*/ | |||
iter->fi = rpmfiLink(fi, "mapIterator"); | iter->fi = rpmfiLink(fi, "mapIterator"); | |||
/*@=assignexpose =castexpose @*/ | /*@=assignexpose =castexpose @*/ | |||
iter->reverse = reverse; | iter->reverse = reverse; | |||
iter->i = (iter->reverse ? (fi->fc - 1) : 0); | iter->i = (iter->reverse ? (fi->fc - 1) : 0); | |||
iter->isave = iter->i; | iter->isave = iter->i; | |||
return iter; | return iter; | |||
} | } | |||
/** \ingroup payload | /** \ingroup payload | |||
* Return next index into file info. | * Return next index into file info. | |||
* @param a file info iterator | * @param _iter file info iterator | |||
* @return next index, -1 on termination | * @return next index, -1 on termination | |||
*/ | */ | |||
static int mapNextIterator(/*@null@*/ void * a) | static int mapNextIterator(/*@null@*/ void * _iter) | |||
/*@*/ | /*@*/ | |||
{ | { | |||
FSMI_t iter = a; | FSMI_t iter = (FSMI_t) _iter; | |||
int i = -1; | int i = -1; | |||
if (iter) { | if (iter) { | |||
/*@-onlytrans@*/ | /*@-onlytrans@*/ | |||
const rpmfi fi = iter->fi; | const rpmfi fi = (rpmfi) iter->fi; | |||
/*@=onlytrans@*/ | /*@=onlytrans@*/ | |||
if (iter->reverse) { | if (iter->reverse) { | |||
if (iter->i >= 0) i = iter->i--; | if (iter->i >= 0) i = iter->i--; | |||
} else { | } else { | |||
if (iter->i < (int)fi->fc) i = iter->i++; | if (iter->i < (int)fi->fc) i = iter->i++; | |||
} | } | |||
iter->isave = i; | iter->isave = i; | |||
} | } | |||
return i; | return i; | |||
} | } | |||
skipping to change at line 239 | skipping to change at line 246 | |||
* @param fsmPath archive path | * @param fsmPath archive path | |||
* @return index into file info, -1 if archive path was not fou nd | * @return index into file info, -1 if archive path was not fou nd | |||
*/ | */ | |||
static int mapFind(/*@null@*/ FSMI_t iter, const char * fsmPath) | static int mapFind(/*@null@*/ FSMI_t iter, const char * fsmPath) | |||
/*@modifies iter @*/ | /*@modifies iter @*/ | |||
{ | { | |||
int ix = -1; | int ix = -1; | |||
if (iter) { | if (iter) { | |||
/*@-onlytrans@*/ | /*@-onlytrans@*/ | |||
const rpmfi fi = iter->fi; | const rpmfi fi = (rpmfi) iter->fi; | |||
/*@=onlytrans@*/ | /*@=onlytrans@*/ | |||
size_t fc = rpmfiFC(fi); | size_t fc = rpmfiFC(fi); | |||
if (fi && fc > 0 && fi->apath && fsmPath && *fsmPath) { | if (fi && fc > 0 && fi->apath && fsmPath && *fsmPath) { | |||
const char ** p = NULL; | const char ** p = NULL; | |||
if (fi->apath != NULL) | if (fi->apath != NULL) | |||
p = bsearch(&fsmPath, fi->apath, fc, sizeof(fsmPath), | p = (const char **) | |||
cpioStrCmp); | bsearch(&fsmPath, fi->apath, fc, sizeof(fsmPath), | |||
cpioStrCmp); | ||||
if (p) { | if (p) { | |||
iter->i = p - fi->apath; | iter->i = p - fi->apath; | |||
ix = mapNextIterator(iter); | ix = mapNextIterator(iter); | |||
} | } | |||
} | } | |||
} | } | |||
return ix; | return ix; | |||
} | } | |||
/** \ingroup payload | /** \ingroup payload | |||
skipping to change at line 271 | skipping to change at line 279 | |||
rpmfi fi; | rpmfi fi; | |||
/*@only@*/ /*@null@*/ | /*@only@*/ /*@null@*/ | |||
char * active; | char * active; | |||
int reverse; | int reverse; | |||
int isave; | int isave; | |||
int i; | int i; | |||
} * DNLI_t; | } * DNLI_t; | |||
/** \ingroup payload | /** \ingroup payload | |||
* Destroy directory name iterator. | * Destroy directory name iterator. | |||
* @param a directory name iterator | * @param _dnli directory name iterator | |||
* @retval NULL always | * @retval NULL always | |||
*/ | */ | |||
static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/ const void * a) | static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/const void * _ dnli) | |||
/*@modifies a @*/ | /*@modifies a @*/ | |||
{ | { | |||
if (a) { | if (_dnli) { | |||
DNLI_t dnli = (void *)a; | DNLI_t dnli = (DNLI_t) _dnli; | |||
if (dnli->active) free(dnli->active); | if (dnli->active) free(dnli->active); | |||
} | } | |||
return _free(a); | return _free(_dnli); | |||
} | } | |||
/** \ingroup payload | /** \ingroup payload | |||
*/ | */ | |||
static inline int dnlCount(/*@null@*/ const DNLI_t dnli) | static inline int dnlCount(/*@null@*/ const DNLI_t dnli) | |||
/*@*/ | /*@*/ | |||
{ | { | |||
return (int) (dnli ? dnli->fi->dc : 0); | return (int) (dnli ? dnli->fi->dc : 0); | |||
} | } | |||
skipping to change at line 320 | skipping to change at line 328 | |||
/*@uses fsm->iter @*/ | /*@uses fsm->iter @*/ | |||
/*@*/ | /*@*/ | |||
{ | { | |||
rpmfi fi = fsmGetFi(fsm); | rpmfi fi = fsmGetFi(fsm); | |||
const char * dnl; | const char * dnl; | |||
DNLI_t dnli; | DNLI_t dnli; | |||
int i, j; | int i, j; | |||
if (fi == NULL) | if (fi == NULL) | |||
return NULL; | return NULL; | |||
dnli = xcalloc(1, sizeof(*dnli)); | dnli = (DNLI_t) xcalloc(1, sizeof(*dnli)); | |||
dnli->fi = fi; | dnli->fi = fi; | |||
dnli->reverse = reverse; | dnli->reverse = reverse; | |||
dnli->i = (int) (reverse ? fi->dc : 0); | dnli->i = (int) (reverse ? fi->dc : 0); | |||
if (fi->dc) { | if (fi->dc) { | |||
dnli->active = xcalloc(fi->dc, sizeof(*dnli->active)); | dnli->active = (char *) xcalloc(fi->dc, sizeof(*dnli->active)); | |||
/* Identify parent directories not skipped. */ | /* Identify parent directories not skipped. */ | |||
if ((fi = rpmfiInit(fi, 0)) != NULL) | if ((fi = rpmfiInit(fi, 0)) != NULL) | |||
while ((i = rpmfiNext(fi)) >= 0) { | while ((i = rpmfiNext(fi)) >= 0) { | |||
if (!iosmFileActionSkipped(fi->actions[i])) dnli->active[fi->di l[i]] = 1; | if (!iosmFileActionSkipped(fi->actions[i])) dnli->active[fi->di l[i]] = 1; | |||
} | } | |||
/* Exclude parent directories that are explicitly included. */ | /* Exclude parent directories that are explicitly included. */ | |||
if ((fi = rpmfiInit(fi, 0)) != NULL) | if ((fi = rpmfiInit(fi, 0)) != NULL) | |||
while ((i = rpmfiNext(fi)) >= 0) { | while ((i = rpmfiNext(fi)) >= 0) { | |||
skipping to change at line 419 | skipping to change at line 427 | |||
if (i >= 0 && i < (int)fi->dc) | if (i >= 0 && i < (int)fi->dc) | |||
dn = fi->dnl[i]; | dn = fi->dnl[i]; | |||
else | else | |||
i = -1; | i = -1; | |||
dnli->isave = i; | dnli->isave = i; | |||
} | } | |||
return dn; | return dn; | |||
} | } | |||
#if defined(WITH_PTHREADS) | #if defined(WITH_PTHREADS) | |||
static void * fsmThread(void * arg) | static void * fsmThread(void * _fsm) | |||
/*@globals h_errno, fileSystem, internalState @*/ | /*@globals h_errno, fileSystem, internalState @*/ | |||
/*@modifies arg, fileSystem, internalState @*/ | /*@modifies arg, fileSystem, internalState @*/ | |||
{ | { | |||
IOSM_t fsm = arg; | IOSM_t fsm = (IOSM_t) _fsm; | |||
/*@-unqualifiedtrans@*/ | /*@-unqualifiedtrans@*/ | |||
return ((void *) ((long)fsmStage(fsm, fsm->nstage))); | return ((void *) ((long)fsmStage(fsm, fsm->nstage))); | |||
/*@=unqualifiedtrans@*/ | /*@=unqualifiedtrans@*/ | |||
} | } | |||
#endif | #endif | |||
int fsmNext(IOSM_t fsm, iosmFileStage nstage) | int fsmNext(IOSM_t fsm, iosmFileStage nstage) | |||
/*@globals h_errno, fileSystem, internalState @*/ | /*@globals h_errno, fileSystem, internalState @*/ | |||
/*@modifies fsm, fileSystem, internalState @*/ | /*@modifies fsm, fileSystem, internalState @*/ | |||
{ | { | |||
skipping to change at line 467 | skipping to change at line 475 | |||
int j; | int j; | |||
/* Find hard link set. */ | /* Find hard link set. */ | |||
for (fsm->li = fsm->links; fsm->li; fsm->li = fsm->li->next) { | for (fsm->li = fsm->links; fsm->li; fsm->li = fsm->li->next) { | |||
if (fsm->li->sb.st_ino == st->st_ino && fsm->li->sb.st_dev == st->st _dev) | if (fsm->li->sb.st_ino == st->st_ino && fsm->li->sb.st_dev == st->st _dev) | |||
break; | break; | |||
} | } | |||
/* New hard link encountered, add new link to set. */ | /* New hard link encountered, add new link to set. */ | |||
if (fsm->li == NULL) { | if (fsm->li == NULL) { | |||
fsm->li = xcalloc(1, sizeof(*fsm->li)); | fsm->li = (struct hardLink_s *) xcalloc(1, sizeof(*fsm->li)); | |||
fsm->li->next = NULL; | fsm->li->next = NULL; | |||
fsm->li->sb = *st; /* structure assignment */ | fsm->li->sb = *st; /* structure assignment */ | |||
fsm->li->nlink = (int) st->st_nlink; | fsm->li->nlink = (int) st->st_nlink; | |||
fsm->li->linkIndex = fsm->ix; | fsm->li->linkIndex = fsm->ix; | |||
fsm->li->createdPath = -1; | fsm->li->createdPath = -1; | |||
fsm->li->filex = xcalloc(st->st_nlink, sizeof(fsm->li->filex[0])); | fsm->li->filex = (int *) xcalloc(st->st_nlink, sizeof(fsm->li->filex [0])); | |||
memset(fsm->li->filex, -1, (st->st_nlink * sizeof(fsm->li->filex[0]) )); | memset(fsm->li->filex, -1, (st->st_nlink * sizeof(fsm->li->filex[0]) )); | |||
fsm->li->nsuffix = xcalloc(st->st_nlink, sizeof(*fsm->li->nsuffix)); | fsm->li->nsuffix = (const char **) xcalloc(st->st_nlink, sizeof(*fsm ->li->nsuffix)); | |||
if (fsm->goal == IOSM_PKGBUILD) | if (fsm->goal == IOSM_PKGBUILD) | |||
fsm->li->linksLeft = (int) st->st_nlink; | fsm->li->linksLeft = (int) st->st_nlink; | |||
if (fsm->goal == IOSM_PKGINSTALL) | if (fsm->goal == IOSM_PKGINSTALL) | |||
fsm->li->linksLeft = 0; | fsm->li->linksLeft = 0; | |||
/*@-kepttrans@*/ | /*@-kepttrans@*/ | |||
fsm->li->next = fsm->links; | fsm->li->next = fsm->links; | |||
/*@=kepttrans@*/ | /*@=kepttrans@*/ | |||
fsm->links = fsm->li; | fsm->links = fsm->li; | |||
skipping to change at line 545 | skipping to change at line 553 | |||
{ | { | |||
if (li) { | if (li) { | |||
li->nsuffix = _free(li->nsuffix); /* XXX elements are shared * / | li->nsuffix = _free(li->nsuffix); /* XXX elements are shared * / | |||
li->filex = _free(li->filex); | li->filex = _free(li->filex); | |||
} | } | |||
return _free(li); | return _free(li); | |||
} | } | |||
IOSM_t newFSM(void) | IOSM_t newFSM(void) | |||
{ | { | |||
IOSM_t fsm = xcalloc(1, sizeof(*fsm)); | IOSM_t fsm = (IOSM_t) xcalloc(1, sizeof(*fsm)); | |||
return fsm; | return fsm; | |||
} | } | |||
IOSM_t freeFSM(IOSM_t fsm) | IOSM_t freeFSM(IOSM_t fsm) | |||
{ | { | |||
if (fsm) { | if (fsm) { | |||
fsm->path = _free(fsm->path); | fsm->path = _free(fsm->path); | |||
while ((fsm->li = fsm->links) != NULL) { | while ((fsm->li = fsm->links) != NULL) { | |||
fsm->links = fsm->li->next; | fsm->links = fsm->li->next; | |||
fsm->li->next = NULL; | fsm->li->next = NULL; | |||
fsm->li = freeHardLink(fsm->li); | fsm->li = freeHardLink((struct hardLink_s *)fsm->li); | |||
} | } | |||
fsm->dnlx = _free(fsm->dnlx); | fsm->dnlx = _free(fsm->dnlx); | |||
fsm->ldn = _free(fsm->ldn); | fsm->ldn = _free(fsm->ldn); | |||
fsm->iter = mapFreeIterator(fsm->iter); | fsm->iter = mapFreeIterator(fsm->iter); | |||
} | } | |||
return _free(fsm); | return _free(fsm); | |||
} | } | |||
#if defined(SUPPORT_AR_PAYLOADS) | #if defined(SUPPORT_AR_PAYLOADS) | |||
static int arSetup(IOSM_t fsm, rpmfi fi) | static int arSetup(IOSM_t fsm, rpmfi fi) | |||
skipping to change at line 595 | skipping to change at line 603 | |||
if ((nb = strlen(path)) < 15) | if ((nb = strlen(path)) < 15) | |||
continue; | continue; | |||
lmtablen += nb + 1; /* trailing \n */ | lmtablen += nb + 1; /* trailing \n */ | |||
} | } | |||
/* Anything to do? */ | /* Anything to do? */ | |||
if (lmtablen == 0) | if (lmtablen == 0) | |||
return 0; | return 0; | |||
/* Create and load ar(1) long member table. */ | /* Create and load ar(1) long member table. */ | |||
fsm->lmtab = t = xmalloc(lmtablen + 1); /* trailing \0 */ | fsm->lmtab = t = (char *) xmalloc(lmtablen + 1); /* trailing \0 */ | |||
fsm->lmtablen = lmtablen; | fsm->lmtablen = lmtablen; | |||
fsm->lmtaboff = 0; | fsm->lmtaboff = 0; | |||
if ((fi = rpmfiInit(fi, 0)) != NULL) | if ((fi = rpmfiInit(fi, 0)) != NULL) | |||
while (rpmfiNext(fi) >= 0) { | while (rpmfiNext(fi) >= 0) { | |||
#ifdef NOTYET | #ifdef NOTYET | |||
if (fi->apath) { | if (fi->apath) { | |||
const char * apath = NULL; | const char * apath = NULL; | |||
(void) urlPath(fi->apath[ix], &apath); | (void) urlPath(fi->apath[ix], &apath); | |||
path = apath + fi->striplen; | path = apath + fi->striplen; | |||
} else | } else | |||
skipping to change at line 623 | skipping to change at line 631 | |||
*t = '\0'; | *t = '\0'; | |||
return 0; | return 0; | |||
} | } | |||
#endif | #endif | |||
int fsmSetup(void * _fsm, iosmFileStage goal, const char * afmt, | int fsmSetup(void * _fsm, iosmFileStage goal, const char * afmt, | |||
const void * _ts, const void * _fi, FD_t cfd, | const void * _ts, const void * _fi, FD_t cfd, | |||
unsigned int * archiveSize, const char ** failedFile) | unsigned int * archiveSize, const char ** failedFile) | |||
{ | { | |||
IOSM_t fsm = _fsm; | IOSM_t fsm = (IOSM_t) _fsm; | |||
/*@-castexpose@*/ | /*@-castexpose@*/ | |||
const rpmts ts = (const rpmts) _ts; | const rpmts ts = (const rpmts) _ts; | |||
const rpmfi fi = (const rpmfi) _fi; | const rpmfi fi = (const rpmfi) _fi; | |||
/*@=castexpose@*/ | /*@=castexpose@*/ | |||
#if defined(_USE_RPMTE) | #if defined(_USE_RPMTE) | |||
int reverse = (rpmteType(fi->te) == TR_REMOVED && fi->action != FA_COPY OUT); | int reverse = (rpmteType(fi->te) == TR_REMOVED && fi->action != FA_COPY OUT); | |||
int adding = (rpmteType(fi->te) == TR_ADDED); | int adding = (rpmteType(fi->te) == TR_ADDED); | |||
#else | #else | |||
int reverse = 0; /* XXX HACK: devise alternative means */ | int reverse = 0; /* XXX HACK: devise alternative means */ | |||
int adding = 1; /* XXX HACK: devise alternative means */ | int adding = 1; /* XXX HACK: devise alternative means */ | |||
skipping to change at line 745 | skipping to change at line 753 | |||
if (fsm->archiveSize && ec == 0) | if (fsm->archiveSize && ec == 0) | |||
*fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos); | *fsm->archiveSize = (fdGetCpioPos(fsm->cfd) - pos); | |||
/*@-nullstate@*/ /* FIX: *fsm->failedFile may be NULL */ | /*@-nullstate@*/ /* FIX: *fsm->failedFile may be NULL */ | |||
return ec; | return ec; | |||
/*@=nullstate@*/ | /*@=nullstate@*/ | |||
} | } | |||
int fsmTeardown(void * _fsm) | int fsmTeardown(void * _fsm) | |||
{ | { | |||
IOSM_t fsm = _fsm; | IOSM_t fsm = (IOSM_t) _fsm; | |||
int rc = fsm->rc; | int rc = fsm->rc; | |||
if (fsm->debug < 0) | if (fsm->debug < 0) | |||
fprintf(stderr, "--> fsmTeardown(%p)\n", fsm); | fprintf(stderr, "--> fsmTeardown(%p)\n", fsm); | |||
if (!rc) | if (!rc) | |||
rc = fsmUNSAFE(fsm, IOSM_DESTROY); | rc = fsmUNSAFE(fsm, IOSM_DESTROY); | |||
(void) rpmswAdd(rpmtsOp(fsmGetTs(fsm), RPMTS_OP_DIGEST), | (void) rpmswAdd(rpmtsOp(fsmGetTs(fsm), RPMTS_OP_DIGEST), | |||
&fsm->op_digest); | &fsm->op_digest); | |||
skipping to change at line 899 | skipping to change at line 907 | |||
int i = fsm->ix; | int i = fsm->ix; | |||
if (fi && i >= 0 && i < (int) fi->fc) { | if (fi && i >= 0 && i < (int) fi->fc) { | |||
mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms); | mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms); | |||
mode_t finalMode = (fi->fmodes ? (mode_t)fi->fmodes[i] : perms); | mode_t finalMode = (fi->fmodes ? (mode_t)fi->fmodes[i] : perms); | |||
dev_t finalRdev = (dev_t)(fi->frdevs ? fi->frdevs[i] : 0); | dev_t finalRdev = (dev_t)(fi->frdevs ? fi->frdevs[i] : 0); | |||
rpmuint32_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0); | rpmuint32_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0); | |||
uid_t uid = fi->uid; | uid_t uid = fi->uid; | |||
gid_t gid = fi->gid; | gid_t gid = fi->gid; | |||
#if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined( RPM_VENDOR_ARK) /* no-owner-group-on-srpm-install */ | ||||
/* Make sure OpenPKG/Mandriva RPM does not try to set file owner/gro up on files during | /* Make sure OpenPKG/Mandriva RPM does not try to set file owner/gro up on files during | |||
installation of _source_ RPMs. Instead, let it use the current | installation of _source_ RPMs. Instead, let it use the current | |||
run-time owner/group, because most of the time the owner/group in | run-time owner/group, because most of the time the owner/group in | |||
the source RPM (which is the owner/group of the files as staying on | the source RPM (which is the owner/group of the files as staying on | |||
the package author system) is not existing on the target system, of | the package author system) is not existing on the target system, of | |||
course. */ | course. */ | |||
#endif | ||||
if (fi->fuser && unameToUid(fi->fuser[i], &uid)) { | if (fi->fuser && unameToUid(fi->fuser[i], &uid)) { | |||
#if defined(RPM_VENDOR_OPENPKG) ||defined(RPM_VENDOR_MANDRIVA) || defined(R PM_VENDOR_ARK) /* no-owner-group-on-srpm-install */ | ||||
if (!fi->isSource) { | if (!fi->isSource) { | |||
#endif | ||||
if (fsm->goal == IOSM_PKGINSTALL) | if (fsm->goal == IOSM_PKGINSTALL) | |||
rpmlog(RPMLOG_WARNING, | rpmlog(RPMLOG_WARNING, | |||
_("user %s does not exist - using root\n"), fi->fuser[i] ); | _("user %s does not exist - using root\n"), fi->fuser[i] ); | |||
uid = 0; | uid = 0; | |||
finalMode &= ~S_ISUID; /* turn off suid bit */ | finalMode &= ~S_ISUID; /* turn off suid bit */ | |||
#if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined( RPM_VENDOR_ARK) /* no-owner-group-on-srpm-install */ | ||||
} | } | |||
#endif | ||||
} | } | |||
if (fi->fgroup && gnameToGid(fi->fgroup[i], &gid)) { | if (fi->fgroup && gnameToGid(fi->fgroup[i], &gid)) { | |||
#if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined( RPM_VENDOR_ARK) /* no-owner-group-on-srpm-install */ | ||||
if (!fi->isSource) { | if (!fi->isSource) { | |||
#endif | ||||
if (fsm->goal == IOSM_PKGINSTALL) | if (fsm->goal == IOSM_PKGINSTALL) | |||
rpmlog(RPMLOG_WARNING, | rpmlog(RPMLOG_WARNING, | |||
_("group %s does not exist - using root\n"), fi->fgroup[ i]); | _("group %s does not exist - using root\n"), fi->fgroup[ i]); | |||
gid = 0; | gid = 0; | |||
finalMode &= ~S_ISGID; /* turn off sgid bit */ | finalMode &= ~S_ISGID; /* turn off sgid bit */ | |||
#if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined (RPM_VENDOR_ARK) /* no-owner-group-on-srpm-install */ | ||||
} | } | |||
#endif | ||||
} | } | |||
if (fsm->mapFlags & IOSM_MAP_MODE) | if (fsm->mapFlags & IOSM_MAP_MODE) | |||
st->st_mode = (st->st_mode & S_IFMT) | (finalMode & ~S_IFMT); | st->st_mode = (st->st_mode & S_IFMT) | (finalMode & ~S_IFMT); | |||
if (fsm->mapFlags & IOSM_MAP_TYPE) { | if (fsm->mapFlags & IOSM_MAP_TYPE) { | |||
st->st_mode = (st->st_mode & ~S_IFMT) | (finalMode & S_IFMT); | st->st_mode = (st->st_mode & ~S_IFMT) | (finalMode & S_IFMT); | |||
if ((S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) | if ((S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) | |||
&& st->st_nlink == 0) | && st->st_nlink == 0) | |||
st->st_nlink = 1; | st->st_nlink = 1; | |||
st->st_rdev = finalRdev; | st->st_rdev = finalRdev; | |||
skipping to change at line 1099 | skipping to change at line 1097 | |||
*/ | */ | |||
/* XXX NUL terminated result in fsm->rdbuf, len in fsm->rdnb. */ | /* XXX NUL terminated result in fsm->rdbuf, len in fsm->rdnb. */ | |||
rc = fsmUNSAFE(fsm, IOSM_READLINK); | rc = fsmUNSAFE(fsm, IOSM_READLINK); | |||
if (rc) goto exit; | if (rc) goto exit; | |||
st->st_size = fsm->rdnb; | st->st_size = fsm->rdnb; | |||
fsm->lpath = xstrdup(fsm->rdbuf); /* XXX save readlink return. */ | fsm->lpath = xstrdup(fsm->rdbuf); /* XXX save readlink return. */ | |||
} | } | |||
if (fsm->mapFlags & IOSM_MAP_ABSOLUTE) { | if (fsm->mapFlags & IOSM_MAP_ABSOLUTE) { | |||
size_t nb= strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof("." ); | size_t nb= strlen(fsm->dirName) + strlen(fsm->baseName) + sizeof("." ); | |||
char * t = alloca(nb); | char * t = (char *) alloca(nb); | |||
*t = '\0'; | *t = '\0'; | |||
fsm->path = t; | fsm->path = t; | |||
if (fsm->mapFlags & IOSM_MAP_ADDDOT) | if (fsm->mapFlags & IOSM_MAP_ADDDOT) | |||
*t++ = '.'; | *t++ = '.'; | |||
t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName); | t = stpcpy( stpcpy(t, fsm->dirName), fsm->baseName); | |||
} else if (fsm->mapFlags & IOSM_MAP_PATH) { | } else if (fsm->mapFlags & IOSM_MAP_PATH) { | |||
rpmfi fi = fsmGetFi(fsm); | rpmfi fi = fsmGetFi(fsm); | |||
if (fi->apath) { | if (fi->apath) { | |||
const char * apath = NULL; | const char * apath = NULL; | |||
(void) urlPath(fi->apath[fsm->ix], &apath); | (void) urlPath(fi->apath[fsm->ix], &apath); | |||
skipping to change at line 1239 | skipping to change at line 1237 | |||
rc = fsmNext(fsm, IOSM_MAP); | rc = fsmNext(fsm, IOSM_MAP); | |||
/*@=compdef@*/ | /*@=compdef@*/ | |||
/* XXX tar and cpio have to do things differently. */ | /* XXX tar and cpio have to do things differently. */ | |||
if (fsm->headerWrite == tarHeaderWrite) { | if (fsm->headerWrite == tarHeaderWrite) { | |||
if (firstfile) { | if (firstfile) { | |||
const char * apath = NULL; | const char * apath = NULL; | |||
char *t; | char *t; | |||
(void) urlPath(fsm->path, &apath); | (void) urlPath(fsm->path, &apath); | |||
/* Remove the buildroot prefix. */ | /* Remove the buildroot prefix. */ | |||
t = xmalloc(sizeof(".") + strlen(apath + fsm->astriplen)); | t = (char *) xmalloc(sizeof(".") + strlen(apath + fsm->astri plen)); | |||
(void) stpcpy( stpcpy(t, "."), apath + fsm->astriplen); | (void) stpcpy( stpcpy(t, "."), apath + fsm->astriplen); | |||
linkpath = t; | linkpath = t; | |||
firstfile = 0; | firstfile = 0; | |||
} else | } else | |||
fsm->lpath = linkpath; | fsm->lpath = linkpath; | |||
/* Write data after first link for tar. */ | /* Write data after first link for tar. */ | |||
rc = writeFile(fsm, (fsm->lpath == NULL)); | rc = writeFile(fsm, (fsm->lpath == NULL)); | |||
} else { | } else { | |||
/* Write data after last link for cpio. */ | /* Write data after last link for cpio. */ | |||
skipping to change at line 1457 | skipping to change at line 1455 | |||
mode_t st_mode = st->st_mode; | mode_t st_mode = st->st_mode; | |||
void * dnli = dnlInitIterator(fsm, 0); | void * dnli = dnlInitIterator(fsm, 0); | |||
char * dn = fsm->rdbuf; | char * dn = fsm->rdbuf; | |||
int dc = dnlCount(dnli); | int dc = dnlCount(dnli); | |||
int rc = 0; | int rc = 0; | |||
size_t i; | size_t i; | |||
fsm->path = NULL; | fsm->path = NULL; | |||
dn[0] = '\0'; | dn[0] = '\0'; | |||
fsm->dnlx = (dc ? xcalloc(dc, sizeof(*fsm->dnlx)) : NULL); | fsm->dnlx = (unsigned short *) (dc ? xcalloc(dc, sizeof(*fsm->dnlx)) : NULL); | |||
/*@-observertrans -dependenttrans@*/ | /*@-observertrans -dependenttrans@*/ | |||
if (fsm->dnlx != NULL) | if (fsm->dnlx != NULL) | |||
while ((fsm->path = dnlNextIterator(dnli)) != NULL) { | while ((fsm->path = dnlNextIterator(dnli)) != NULL) { | |||
size_t dnlen = strlen(fsm->path); | size_t dnlen = strlen(fsm->path); | |||
char * te; | char * te; | |||
dc = dnlIndex(dnli); | dc = dnlIndex(dnli); | |||
if (dc < 0) continue; | if (dc < 0) continue; | |||
fsm->dnlx[dc] = (unsigned short) dnlen; | fsm->dnlx[dc] = (unsigned short) dnlen; | |||
if (dnlen <= 1) | if (dnlen <= 1) | |||
skipping to change at line 1540 | skipping to change at line 1538 | |||
} | } | |||
if (rc) | if (rc) | |||
/*@innerbreak@*/ break; | /*@innerbreak@*/ break; | |||
} | } | |||
if (rc) break; | if (rc) break; | |||
/* Save last validated path. */ | /* Save last validated path. */ | |||
/*@-compdef@*/ /* FIX: ldn/path annotations ? */ | /*@-compdef@*/ /* FIX: ldn/path annotations ? */ | |||
if (fsm->ldnalloc < (dnlen + 1)) { | if (fsm->ldnalloc < (dnlen + 1)) { | |||
fsm->ldnalloc = dnlen + 100; | fsm->ldnalloc = dnlen + 100; | |||
fsm->ldn = xrealloc(fsm->ldn, fsm->ldnalloc); | fsm->ldn = (char *) xrealloc(fsm->ldn, fsm->ldnalloc); | |||
} | } | |||
if (fsm->ldn != NULL) { /* XXX can't happen */ | if (fsm->ldn != NULL) { /* XXX can't happen */ | |||
strcpy(fsm->ldn, fsm->path); | strcpy(fsm->ldn, fsm->path); | |||
fsm->ldnlen = dnlen; | fsm->ldnlen = dnlen; | |||
} | } | |||
/*@=compdef@*/ | /*@=compdef@*/ | |||
} | } | |||
dnli = dnlFreeIterator(dnli); | dnli = dnlFreeIterator(dnli); | |||
/*@=observertrans =dependenttrans@*/ | /*@=observertrans =dependenttrans@*/ | |||
skipping to change at line 1772 | skipping to change at line 1770 | |||
fsm->dnlx = _free(fsm->dnlx); | fsm->dnlx = _free(fsm->dnlx); | |||
fsm->ldn = _free(fsm->ldn); | fsm->ldn = _free(fsm->ldn); | |||
fsm->ldnalloc = fsm->ldnlen = 0; | fsm->ldnalloc = fsm->ldnlen = 0; | |||
fsm->rdsize = fsm->wrsize = 0; | fsm->rdsize = fsm->wrsize = 0; | |||
fsm->rdbuf = fsm->rdb = _free(fsm->rdb); | fsm->rdbuf = fsm->rdb = _free(fsm->rdb); | |||
fsm->wrbuf = fsm->wrb = _free(fsm->wrb); | fsm->wrbuf = fsm->wrb = _free(fsm->wrb); | |||
if (fsm->goal == IOSM_PKGINSTALL || fsm->goal == IOSM_PKGBUILD) { | if (fsm->goal == IOSM_PKGINSTALL || fsm->goal == IOSM_PKGBUILD) { | |||
fsm->rdsize = 16 * BUFSIZ; | fsm->rdsize = 16 * BUFSIZ; | |||
fsm->rdbuf = fsm->rdb = xmalloc(fsm->rdsize); | fsm->rdbuf = fsm->rdb = (char *) xmalloc(fsm->rdsize); | |||
fsm->wrsize = 16 * BUFSIZ; | fsm->wrsize = 16 * BUFSIZ; | |||
fsm->wrbuf = fsm->wrb = xmalloc(fsm->wrsize); | fsm->wrbuf = fsm->wrb = (char *) xmalloc(fsm->wrsize); | |||
} | } | |||
fsm->mkdirsdone = 0; | fsm->mkdirsdone = 0; | |||
fsm->ix = -1; | fsm->ix = -1; | |||
fsm->links = NULL; | fsm->links = NULL; | |||
fsm->li = NULL; | fsm->li = NULL; | |||
errno = 0; /* XXX get rid of EBADF */ | errno = 0; /* XXX get rid of EBADF */ | |||
/* Detect and create directories not explicitly in package. */ | /* Detect and create directories not explicitly in package. */ | |||
if (fsm->goal == IOSM_PKGINSTALL) { | if (fsm->goal == IOSM_PKGINSTALL) { | |||
skipping to change at line 1938 | skipping to change at line 1936 | |||
rc = writeFile(fsm, 1); | rc = writeFile(fsm, 1); | |||
} | } | |||
break; | break; | |||
} | } | |||
if (fsm->goal != IOSM_PKGINSTALL) | if (fsm->goal != IOSM_PKGINSTALL) | |||
break; | break; | |||
if (S_ISREG(st->st_mode) && fsm->lpath != NULL) { | if (S_ISREG(st->st_mode) && fsm->lpath != NULL) { | |||
const char * opath = fsm->opath; | const char * opath = fsm->opath; | |||
char * t = xmalloc(strlen(fsm->lpath+1) + strlen(fsm->suffix) + 1); | char * t = (char *) xmalloc(strlen(fsm->lpath+1) + strlen(fsm->s uffix) + 1); | |||
(void) stpcpy(t, fsm->lpath+1); | (void) stpcpy(t, fsm->lpath+1); | |||
fsm->opath = t; | fsm->opath = t; | |||
/* XXX link(fsm->opath, fsm->path) */ | /* XXX link(fsm->opath, fsm->path) */ | |||
rc = fsmNext(fsm, IOSM_LINK); | rc = fsmNext(fsm, IOSM_LINK); | |||
if (fsm->failedFile && rc != 0 && *fsm->failedFile == NULL) { | if (fsm->failedFile && rc != 0 && *fsm->failedFile == NULL) { | |||
*fsm->failedFile = xstrdup(fsm->path); | *fsm->failedFile = xstrdup(fsm->path); | |||
} | } | |||
fsm->opath = _free(fsm->opath); | fsm->opath = _free(fsm->opath); | |||
fsm->opath = opath; | fsm->opath = opath; | |||
break; /* XXX so that delayed hard links get skipped. */ | break; /* XXX so that delayed hard links get skipped. */ | |||
skipping to change at line 2243 | skipping to change at line 2241 | |||
fsm->ldnalloc = fsm->ldnlen = 0; | fsm->ldnalloc = fsm->ldnlen = 0; | |||
fsm->rdbuf = fsm->rdb = _free(fsm->rdb); | fsm->rdbuf = fsm->rdb = _free(fsm->rdb); | |||
fsm->wrbuf = fsm->wrb = _free(fsm->wrb); | fsm->wrbuf = fsm->wrb = _free(fsm->wrb); | |||
break; | break; | |||
case IOSM_VERIFY: | case IOSM_VERIFY: | |||
if (fsm->diskchecked && !fsm->exists) { | if (fsm->diskchecked && !fsm->exists) { | |||
rc = IOSMERR_ENOENT; | rc = IOSMERR_ENOENT; | |||
break; | break; | |||
} | } | |||
if (S_ISREG(st->st_mode)) { | if (S_ISREG(st->st_mode)) { | |||
char * path = alloca(strlen(fsm->path) + sizeof("-RPMDELETE")); | char * path = (char *) alloca(strlen(fsm->path) + sizeof("-RPMDE LETE")); | |||
(void) stpcpy( stpcpy(path, fsm->path), "-RPMDELETE"); | (void) stpcpy( stpcpy(path, fsm->path), "-RPMDELETE"); | |||
/* | /* | |||
* XXX HP-UX (and other os'es) don't permit unlink on busy | * XXX HP-UX (and other os'es) don't permit unlink on busy | |||
* XXX files. | * XXX files. | |||
*/ | */ | |||
fsm->opath = fsm->path; | fsm->opath = fsm->path; | |||
fsm->path = path; | fsm->path = path; | |||
rc = fsmNext(fsm, IOSM_RENAME); | rc = fsmNext(fsm, IOSM_RENAME); | |||
if (!rc) | if (!rc) | |||
(void) fsmNext(fsm, IOSM_UNLINK); | (void) fsmNext(fsm, IOSM_UNLINK); | |||
End of changes. 49 change blocks. | ||||
51 lines changed or deleted | 50 lines changed or added | |||
This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/ |