iosm.c   iosm.c 
skipping to change at line 64 skipping to change at line 64
#endif #endif
#include "debug.h" #include "debug.h"
/*@access FD_t @*/ /* XXX void ptr args */ /*@access FD_t @*/ /* XXX void ptr args */
/*@access IOSMI_t @*/ /*@access IOSMI_t @*/
/*@access IOSM_t @*/ /*@access IOSM_t @*/
/*@access rpmfi @*/ /*@access rpmfi @*/
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) #ifdef __cplusplus
GENfree(unsigned short *)
GENfree(int *)
GENfree(IOSM_t)
GENfree(iosmFileAction *)
#endif /* __cplusplus */
#define alloca_strdup(_s) strcpy((char *)alloca(strlen(_s)+1),
(_s))
#define _IOSM_DEBUG 0 #define _IOSM_DEBUG 0
/*@unchecked@*/ /*@unchecked@*/
int _iosm_debug = _IOSM_DEBUG; int _iosm_debug = _IOSM_DEBUG;
/*@-exportheadervar@*/ /*@-exportheadervar@*/
/*@unchecked@*/ /*@unchecked@*/
int _iosm_threads = 0; int _iosm_threads = 0;
/*@=exportheadervar@*/ /*@=exportheadervar@*/
skipping to change at line 127 skipping to change at line 134
{ {
const char * s = NULL; const char * s = NULL;
if (iosm) { if (iosm) {
char * t; char * t;
int nb; int nb;
nb = strlen(iosm->dirName) + nb = strlen(iosm->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(iosm->baseName) + 1; strlen(iosm->baseName) + 1;
s = t = xmalloc(nb); s = t = (char *) xmalloc(nb);
t = stpcpy(t, iosm->dirName); t = stpcpy(t, iosm->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, iosm->baseName); t = stpcpy(t, iosm->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)
/*@modifies p @*/ /*@modifies p @*/
{ {
IOSMI_t iter = p; IOSMI_t iter = (IOSMI_t) _iter;
if (iter) { if (iter) {
#if !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
iter->fi = rpmfiUnlink(iter->fi, "mapIterator"); iter->fi = rpmfiUnlink(iter->fi, "mapIterator");
#endif #endif
iter->fi = NULL; iter->fi = NULL;
} }
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
*/ */
/*@-mustmod@*/ /*@-mustmod@*/
static void * static void *
mapInitIterator(rpmfi fi, int reverse) mapInitIterator(rpmfi fi, int reverse)
/*@modifies fi @*/ /*@modifies fi @*/
{ {
IOSMI_t iter = NULL; IOSMI_t iter = NULL;
iter = xcalloc(1, sizeof(*iter)); iter = (IOSMI_t) xcalloc(1, sizeof(*iter));
#if !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
iter->fi = rpmfiLink(fi, "mapIterator"); iter->fi = rpmfiLink(fi, "mapIterator");
#else #else
/*@i@*/ iter->fi = fi; /*@i@*/ iter->fi = fi;
#endif #endif
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;
} }
/*@=mustmod@*/ /*@=mustmod@*/
/** \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)
/*@*/ /*@*/
{ {
IOSMI_t iter = a; IOSMI_t iter = (IOSMI_t) _iter;
int i = -1; int i = -1;
if (iter) { if (iter) {
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) ((rpmfi)iter->fi)->fc) i = iter->i++; if (iter->i < (int) ((rpmfi)iter->fi)->fc) i = iter->i++;
} }
iter->isave = i; iter->isave = i;
} }
skipping to change at line 247 skipping to change at line 254
* @param iosmPath archive path * @param iosmPath 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@*/ IOSMI_t iter, const char * iosmPath) static int mapFind(/*@null@*/ IOSMI_t iter, const char * iosmPath)
/*@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@*/
#if !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
size_t fc = rpmfiFC(fi); size_t fc = rpmfiFC(fi);
#else #else
size_t fc = (fi ? fi->fc : 0); size_t fc = (fi ? fi->fc : 0);
#endif #endif
if (fi && fc > 0 && fi->apath && iosmPath && *iosmPath) { if (fi && fc > 0 && fi->apath && iosmPath && *iosmPath) {
const char ** p = NULL; const char ** p = NULL;
if (fi->apath != NULL) if (fi->apath != NULL)
p = bsearch(&iosmPath, fi->apath, fc, sizeof(iosmPath), p = (const char **)
iosmStrCmp); bsearch(&iosmPath, fi->apath, fc, sizeof(iosmPath),
iosmStrCmp);
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 283 skipping to change at line 291
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 * static /*@null@*/ void * dnlFreeIterator(/*@only@*//*@null@*/ const void *
a) _dnli)
/*@modifies a @*/ /*@modifies _dnli @*/
{ {
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((void *)_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 325 skipping to change at line 333
* @param reverse traverse directory names in reverse order? * @param reverse traverse directory names in reverse order?
* @return directory name iterator * @return directory name iterator
*/ */
/*@-usereleased@*/ /*@-usereleased@*/
static /*@only@*/ /*@null@*/ static /*@only@*/ /*@null@*/
void * dnlInitIterator(/*@special@*/ const IOSM_t iosm, void * dnlInitIterator(/*@special@*/ const IOSM_t iosm,
int reverse) int reverse)
/*@uses iosm->iter @*/ /*@uses iosm->iter @*/
/*@*/ /*@*/
{ {
rpmfi fi = iosmGetFi(iosm); rpmfi fi = (rpmfi) iosmGetFi(iosm);
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 !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
if ((fi = rpmfiInit(fi, 0)) != NULL) if ((fi = rpmfiInit(fi, 0)) != NULL)
while ((i = rpmfiNext(fi)) >= 0) while ((i = rpmfiNext(fi)) >= 0)
#else #else
for (i = 0; i < (int)fi->fc; i++) for (i = 0; i < (int)fi->fc; i++)
#endif #endif
{ {
if (!iosmFileActionSkipped(fi->actions[i])) if (!iosmFileActionSkipped((iosmFileAction)fi->actions[i]))
dnli->active[fi->dil[i]] = (char)1; dnli->active[fi->dil[i]] = (char)1;
} }
/* Exclude parent directories that are explicitly included. */ /* Exclude parent directories that are explicitly included. */
#if !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
if ((fi = rpmfiInit(fi, 0)) != NULL) if ((fi = rpmfiInit(fi, 0)) != NULL)
while ((i = rpmfiNext(fi)) >= 0) while ((i = rpmfiNext(fi)) >= 0)
#else #else
for (i = 0; i < (int)fi->fc; i++) for (i = 0; i < (int)fi->fc; i++)
#endif #endif
skipping to change at line 442 skipping to change at line 450
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 * iosmThread(void * arg) static void * iosmThread(void * _iosm)
/*@globals h_errno, fileSystem, internalState @*/ /*@globals h_errno, fileSystem, internalState @*/
/*@modifies arg, fileSystem, internalState @*/ /*@modifies _iosm, fileSystem, internalState @*/
{ {
IOSM_t iosm = arg; IOSM_t iosm = (IOSM_t) _iosm;
/*@-unqualifiedtrans@*/ /*@-unqualifiedtrans@*/
return ((void *) ((long)iosmStage(iosm, iosm->nstage))); return ((void *) ((long)iosmStage(iosm, iosm->nstage)));
/*@=unqualifiedtrans@*/ /*@=unqualifiedtrans@*/
} }
#endif #endif
int iosmNext(IOSM_t iosm, iosmFileStage nstage) int iosmNext(IOSM_t iosm, iosmFileStage nstage)
/*@globals h_errno, fileSystem, internalState @*/ /*@globals h_errno, fileSystem, internalState @*/
/*@modifies iosm, fileSystem, internalState @*/ /*@modifies iosm, fileSystem, internalState @*/
{ {
skipping to change at line 490 skipping to change at line 498
int j; int j;
/* Find hard link set. */ /* Find hard link set. */
for (iosm->li = iosm->links; iosm->li; iosm->li = iosm->li->next) { for (iosm->li = iosm->links; iosm->li; iosm->li = iosm->li->next) {
if (iosm->li->sb.st_ino == st->st_ino && iosm->li->sb.st_dev == st-> st_dev) if (iosm->li->sb.st_ino == st->st_ino && iosm->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 (iosm->li == NULL) { if (iosm->li == NULL) {
iosm->li = xcalloc(1, sizeof(*iosm->li)); iosm->li = (struct hardLink_s *) xcalloc(1, sizeof(*iosm->li));
iosm->li->next = NULL; iosm->li->next = NULL;
iosm->li->sb = *st; /* structure assignment */ iosm->li->sb = *st; /* structure assignment */
iosm->li->nlink = (int) st->st_nlink; iosm->li->nlink = (int) st->st_nlink;
iosm->li->linkIndex = iosm->ix; iosm->li->linkIndex = iosm->ix;
iosm->li->createdPath = -1; iosm->li->createdPath = -1;
iosm->li->filex = xcalloc(st->st_nlink, sizeof(iosm->li->filex[0])); iosm->li->filex = (int *) xcalloc(st->st_nlink, sizeof(iosm->li->fil ex[0]));
memset(iosm->li->filex, -1, (st->st_nlink * sizeof(iosm->li->filex[0 ]))); memset(iosm->li->filex, -1, (st->st_nlink * sizeof(iosm->li->filex[0 ])));
iosm->li->nsuffix = xcalloc(st->st_nlink, sizeof(*iosm->li->nsuffix) ); iosm->li->nsuffix = (const char **) xcalloc(st->st_nlink, sizeof(*io sm->li->nsuffix));
if (iosm->goal == IOSM_PKGBUILD) if (iosm->goal == IOSM_PKGBUILD)
iosm->li->linksLeft = (int) st->st_nlink; iosm->li->linksLeft = (int) st->st_nlink;
if (iosm->goal == IOSM_PKGINSTALL) if (iosm->goal == IOSM_PKGINSTALL)
iosm->li->linksLeft = 0; iosm->li->linksLeft = 0;
/*@-kepttrans@*/ /*@-kepttrans@*/
iosm->li->next = iosm->links; iosm->li->next = iosm->links;
/*@=kepttrans@*/ /*@=kepttrans@*/
iosm->links = iosm->li; iosm->links = iosm->li;
skipping to change at line 529 skipping to change at line 537
if (iosm->goal == IOSM_PKGBUILD) if (iosm->goal == IOSM_PKGBUILD)
return (iosm->li->linksLeft > 0); return (iosm->li->linksLeft > 0);
if (iosm->goal != IOSM_PKGINSTALL) if (iosm->goal != IOSM_PKGINSTALL)
return 0; return 0;
if (!(st->st_size || iosm->li->linksLeft == (int) st->st_nlink)) if (!(st->st_size || iosm->li->linksLeft == (int) st->st_nlink))
return 1; return 1;
/* Here come the bits, time to choose a non-skipped file name. */ /* Here come the bits, time to choose a non-skipped file name. */
{ rpmfi fi = iosmGetFi(iosm); { rpmfi fi = (rpmfi) iosmGetFi(iosm);
for (j = iosm->li->linksLeft - 1; j >= 0; j--) { for (j = iosm->li->linksLeft - 1; j >= 0; j--) {
ix = iosm->li->filex[j]; ix = iosm->li->filex[j];
if (ix < 0 || iosmFileActionSkipped(fi->actions[ix])) if (ix < 0 || iosmFileActionSkipped((iosmFileAction)fi->actions[ ix]))
continue; continue;
break; break;
} }
} }
/* Are all links skipped or not encountered yet? */ /* Are all links skipped or not encountered yet? */
if (ix < 0 || j < 0) if (ix < 0 || j < 0)
return 1; /* XXX W2DO? */ return 1; /* XXX W2DO? */
/* Save the non-skipped file name and map index. */ /* Save the non-skipped file name and map index. */
skipping to change at line 568 skipping to change at line 576
{ {
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 newIOSM(void) IOSM_t newIOSM(void)
{ {
IOSM_t iosm = xcalloc(1, sizeof(*iosm)); IOSM_t iosm = (IOSM_t) xcalloc(1, sizeof(*iosm));
return iosm; return iosm;
} }
IOSM_t freeIOSM(IOSM_t iosm) IOSM_t freeIOSM(IOSM_t iosm)
{ {
if (iosm) { if (iosm) {
iosm->path = _free(iosm->path); iosm->path = _free(iosm->path);
while ((iosm->li = iosm->links) != NULL) { while ((iosm->li = iosm->links) != NULL) {
iosm->links = iosm->li->next; iosm->links = iosm->li->next;
iosm->li->next = NULL; iosm->li->next = NULL;
iosm->li = freeHardLink(iosm->li); iosm->li = (struct hardLink_s *) freeHardLink((struct hardLink_s *) iosm->li);
} }
iosm->dnlx = _free(iosm->dnlx); iosm->dnlx = _free(iosm->dnlx);
iosm->ldn = _free(iosm->ldn); iosm->ldn = _free(iosm->ldn);
iosm->iter = mapFreeIterator(iosm->iter); iosm->iter = (IOSMI_t) mapFreeIterator((IOSMI_t)iosm->iter);
} }
return _free(iosm); return _free(iosm);
} }
static int arSetup(IOSM_t iosm, rpmfi fi) static int arSetup(IOSM_t iosm, rpmfi fi)
/*@modifies iosm @*/ /*@modifies iosm @*/
{ {
const char * path; const char * path;
char * t; char * t;
size_t lmtablen = 0; size_t lmtablen = 0;
skipping to change at line 628 skipping to change at line 636
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. */
iosm->lmtab = t = xmalloc(lmtablen + 1); /* trailing \0 */ iosm->lmtab = t = (char *) xmalloc(lmtablen + 1); /* trailing \0 */
iosm->lmtablen = lmtablen; iosm->lmtablen = lmtablen;
iosm->lmtaboff = 0; iosm->lmtaboff = 0;
#if !defined(_RPMFI_NOMETHODS) #if !defined(_RPMFI_NOMETHODS)
if ((fi = rpmfiInit(fi, 0)) != NULL) if ((fi = rpmfiInit(fi, 0)) != NULL)
while (rpmfiNext(fi) >= 0) while (rpmfiNext(fi) >= 0)
#else #else
if (fi != NULL) if (fi != NULL)
for (i = 0; i < (int)fi->fc; i++) for (i = 0; i < (int)fi->fc; i++)
#endif #endif
{ {
skipping to change at line 727 skipping to change at line 735
iosm->goal = goal; iosm->goal = goal;
if (cfd != NULL) { if (cfd != NULL) {
/*@-assignexpose@*/ /*@-assignexpose@*/
iosm->cfd = fdLink(cfd, "persist (iosm)"); iosm->cfd = fdLink(cfd, "persist (iosm)");
/*@=assignexpose@*/ /*@=assignexpose@*/
pos = fdGetCpioPos(iosm->cfd); pos = fdGetCpioPos(iosm->cfd);
fdSetCpioPos(iosm->cfd, 0); fdSetCpioPos(iosm->cfd, 0);
} }
/*@-mods@*/ /* WTF? */ /*@-mods@*/ /* WTF? */
iosm->iter = mapInitIterator(fi, reverse); iosm->iter = (IOSMI_t) mapInitIterator(fi, reverse);
/*@=mods@*/ /*@=mods@*/
#if defined(_USE_RPMTS) #if defined(_USE_RPMTS)
iosm->iter->ts = rpmtsLink(ts, "mapIterator"); iosm->iter->ts = rpmtsLink(ts, "mapIterator");
iosm->nofcontexts = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS); iosm->nofcontexts = (rpmtsFlags(ts) & RPMTRANS_FLAG_NOCONTEXTS);
iosm->nofdigests = iosm->nofdigests =
(ts != NULL && !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOFDIGESTS)) (ts != NULL && !(rpmtsFlags(ts) & RPMTRANS_FLAG_NOFDIGESTS))
? 0 : 1; ? 0 : 1;
#define _tsmask (RPMTRANS_FLAG_PKGCOMMIT | RPMTRANS_FLAG_COMMIT) #define _tsmask (RPMTRANS_FLAG_PKGCOMMIT | RPMTRANS_FLAG_COMMIT)
iosm->commit = ((ts && (rpmtsFlags(ts) & _tsmask) && iosm->commit = ((ts && (rpmtsFlags(ts) & _tsmask) &&
iosm->goal != IOSM_PKGCOMMIT) ? 0 : 1); iosm->goal != IOSM_PKGCOMMIT) ? 0 : 1);
skipping to change at line 812 skipping to change at line 820
iosm->lmtab = _free(iosm->lmtab); iosm->lmtab = _free(iosm->lmtab);
if (iosm->iter != NULL) { if (iosm->iter != NULL) {
#if defined(_USE_RPMTS) #if defined(_USE_RPMTS)
(void) rpmswAdd(rpmtsOp(iosmGetTs(iosm), RPMTS_OP_DIGEST), (void) rpmswAdd(rpmtsOp(iosmGetTs(iosm), RPMTS_OP_DIGEST),
&iosm->op_digest); &iosm->op_digest);
(void)rpmtsFree(iosm->iter->ts); (void)rpmtsFree(iosm->iter->ts);
#endif #endif
iosm->iter->ts = NULL; iosm->iter->ts = NULL;
iosm->iter = mapFreeIterator(iosm->iter); mapFreeIterator(iosm->iter); iosm->iter = NULL;
} }
if (iosm->cfd != NULL) { if (iosm->cfd != NULL) {
iosm->cfd = fdFree(iosm->cfd, "persist (iosm)"); iosm->cfd = fdFree(iosm->cfd, "persist (iosm)");
iosm->cfd = NULL; iosm->cfd = NULL;
} }
iosm->failedFile = NULL; iosm->failedFile = NULL;
return rc; return rc;
} }
/* /*
skipping to change at line 837 skipping to change at line 845
static int iosmMapFContext(IOSM_t iosm) static int iosmMapFContext(IOSM_t iosm)
/*@modifies iosm @*/ /*@modifies iosm @*/
{ {
/* /*
* Find file security context (if not disabled). * Find file security context (if not disabled).
*/ */
iosm->fcontext = NULL; iosm->fcontext = NULL;
if (!iosm->nofcontexts) { if (!iosm->nofcontexts) {
iosm->fcontext = rpmsxMatch(NULL, iosm->path, iosm->sb.st_mode); iosm->fcontext = rpmsxMatch(NULL, iosm->path, iosm->sb.st_mode);
#ifdef DYING /* XXX SELinux file contexts not set from package content. * / #ifdef DYING /* XXX SELinux file contexts not set from package content. * /
{ rpmfi fi = iosmGetFi(iosm); { rpmfi fi = (rpmfi) iosmGetFi(iosm);
int i = iosm->ix; int i = iosm->ix;
/* Get file security context from package. */ /* Get file security context from package. */
if (fi && i >= 0 && i < (int)fi->fc) if (fi && i >= 0 && i < (int)fi->fc)
iosm->fcontext = (fi->fcontexts ? fi->fcontexts[i] : NULL); iosm->fcontext = (fi->fcontexts ? fi->fcontexts[i] : NULL);
} }
#endif #endif
/*@=moduncon@*/ /*@=moduncon@*/
} }
return 0; return 0;
} }
int iosmMapPath(IOSM_t iosm) int iosmMapPath(IOSM_t iosm)
{ {
rpmfi fi = iosmGetFi(iosm); /* XXX const except for fstates */ rpmfi fi = (rpmfi) iosmGetFi(iosm); /* XXX const except for fsta tes */
int teAdding = iosm->adding; int teAdding = iosm->adding;
int rc = 0; int rc = 0;
int i = iosm->ix; int i = iosm->ix;
iosm->osuffix = NULL; iosm->osuffix = NULL;
iosm->nsuffix = NULL; iosm->nsuffix = NULL;
iosm->astriplen = 0; iosm->astriplen = 0;
iosm->action = FA_UNKNOWN; iosm->action = FA_UNKNOWN;
iosm->mapFlags = (fi ? fi->mapflags : 0); iosm->mapFlags = (iosmMapFlags) (fi ? fi->mapflags : 0);
if (fi && i >= 0 && i < (int)fi->fc) { if (fi && i >= 0 && i < (int)fi->fc) {
iosm->astriplen = fi->astriplen; iosm->astriplen = fi->astriplen;
iosm->action = (fi->actions ? fi->actions[i] : fi->action); iosm->action = (iosmFileAction) (fi->actions ? fi->actions[i] : fi-> action);
iosm->fflags = (fi->fflags ? fi->fflags[i] : fi->flags); iosm->fflags = (fi->fflags ? fi->fflags[i] : fi->flags);
iosm->mapFlags = (fi->fmapflags ? fi->fmapflags[i] : fi->mapflags); iosm->mapFlags = (iosmMapFlags) (fi->fmapflags ? fi->fmapflags[i] : fi->mapflags);
/* src rpms have simple base name in payload. */ /* src rpms have simple base name in payload. */
iosm->dirName = fi->dnl[fi->dil[i]]; iosm->dirName = fi->dnl[fi->dil[i]];
iosm->baseName = fi->bnl[i]; iosm->baseName = fi->bnl[i];
switch (iosm->action) { switch (iosm->action) {
case FA_SKIP: case FA_SKIP:
break; break;
case FA_UNKNOWN: case FA_UNKNOWN:
break; break;
skipping to change at line 944 skipping to change at line 952
iosm->path = iosmFsPath(iosm, st, iosm->subdir, iosm->path = iosmFsPath(iosm, st, iosm->subdir,
(iosm->suffix ? iosm->suffix : iosm->nsuffix)); (iosm->suffix ? iosm->suffix : iosm->nsuffix));
} }
} }
return rc; return rc;
} }
int iosmMapAttrs(IOSM_t iosm) int iosmMapAttrs(IOSM_t iosm)
{ {
struct stat * st = &iosm->sb; struct stat * st = &iosm->sb;
rpmfi fi = iosmGetFi(iosm); rpmfi fi = (rpmfi) iosmGetFi(iosm);
int i = iosm->ix; int i = iosm->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 = (fi->frdevs ? fi->frdevs[i] : 0); dev_t finalRdev = (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( RPM_VENDOR_ARK) /* no-owner-group-on-srpm-install */
if (!fi->isSource) { if (!fi->isSource) {
#endif
if (iosm->goal == IOSM_PKGINSTALL) if (iosm->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 (iosm->goal == IOSM_PKGINSTALL) if (iosm->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 (iosm->mapFlags & IOSM_MAP_MODE) if (iosm->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 (iosm->mapFlags & IOSM_MAP_TYPE) { if (iosm->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 1045 skipping to change at line 1043
const struct stat * st = &iosm->sb; const struct stat * st = &iosm->sb;
size_t left = (size_t) st->st_size; size_t left = (size_t) st->st_size;
int rc = 0; int rc = 0;
int xx; int xx;
rc = iosmNext(iosm, IOSM_WOPEN); rc = iosmNext(iosm, IOSM_WOPEN);
if (rc) if (rc)
goto exit; goto exit;
if (st->st_size > 0 && (iosm->fdigest != NULL || iosm->digest != NULL)) if (st->st_size > 0 && (iosm->fdigest != NULL || iosm->digest != NULL))
fdInitDigest(iosm->wfd, iosm->fdigestalgo, 0); fdInitDigest(iosm->wfd, (pgpHashAlgo)iosm->fdigestalgo, 0);
while (left) { while (left) {
iosm->wrlen = (left > iosm->wrsize ? iosm->wrsize : left); iosm->wrlen = (left > iosm->wrsize ? iosm->wrsize : left);
rc = iosmNext(iosm, IOSM_DREAD); rc = iosmNext(iosm, IOSM_DREAD);
if (rc) if (rc)
goto exit; goto exit;
rc = iosmNext(iosm, IOSM_WRITE); rc = iosmNext(iosm, IOSM_WRITE);
if (rc) if (rc)
skipping to change at line 1072 skipping to change at line 1070
(void) iosmNext(iosm, IOSM_NOTIFY); (void) iosmNext(iosm, IOSM_NOTIFY);
} }
xx = fsync(Fileno(iosm->wfd)); xx = fsync(Fileno(iosm->wfd));
if (st->st_size > 0 && (iosm->fdigest || iosm->digest)) { if (st->st_size > 0 && (iosm->fdigest || iosm->digest)) {
void * digest = NULL; void * digest = NULL;
int asAscii = (iosm->digest == NULL ? 1 : 0); int asAscii = (iosm->digest == NULL ? 1 : 0);
(void) Fflush(iosm->wfd); (void) Fflush(iosm->wfd);
fdFiniDigest(iosm->wfd, iosm->fdigestalgo, &digest, NULL, asAscii); fdFiniDigest(iosm->wfd, (pgpHashAlgo)iosm->fdigestalgo, &digest, NUL L, asAscii);
if (digest == NULL) { if (digest == NULL) {
rc = IOSMERR_DIGEST_MISMATCH; rc = IOSMERR_DIGEST_MISMATCH;
goto exit; goto exit;
} }
if (iosm->digest != NULL) { if (iosm->digest != NULL) {
if (memcmp(digest, iosm->digest, iosm->digestlen)) if (memcmp(digest, iosm->digest, iosm->digestlen))
rc = IOSMERR_DIGEST_MISMATCH; rc = IOSMERR_DIGEST_MISMATCH;
} else { } else {
if (strcmp(digest, iosm->fdigest)) if (strcmp((char *)digest, iosm->fdigest))
rc = IOSMERR_DIGEST_MISMATCH; rc = IOSMERR_DIGEST_MISMATCH;
} }
digest = _free(digest); digest = _free(digest);
} }
exit: exit:
(void) iosmNext(iosm, IOSM_WCLOSE); (void) iosmNext(iosm, IOSM_WCLOSE);
return rc; return rc;
} }
/*@=compdef@*/ /*@=compdef@*/
skipping to change at line 1133 skipping to change at line 1131
*/ */
/* XXX NUL terminated result in iosm->rdbuf, len in iosm->rdnb. */ /* XXX NUL terminated result in iosm->rdbuf, len in iosm->rdnb. */
rc = iosmUNSAFE(iosm, IOSM_READLINK); rc = iosmUNSAFE(iosm, IOSM_READLINK);
if (rc) goto exit; if (rc) goto exit;
st->st_size = iosm->rdnb; st->st_size = iosm->rdnb;
iosm->lpath = xstrdup(iosm->rdbuf); /* XXX save readlink return. */ iosm->lpath = xstrdup(iosm->rdbuf); /* XXX save readlink return. */
} }
if (iosm->mapFlags & IOSM_MAP_ABSOLUTE) { if (iosm->mapFlags & IOSM_MAP_ABSOLUTE) {
size_t nb=strlen(iosm->dirName) + strlen(iosm->baseName) + sizeof(". "); size_t nb=strlen(iosm->dirName) + strlen(iosm->baseName) + sizeof(". ");
char * t = alloca(nb); char * t = (char *) alloca(nb);
*t = '\0'; *t = '\0';
iosm->path = t; iosm->path = t;
if (iosm->mapFlags & IOSM_MAP_ADDDOT) if (iosm->mapFlags & IOSM_MAP_ADDDOT)
*t++ = '.'; *t++ = '.';
t = stpcpy( stpcpy(t, iosm->dirName), iosm->baseName); t = stpcpy( stpcpy(t, iosm->dirName), iosm->baseName);
} else if (iosm->mapFlags & IOSM_MAP_PATH) { } else if (iosm->mapFlags & IOSM_MAP_PATH) {
rpmfi fi = iosmGetFi(iosm); rpmfi fi = (rpmfi) iosmGetFi(iosm);
if (fi->apath) { if (fi->apath) {
const char * apath = NULL; const char * apath = NULL;
(void) urlPath(fi->apath[iosm->ix], &apath); (void) urlPath(fi->apath[iosm->ix], &apath);
iosm->path = apath + fi->striplen; iosm->path = apath + fi->striplen;
} else } else
iosm->path = fi->bnl[iosm->ix]; iosm->path = fi->bnl[iosm->ix];
} }
rc = iosmNext(iosm, IOSM_HWRITE); rc = iosmNext(iosm, IOSM_HWRITE);
iosm->path = path; iosm->path = path;
skipping to change at line 1273 skipping to change at line 1271
rc = iosmNext(iosm, IOSM_MAP); rc = iosmNext(iosm, IOSM_MAP);
/*@=compdef@*/ /*@=compdef@*/
/* XXX tar and cpio have to do things differently. */ /* XXX tar and cpio have to do things differently. */
if (iosm->headerWrite == tarHeaderWrite) { if (iosm->headerWrite == tarHeaderWrite) {
if (firstfile) { if (firstfile) {
const char * apath = NULL; const char * apath = NULL;
char *t; char *t;
(void) urlPath(iosm->path, &apath); (void) urlPath(iosm->path, &apath);
/* Remove the buildroot prefix. */ /* Remove the buildroot prefix. */
t = xmalloc(sizeof(".") + strlen(apath + iosm->astriplen)); t = (char *) xmalloc(sizeof(".") + strlen(apath + iosm->astr iplen));
(void) stpcpy( stpcpy(t, "."), apath + iosm->astriplen); (void) stpcpy( stpcpy(t, "."), apath + iosm->astriplen);
linkpath = t; linkpath = t;
firstfile = 0; firstfile = 0;
} else } else
iosm->lpath = linkpath; iosm->lpath = linkpath;
/* Write data after first link for tar. */ /* Write data after first link for tar. */
rc = writeFile(iosm, (iosm->lpath == NULL)); rc = writeFile(iosm, (iosm->lpath == NULL));
} else { } else {
/* Write data after last link for cpio. */ /* Write data after last link for cpio. */
skipping to change at line 1424 skipping to change at line 1422
* @return 0 on success * @return 0 on success
*/ */
static int iosmRmdirs(/*@special@*/ /*@partial@*/ IOSM_t iosm) static int iosmRmdirs(/*@special@*/ /*@partial@*/ IOSM_t iosm)
/*@uses iosm->path, iosm->dnlx, iosm->ldn, iosm->rdbuf, iosm->iter @ */ /*@uses iosm->path, iosm->dnlx, iosm->ldn, iosm->rdbuf, iosm->iter @ */
/*@globals h_errno, fileSystem, internalState @*/ /*@globals h_errno, fileSystem, internalState @*/
/*@modifies iosm, fileSystem, internalState @*/ /*@modifies iosm, fileSystem, internalState @*/
{ {
const char * path = iosm->path; const char * path = iosm->path;
void * dnli = dnlInitIterator(iosm, 1); void * dnli = dnlInitIterator(iosm, 1);
char * dn = iosm->rdbuf; char * dn = iosm->rdbuf;
int dc = dnlCount(dnli); int dc = dnlCount((DNLI_t)dnli);
int rc = 0; int rc = 0;
iosm->path = NULL; iosm->path = NULL;
dn[0] = '\0'; dn[0] = '\0';
/*@-observertrans -dependenttrans@*/ /*@-observertrans -dependenttrans@*/
if (iosm->ldn != NULL && iosm->dnlx != NULL) if (iosm->ldn != NULL && iosm->dnlx != NULL)
while ((iosm->path = dnlNextIterator(dnli)) != NULL) { while ((iosm->path = dnlNextIterator((DNLI_t)dnli)) != NULL) {
size_t dnlen = strlen(iosm->path); size_t dnlen = strlen(iosm->path);
char * te; char * te;
dc = dnlIndex(dnli); dc = dnlIndex((DNLI_t)dnli);
if (iosm->dnlx[dc] < 1 || (size_t)iosm->dnlx[dc] >= dnlen) if (iosm->dnlx[dc] < 1 || (size_t)iosm->dnlx[dc] >= dnlen)
continue; continue;
/* Copy to avoid const on iosm->path. */ /* Copy to avoid const on iosm->path. */
te = stpcpy(dn, iosm->path) - 1; te = stpcpy(dn, iosm->path) - 1;
iosm->path = dn; iosm->path = dn;
/* Remove generated directories. */ /* Remove generated directories. */
/*@-usereleased@*/ /* LCL: te used after release? */ /*@-usereleased@*/ /* LCL: te used after release? */
do { do {
skipping to change at line 1484 skipping to change at line 1482
/*@defines iosm->dnlx, iosm->ldn @*/ /*@defines iosm->dnlx, iosm->ldn @*/
/*@globals h_errno, fileSystem, internalState @*/ /*@globals h_errno, fileSystem, internalState @*/
/*@modifies iosm, fileSystem, internalState @*/ /*@modifies iosm, fileSystem, internalState @*/
{ {
struct stat * st = &iosm->sb; struct stat * st = &iosm->sb;
struct stat * ost = &iosm->osb; struct stat * ost = &iosm->osb;
const char * path = iosm->path; const char * path = iosm->path;
mode_t st_mode = st->st_mode; mode_t st_mode = st->st_mode;
void * dnli = dnlInitIterator(iosm, 0); void * dnli = dnlInitIterator(iosm, 0);
char * dn = iosm->rdbuf; char * dn = iosm->rdbuf;
int dc = dnlCount(dnli); int dc = dnlCount((DNLI_t)dnli);
int rc = 0; int rc = 0;
size_t i; size_t i;
iosm->path = NULL; iosm->path = NULL;
dn[0] = '\0'; dn[0] = '\0';
iosm->dnlx = (dc ? xcalloc(dc, sizeof(*iosm->dnlx)) : NULL); iosm->dnlx = (unsigned short *) (dc ? xcalloc(dc, sizeof(*iosm->dnlx)) : NULL);
/*@-observertrans -dependenttrans@*/ /*@-observertrans -dependenttrans@*/
if (iosm->dnlx != NULL) if (iosm->dnlx != NULL)
while ((iosm->path = dnlNextIterator(dnli)) != NULL) { while ((iosm->path = dnlNextIterator((DNLI_t)dnli)) != NULL) {
size_t dnlen = strlen(iosm->path); size_t dnlen = strlen(iosm->path);
char * te; char * te;
dc = dnlIndex(dnli); dc = dnlIndex((DNLI_t)dnli);
if (dc < 0) continue; if (dc < 0) continue;
iosm->dnlx[dc] = (unsigned short) dnlen; iosm->dnlx[dc] = (unsigned short) dnlen;
if (dnlen <= 1) if (dnlen <= 1)
continue; continue;
/*@-compdef -nullpass@*/ /* FIX: iosm->ldn not defined ??? */ /*@-compdef -nullpass@*/ /* FIX: iosm->ldn not defined ??? */
if (dnlen <= iosm->ldnlen && !strcmp(iosm->path, iosm->ldn)) if (dnlen <= iosm->ldnlen && !strcmp(iosm->path, iosm->ldn))
continue; continue;
/*@=compdef =nullpass@*/ /*@=compdef =nullpass@*/
skipping to change at line 1543 skipping to change at line 1541
/* Validate next component of path. */ /* Validate next component of path. */
rc = iosmUNSAFE(iosm, IOSM_LSTAT); rc = iosmUNSAFE(iosm, IOSM_LSTAT);
*te = '/'; *te = '/';
/* Directory already exists? */ /* Directory already exists? */
if (rc == 0 && S_ISDIR(ost->st_mode)) { if (rc == 0 && S_ISDIR(ost->st_mode)) {
/* Move pre-existing path marker forward. */ /* Move pre-existing path marker forward. */
iosm->dnlx[dc] = (te - dn); iosm->dnlx[dc] = (te - dn);
} else if (rc == IOSMERR_ENOENT) { } else if (rc == IOSMERR_ENOENT) {
rpmfi fi = iosmGetFi(iosm); rpmfi fi = (rpmfi) iosmGetFi(iosm);
*te = '\0'; *te = '\0';
st->st_mode = S_IFDIR | (fi->dperms & 07777); st->st_mode = S_IFDIR | (fi->dperms & 07777);
rc = iosmNext(iosm, IOSM_MKDIR); rc = iosmNext(iosm, IOSM_MKDIR);
if (!rc) { if (!rc) {
#if defined(_USE_RPMSX) #if defined(_USE_RPMSX)
/* XXX FIXME? only new dir will have context set. */ /* XXX FIXME? only new dir will have context set. */
/* Get file security context from patterns. */ /* Get file security context from patterns. */
if (!fsm->nofcontexts) { if (!fsm->nofcontexts) {
iosm->fcontext = iosm->fcontext =
rpmsxMatch(NULL, iosm->path, st->st_mode); rpmsxMatch(NULL, iosm->path, st->st_mode);
skipping to change at line 1578 skipping to change at line 1576
} }
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 (iosm->ldnalloc < (dnlen + 1)) { if (iosm->ldnalloc < (dnlen + 1)) {
iosm->ldnalloc = dnlen + 100; iosm->ldnalloc = dnlen + 100;
iosm->ldn = xrealloc(iosm->ldn, iosm->ldnalloc); iosm->ldn = (char *) xrealloc(iosm->ldn, iosm->ldnalloc);
} }
if (iosm->ldn != NULL) { /* XXX can't happen */ if (iosm->ldn != NULL) { /* XXX can't happen */
strcpy(iosm->ldn, iosm->path); strcpy(iosm->ldn, iosm->path);
iosm->ldnlen = dnlen; iosm->ldnlen = dnlen;
} }
/*@=compdef@*/ /*@=compdef@*/
} }
dnli = dnlFreeIterator(dnli); dnli = dnlFreeIterator(dnli);
/*@=observertrans =dependenttrans@*/ /*@=observertrans =dependenttrans@*/
skipping to change at line 1789 skipping to change at line 1787
iosm->li->filex[0] = iosm->li->filex[j]; iosm->li->filex[0] = iosm->li->filex[j];
iosm->li->filex[j] = -1; iosm->li->filex[j] = -1;
} }
iosm->li->sb.st_nlink = nlink; iosm->li->sb.st_nlink = nlink;
iosm->sb = iosm->li->sb; /* structure assignment */ iosm->sb = iosm->li->sb; /* structure assignment */
iosm->osb = iosm->sb; /* structure assignment */ iosm->osb = iosm->sb; /* structure assignment */
if (!rc) rc = writeLinkedFile(iosm); if (!rc) rc = writeLinkedFile(iosm);
iosm->li = freeHardLink(iosm->li); iosm->li = (struct hardLink_s *) freeHardLink((struct hardLi nk_s *) iosm->li);
} }
} }
if (!rc) if (!rc)
rc = iosmNext(iosm, IOSM_TRAILER); rc = iosmNext(iosm, IOSM_TRAILER);
break; break;
case IOSM_CREATE: case IOSM_CREATE:
iosm->path = _free(iosm->path); iosm->path = _free(iosm->path);
iosm->lpath = _free(iosm->lpath); iosm->lpath = _free(iosm->lpath);
skipping to change at line 1811 skipping to change at line 1809
iosm->dnlx = _free(iosm->dnlx); iosm->dnlx = _free(iosm->dnlx);
iosm->ldn = _free(iosm->ldn); iosm->ldn = _free(iosm->ldn);
iosm->ldnalloc = iosm->ldnlen = 0; iosm->ldnalloc = iosm->ldnlen = 0;
iosm->rdsize = iosm->wrsize = 0; iosm->rdsize = iosm->wrsize = 0;
iosm->rdbuf = iosm->rdb = _free(iosm->rdb); iosm->rdbuf = iosm->rdb = _free(iosm->rdb);
iosm->wrbuf = iosm->wrb = _free(iosm->wrb); iosm->wrbuf = iosm->wrb = _free(iosm->wrb);
if (iosm->goal == IOSM_PKGINSTALL || iosm->goal == IOSM_PKGBUILD) { if (iosm->goal == IOSM_PKGINSTALL || iosm->goal == IOSM_PKGBUILD) {
iosm->rdsize = 16 * BUFSIZ; iosm->rdsize = 16 * BUFSIZ;
iosm->rdbuf = iosm->rdb = xmalloc(iosm->rdsize); iosm->rdbuf = iosm->rdb = (char *) xmalloc(iosm->rdsize);
iosm->wrsize = 16 * BUFSIZ; iosm->wrsize = 16 * BUFSIZ;
iosm->wrbuf = iosm->wrb = xmalloc(iosm->wrsize); iosm->wrbuf = iosm->wrb = (char *) xmalloc(iosm->wrsize);
} }
iosm->mkdirsdone = 0; iosm->mkdirsdone = 0;
iosm->ix = -1; iosm->ix = -1;
iosm->links = NULL; iosm->links = NULL;
iosm->li = NULL; iosm->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 (iosm->goal == IOSM_PKGINSTALL) { if (iosm->goal == IOSM_PKGINSTALL) {
skipping to change at line 1852 skipping to change at line 1850
if (iosm->goal == IOSM_PKGINSTALL) { if (iosm->goal == IOSM_PKGINSTALL) {
/* Read next header from payload, checking for end-of-payload. * / /* Read next header from payload, checking for end-of-payload. * /
rc = iosmUNSAFE(iosm, IOSM_NEXT); rc = iosmUNSAFE(iosm, IOSM_NEXT);
} }
if (rc) break; if (rc) break;
/* Identify mapping index. */ /* Identify mapping index. */
iosm->ix = ((iosm->goal == IOSM_PKGINSTALL) iosm->ix = ((iosm->goal == IOSM_PKGINSTALL)
? mapFind(iosm->iter, iosm->path) : mapNextIterator(iosm->it er)); ? mapFind(iosm->iter, iosm->path) : mapNextIterator(iosm->it er));
{ rpmfi fi = iosmGetFi(iosm); { rpmfi fi = (rpmfi) iosmGetFi(iosm);
if (fi != NULL && !(fi->mapflags & IOSM_PAYLOAD_LIST)) { if (fi != NULL && !(fi->mapflags & IOSM_PAYLOAD_LIST)) {
/* Detect end-of-loop and/or mapping error. */ /* Detect end-of-loop and/or mapping error. */
if (!(fi->mapflags & IOSM_PAYLOAD_EXTRACT)) { if (!(fi->mapflags & IOSM_PAYLOAD_EXTRACT)) {
if (iosm->ix < 0) { if (iosm->ix < 0) {
if (iosm->goal == IOSM_PKGINSTALL) { if (iosm->goal == IOSM_PKGINSTALL) {
#if 0 #if 0
rpmlog(RPMLOG_WARNING, rpmlog(RPMLOG_WARNING,
_("archive file %s was not found in header\n"), _("archive file %s was not found in header\n"),
iosm->path); iosm->path);
#endif #endif
skipping to change at line 1921 skipping to change at line 1919
rc = iosmMapAttrs(iosm); rc = iosmMapAttrs(iosm);
if (rc) break; if (rc) break;
iosm->postpone = iosmFileActionSkipped(iosm->action); iosm->postpone = iosmFileActionSkipped(iosm->action);
if (iosm->goal == IOSM_PKGINSTALL || iosm->goal == IOSM_PKGBUILD) { if (iosm->goal == IOSM_PKGINSTALL || iosm->goal == IOSM_PKGBUILD) {
/*@-evalorder@*/ /* FIX: saveHardLink can modify iosm */ /*@-evalorder@*/ /* FIX: saveHardLink can modify iosm */
if (S_ISREG(st->st_mode) && st->st_nlink > 1) if (S_ISREG(st->st_mode) && st->st_nlink > 1)
iosm->postpone = saveHardLink(iosm); iosm->postpone = saveHardLink(iosm);
/*@=evalorder@*/ /*@=evalorder@*/
} }
{ rpmfi fi = iosmGetFi(iosm); { rpmfi fi = (rpmfi) iosmGetFi(iosm);
if (fi != NULL && (fi->mapflags & IOSM_PAYLOAD_LIST)) if (fi != NULL && (fi->mapflags & IOSM_PAYLOAD_LIST))
iosm->postpone = 1; iosm->postpone = 1;
} }
break; break;
case IOSM_PRE: case IOSM_PRE:
break; break;
case IOSM_MAP: case IOSM_MAP:
rc = iosmMapPath(iosm); rc = iosmMapPath(iosm);
break; break;
case IOSM_MKDIRS: case IOSM_MKDIRS:
skipping to change at line 1967 skipping to change at line 1965
for (li = iosm->links, prev = NULL; li; prev = li, li = li-> next) for (li = iosm->links, prev = NULL; li; prev = li, li = li-> next)
if (li == iosm->li) if (li == iosm->li)
/*@loopbreak@*/ break; /*@loopbreak@*/ break;
if (prev == NULL) if (prev == NULL)
iosm->links = iosm->li->next; iosm->links = iosm->li->next;
else else
prev->next = iosm->li->next; prev->next = iosm->li->next;
iosm->li->next = NULL; iosm->li->next = NULL;
iosm->li = freeHardLink(iosm->li); iosm->li = (struct hardLink_s *) freeHardLink((struct hardLi nk_s *) iosm->li);
} else { } else {
rc = writeFile(iosm, 1); rc = writeFile(iosm, 1);
} }
break; break;
} }
if (iosm->goal != IOSM_PKGINSTALL) if (iosm->goal != IOSM_PKGINSTALL)
break; break;
if (S_ISREG(st->st_mode) && iosm->lpath != NULL) { if (S_ISREG(st->st_mode) && iosm->lpath != NULL) {
const char * opath = iosm->opath; const char * opath = iosm->opath;
char * t = xmalloc(strlen(iosm->lpath+1) + strlen(iosm->suffix) + 1); char * t = (char *) xmalloc(strlen(iosm->lpath+1) + strlen(iosm- >suffix) + 1);
(void) stpcpy(t, iosm->lpath+1); (void) stpcpy(t, iosm->lpath+1);
iosm->opath = t; iosm->opath = t;
/* XXX link(iosm->opath, iosm->path) */ /* XXX link(iosm->opath, iosm->path) */
rc = iosmNext(iosm, IOSM_LINK); rc = iosmNext(iosm, IOSM_LINK);
if (iosm->failedFile && rc != 0 && *iosm->failedFile == NULL) { if (iosm->failedFile && rc != 0 && *iosm->failedFile == NULL) {
*iosm->failedFile = xstrdup(iosm->path); *iosm->failedFile = xstrdup(iosm->path);
} }
iosm->opath = _free(iosm->opath); iosm->opath = _free(iosm->opath);
iosm->opath = opath; iosm->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 2182 skipping to change at line 2180
/*@innerbreak@*/ break; /*@innerbreak@*/ break;
} }
} }
} }
/* XXX Failure to remove is not (yet) cause for failure. */ /* XXX Failure to remove is not (yet) cause for failure. */
if (!iosm->strict_erasures) rc = 0; if (!iosm->strict_erasures) rc = 0;
break; break;
} }
/* XXX Special case /dev/log, which shouldn't be packaged anyways */ /* XXX Special case /dev/log, which shouldn't be packaged anyways */
{ rpmfi fi = iosmGetFi(iosm); { rpmfi fi = (rpmfi) iosmGetFi(iosm);
if (!(fi->mapflags & IOSM_PAYLOAD_EXTRACT)) { if (!(fi->mapflags & IOSM_PAYLOAD_EXTRACT)) {
if (!S_ISSOCK(st->st_mode) && !IS_DEV_LOG(iosm->path)) { if (!S_ISSOCK(st->st_mode) && !IS_DEV_LOG(iosm->path)) {
/* Rename temporary to final file name. */ /* Rename temporary to final file name. */
if (!S_ISDIR(st->st_mode) && if (!S_ISDIR(st->st_mode) &&
(iosm->subdir || iosm->suffix || iosm->nsuffix)) (iosm->subdir || iosm->suffix || iosm->nsuffix))
{ {
iosm->opath = iosm->path; iosm->opath = iosm->path;
iosm->path = iosmFsPath(iosm, st, NULL, iosm->nsuffix); iosm->path = iosmFsPath(iosm, st, NULL, iosm->nsuffix);
rc = iosmNext(iosm, IOSM_RENAME); rc = iosmNext(iosm, IOSM_RENAME);
if (rc) if (rc)
skipping to change at line 2268 skipping to change at line 2266
} }
} }
/*@loopbreak@*/ break; /*@loopbreak@*/ break;
} }
} }
if (iosm->goal == IOSM_PKGBUILD && if (iosm->goal == IOSM_PKGBUILD &&
(iosm->mapFlags & IOSM_ALL_HARDLINKS)) (iosm->mapFlags & IOSM_ALL_HARDLINKS))
{ {
rc = IOSMERR_MISSING_HARDLINK; rc = IOSMERR_MISSING_HARDLINK;
} }
iosm->li = freeHardLink(iosm->li); freeHardLink(iosm->li); iosm->li = NULL;
} }
iosm->ldn = _free(iosm->ldn); iosm->ldn = _free(iosm->ldn);
iosm->ldnalloc = iosm->ldnlen = 0; iosm->ldnalloc = iosm->ldnlen = 0;
iosm->rdbuf = iosm->rdb = _free(iosm->rdb); iosm->rdbuf = iosm->rdb = _free(iosm->rdb);
iosm->wrbuf = iosm->wrb = _free(iosm->wrb); iosm->wrbuf = iosm->wrb = _free(iosm->wrb);
break; break;
case IOSM_VERIFY: case IOSM_VERIFY:
if (iosm->diskchecked && !iosm->exists) { if (iosm->diskchecked && !iosm->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(iosm->path) + sizeof("-RPMDELETE")); char * path = (char *) alloca(strlen(iosm->path) + sizeof("-RPMD ELETE"));
(void) stpcpy( stpcpy(path, iosm->path), "-RPMDELETE"); (void) stpcpy( stpcpy(path, iosm->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.
*/ */
iosm->opath = iosm->path; iosm->opath = iosm->path;
iosm->path = path; iosm->path = path;
rc = iosmNext(iosm, IOSM_RENAME); rc = iosmNext(iosm, IOSM_RENAME);
if (!rc) if (!rc)
(void) iosmNext(iosm, IOSM_UNLINK); (void) iosmNext(iosm, IOSM_UNLINK);
skipping to change at line 2365 skipping to change at line 2363
/* XXX rc = iosmNext(iosm, IOSM_CHMOD); instead */ /* XXX rc = iosmNext(iosm, IOSM_CHMOD); instead */
(void)Chmod(iosm->path, stb.st_mode & 0777); (void)Chmod(iosm->path, stb.st_mode & 0777);
} }
} }
rc = Rename(iosm->opath, iosm->path); rc = Rename(iosm->opath, iosm->path);
/* XXX Repackaged payloads may be missing files. */ /* XXX Repackaged payloads may be missing files. */
if (iosm->repackaged) if (iosm->repackaged)
rc = 0; rc = 0;
#if defined(ETXTBSY) #if defined(ETXTBSY)
if (rc && errno == ETXTBSY) { if (rc && errno == ETXTBSY) {
char * path = alloca(strlen(iosm->path) + sizeof("-RPMDELETE")); char * path = (char *) alloca(strlen(iosm->path) + sizeof("-RPMD ELETE"));
(void) stpcpy( stpcpy(path, iosm->path), "-RPMDELETE"); (void) stpcpy( stpcpy(path, iosm->path), "-RPMDELETE");
/* /*
* XXX HP-UX (and other os'es) don't permit rename to busy * XXX HP-UX (and other os'es) don't permit rename to busy
* XXX files. * XXX files.
*/ */
rc = Rename(iosm->path, path); rc = Rename(iosm->path, path);
if (!rc) rc = Rename(iosm->opath, iosm->path); if (!rc) rc = Rename(iosm->opath, iosm->path);
} }
#endif #endif
if (iosm->debug && (stage & IOSM_SYSCALL)) if (iosm->debug && (stage & IOSM_SYSCALL))
skipping to change at line 2768 skipping to change at line 2766
case IOSM_WCLOSE: return "Fclose"; case IOSM_WCLOSE: return "Fclose";
default: return "???"; default: return "???";
} }
/*@noteached@*/ /*@noteached@*/
} }
char * iosmStrerror(int rc) char * iosmStrerror(int rc)
{ {
char msg[256]; char msg[256];
char *s; const char *s;
int l, myerrno = errno; int l, myerrno = errno;
strcpy(msg, "cpio: "); strcpy(msg, "cpio: ");
switch (rc) { switch (rc) {
default: default:
s = msg + strlen(msg); s = msg + strlen(msg);
sprintf(s, _("(error 0x%x)"), (unsigned)rc); sprintf((char *)s, _("(error 0x%x)"), (unsigned)rc);
s = NULL; s = NULL;
break; break;
case IOSMERR_BAD_MAGIC: s = _("Bad magic"); break; case IOSMERR_BAD_MAGIC: s = _("Bad magic"); break;
case IOSMERR_BAD_HEADER: s = _("Bad/unreadable header"); break; case IOSMERR_BAD_HEADER: s = _("Bad/unreadable header"); break;
case IOSMERR_OPEN_FAILED: s = "open"; break; case IOSMERR_OPEN_FAILED: s = "open"; break;
case IOSMERR_CHMOD_FAILED: s = "chmod"; break; case IOSMERR_CHMOD_FAILED: s = "chmod"; break;
case IOSMERR_CHOWN_FAILED: s = "chown"; break; case IOSMERR_CHOWN_FAILED: s = "chown"; break;
case IOSMERR_WRITE_FAILED: s = "write"; break; case IOSMERR_WRITE_FAILED: s = "write"; break;
case IOSMERR_UTIME_FAILED: s = "utime"; break; case IOSMERR_UTIME_FAILED: s = "utime"; break;
 End of changes. 78 change blocks. 
82 lines changed or deleted 81 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/