15 #define _RPMAV_INTERNAL
21 #define _IOSM_INTERNAL
22 #define _RPMFI_INTERNAL
28 #define _RPMTE_INTERNAL
68 for (t = s + strlen(s) - 1; *t == c && t >= s; t--)
76 return (fi != NULL ? fi->fc : 0);
81 return (fi != NULL ? fi->dc : 0);
92 return (fi != NULL ? fi->i : -1);
99 if (fi != NULL && fx >= 0 && fx < (
int)fi->fc) {
102 fi->j = fi->dil[fi->i];
109 return (fi != NULL ? fi->j : -1);
116 if (fi != NULL && dx >= 0 && dx < (
int)fi->dc) {
125 return (fi != NULL ? fi->isSource : 0);
130 const char * BN = NULL;
132 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
141 const char * DN = NULL;
143 if (fi != NULL && fi->j >= 0 && fi->j < (
int)fi->dc) {
152 const char * FN =
"";
154 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
158 fi->fn =
xmalloc(fi->fnlen + 1);
160 (void)
urlPath(fi->dnl[fi->dil[fi->i]], &dn);
163 t =
stpcpy(t, fi->bnl[fi->i]);
179 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
180 if (fi->fflags != NULL)
181 FFlags = fi->fflags[fi->i];
190 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
191 if (fi->fflags != NULL && fi->h == NULL) {
192 oFFlags = fi->fflags[fi->i];
203 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
204 if (fi->vflags != NULL)
205 VFlags = fi->vflags[fi->i];
214 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
215 if (fi->vflags != NULL && fi->h == NULL) {
216 oVFlags = fi->vflags[fi->i];
227 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
228 if (fi->fmodes != NULL)
229 fmode = fi->fmodes[fi->i];
238 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
239 if (fi->fstates != NULL)
240 fstate = fi->fstates[fi->i];
249 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
250 if (fi->fstates != NULL) {
251 ofstate = fi->fstates[fi->i];
252 fi->fstates[fi->i] = fstate;
260 unsigned char * digest = NULL;
262 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
263 if (fi->digests != NULL) {
264 digest = fi->digests + (fi->digestlen * fi->i);
266 *algop = (fi->fdigestalgos
267 ? fi->fdigestalgos[fi->i] : fi->digestalgo);
269 *lenp = fi->digestlen;
277 const char * flink = NULL;
279 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
280 if (fi->flinks != NULL)
281 flink = fi->flinks[fi->i];
290 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
291 if (fi->fsizes != NULL)
292 fsize = fi->fsizes[fi->i];
301 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
302 if (fi->frdevs != NULL)
303 frdev = fi->frdevs[fi->i];
312 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
313 if (fi->finodes != NULL)
314 finode = fi->finodes[fi->i];
325 color = fi->color & 0xf;
333 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
334 if (fi->fcolors != NULL)
336 fcolor = (fi->fcolors[fi->i] & 0x0f);
343 const char * fclass = NULL;
345 if (fi != NULL && fi->fcdictx != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
346 int cdictx = fi->fcdictx[fi->i];
347 if (fi->cdict != NULL && cdictx >= 0 && cdictx < (
int)fi->ncdict)
348 fclass = fi->cdict[cdictx];
355 const char * fcontext = NULL;
357 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
358 if (fi->fcontexts != NULL)
359 fcontext = fi->fcontexts[fi->i];
370 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
371 if (fi->fddictn != NULL)
372 fddictn = fi->fddictn[fi->i];
373 if (fddictn > 0 && fi->fddictx != NULL)
374 fddictx = fi->fddictx[fi->i];
375 if (fi->ddict != NULL && fddictx >= 0 && (fddictx+fddictn) <= (
int)fi->nddict)
376 fddict = fi->ddict + fddictx;
389 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
391 if (fi->finodes && fi->frdevs) {
396 for (j = 0; j < (int)fi->fc; j++) {
397 if (fi->frdevs[j] == frdev && fi->finodes[j] == finode)
409 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
410 if (fi->fmtimes != NULL)
411 fmtime = fi->fmtimes[fi->i];
418 const char * fuser = NULL;
421 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
422 if (fi->fuser != NULL)
423 fuser = fi->fuser[fi->i];
430 const char * fgroup = NULL;
433 if (fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
434 if (fi->fgroup != NULL)
435 fgroup = fi->fgroup[fi->i];
442 return (fi != NULL ? fi->exclude : NULL);
447 return (fi != NULL ? fi->nexclude : 0);
452 return (fi != NULL ? fi->include : NULL);
457 return (fi != NULL ? fi->ninclude : 0);
464 if (fi != NULL && ++fi->i >= 0) {
465 if (fi->i < (
int)fi->fc) {
468 fi->j = fi->dil[fi->i];
474 fprintf(stderr,
"*** fi %p\t%s[%d] %s%s\n", fi, (fi->Type ? fi->Type :
"?Type?"), i, (i >= 0 ? fi->dnl[fi->j] :
""), (i >= 0 ? fi->bnl[fi->i] :
""));
485 if (fx >= 0 && fx < (
int)fi->fc) {
500 if (fi != NULL && ++fi->j >= 0) {
501 if (fi->j < (
int)fi->dc)
508 fprintf(stderr,
"*** fi %p\t%s[%d]\n", fi, (fi->Type ? fi->Type :
"?Type?"), j);
519 if (dx >= 0 && dx < (
int)fi->fc)
540 case XDIR:
return "directory";
541 case CDEV:
return "char dev";
542 case BDEV:
return "block dev";
543 case LINK:
return "link";
544 case SOCK:
return "sock";
545 case PIPE:
return "fifo/pipe";
546 case REG:
return "file";
547 default:
return "unknown file type";
560 if (S_ISDIR(mode))
return XDIR;
561 if (S_ISCHR(mode))
return CDEV;
562 if (S_ISBLK(mode))
return BDEV;
567 if (S_ISFIFO(mode))
return PIPE;
577 if (awhat != bwhat)
return 1;
582 if (alink == blink)
return 0;
583 if (alink == NULL)
return 1;
584 if (blink == NULL)
return -1;
585 return strcmp(alink, blink);
586 }
else if (awhat ==
REG) {
589 const unsigned char * adigest =
rpmfiDigest(afi, &aalgo, &alen);
592 const unsigned char * bdigest =
rpmfiDigest(bfi, &balgo, &blen);
594 if (!(aalgo == balgo && alen == blen))
596 if (adigest == bdigest)
return 0;
597 if (adigest == NULL)
return 1;
598 if (bdigest == NULL)
return -1;
599 return memcmp(adigest, bdigest, alen);
607 const char * fn =
rpmfiFN(nfi);
614 if (
Lstat(fn, &sb)) {
639 if (diskWhat != newWhat && dbWhat !=
REG && dbWhat !=
LINK)
641 else if (newWhat != dbWhat && diskWhat != dbWhat)
643 else if (dbWhat != newWhat)
645 else if (dbWhat !=
LINK && dbWhat !=
REG)
652 memset(buffer, 0,
sizeof(buffer));
656 const unsigned char * odigest;
659 const unsigned char * ndigest;
661 if (diskWhat ==
REG) {
663 if (
dodigest(oalgo, fn, (
unsigned char *)buffer, 0, NULL))
665 if (odigest && !memcmp(odigest, buffer, olen))
670 if (odigest && ndigest && oalgo == nalgo && olen == nlen
671 && !memcmp(odigest, ndigest, nlen))
675 const char * oFLink, * nFLink;
677 if (diskWhat ==
LINK) {
678 if (
Readlink(fn, buffer,
sizeof(buffer) - 1) == -1)
680 buffer[
sizeof(buffer)-1] =
'\0';
681 if (oFLink && !strcmp(oFLink, buffer))
686 if (oFLink && nFLink && !strcmp(oFLink, nFLink))
706 default:
return "???";
711 #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
730 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
732 static int _printed = 0;
736 const char ** validRelocations;
739 const char ** baseNames;
740 const char ** dirNames;
751 size_t fileAlloced = 0;
753 int haveRelocatedFile = 0;
762 validRelocations = he->
p.
argv;
770 while (p->relocs[numRelocations].newPath ||
771 p->relocs[numRelocations].oldPath)
780 if (p->relocs == NULL || numRelocations == 0) {
785 he->
p.
argv = validRelocations;
789 validRelocations =
_free(validRelocations);
801 relocations =
alloca(
sizeof(*relocations) * numRelocations);
804 for (i = 0; i < numRelocations; i++) {
811 if (p->relocs[i].oldPath == NULL)
continue;
816 relocations[i].
oldPath = (t[0] ==
'/' && t[1] ==
'\0')
821 if (p->relocs[i].newPath) {
825 relocations[i].
newPath = (t[0] ==
'/' && t[1] ==
'\0')
831 for (j = 0; j < numValid; j++) {
832 if (!strcmp(validRelocations[j], relocations[i].oldPath))
837 if (j == numValid && !allowBadRelocate && actions) {
841 relocations[i].oldPath, NULL, NULL, 0);
845 (int)strlen(relocations[i].newPath) - (int)strlen(relocations[i].oldPath);
856 for (i = 0; i < numRelocations; i++) {
859 for (j = 1; j < numRelocations; j++) {
861 if (relocations[j - 1].
oldPath == NULL ||
862 relocations[j ].
oldPath == NULL ||
866 tmpReloc = relocations[j - 1];
867 relocations[j - 1] = relocations[j];
868 relocations[j] = tmpReloc;
872 if (!madeSwap)
break;
878 for (i = 0; i < numRelocations; i++) {
879 if (relocations[i].
oldPath == NULL)
continue;
880 if (relocations[i].
newPath == NULL)
885 i, relocations[i].oldPath, relocations[i].
newPath);
891 const char ** actualRelocations;
894 actualRelocations =
xmalloc(numValid *
sizeof(*actualRelocations));
896 for (i = 0; i < numValid; i++) {
897 for (j = 0; j < numRelocations; j++) {
898 if (relocations[j].
oldPath == NULL ||
899 strcmp(validRelocations[i], relocations[j].
oldPath))
903 actualRelocations[numActual] = relocations[j].
newPath;
908 if (j == numRelocations) {
909 actualRelocations[numActual] = validRelocations[i];
917 he->
p.
argv = actualRelocations;
922 actualRelocations =
_free(actualRelocations);
923 validRelocations =
_free(validRelocations);
928 baseNames = he->
p.
argv;
935 dirNames = he->
p.
argv;
947 dColors =
alloca(dirCount *
sizeof(*dColors));
948 memset(dColors, 0, dirCount *
sizeof(*dColors));
958 for (i = fileCount - 1; i >= 0; i--) {
963 strlen(dirNames[dirIndexes[i]]) + strlen(baseNames[i]) + 1;
964 if (len >= fileAlloced) {
965 fileAlloced = len * 2;
971 fnlen =
stpcpy(
stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn;
973 if (fColors != NULL) {
975 for (j = 0; j < (int)dirCount; j++) {
976 if (strcmp(dirNames[dirIndexes[i]], dirNames[j]))
continue;
977 dColors[j] |= fColors[i];
988 for (j = numRelocations - 1; j >= 0; j--) {
989 if (relocations[j].
oldPath == NULL)
991 len = strcmp(relocations[j].
oldPath,
"/")
992 ? strlen(relocations[j].oldPath)
1001 if (!(fn[len] ==
'/' || fnlen == len))
1004 if (strncmp(relocations[j].oldPath, fn, len))
1008 if (j < 0)
continue;
1015 if (relocations[j].
newPath == NULL) {
1018 for (j = dirIndexes[i]; j < (int)dirCount; j++) {
1019 len = strlen(dirNames[j]) - 1;
1020 while (len > 0 && dirNames[j][len-1] ==
'/') len--;
1023 if (strncmp(fn, dirNames[j], fnlen))
1037 if (fnlen != len)
continue;
1044 strcpy(fn, relocations[j].newPath);
1045 {
char * te = strrchr(fn,
'/');
1050 te = fn + strlen(fn);
1052 if (strcmp(baseNames[i], te))
1059 for (j = 0; j < (int)dirCount; j++) {
1060 if (fnlen != strlen(dirNames[j]))
1062 if (strncmp(fn, dirNames[j], fnlen))
1067 if (j < (
int)dirCount) {
1073 if (!haveRelocatedFile) {
1074 const char ** newDirList;
1076 haveRelocatedFile = 1;
1077 newDirList =
xmalloc((dirCount + 1) *
sizeof(*newDirList));
1078 for (j = 0; j < (int)dirCount; j++)
1080 dirNames =
_free(dirNames);
1081 dirNames = newDirList;
1084 sizeof(*dirNames) * (dirCount + 1));
1088 dirIndexes[i] = dirCount;
1093 for (i = dirCount - 1; i >= 0; i--) {
1094 for (j = numRelocations - 1; j >= 0; j--) {
1097 if (j == p->autorelocatex
1098 && (dColors[i] == 0 || !(dColors[i] & mydColor)))
1101 if (relocations[j].
oldPath == NULL)
1103 len = strcmp(relocations[j].
oldPath,
"/")
1104 ? strlen(relocations[j].oldPath)
1107 if (len && strncmp(relocations[j].oldPath, dirNames[i], len))
1114 if (dirNames[i][len] !=
'/')
1118 const char * s = relocations[j].
newPath;
1119 char * t =
alloca(strlen(s) + strlen(dirNames[i]) - len + 1);
1132 D_(
"relocating directory %s to %s\n"), dirNames[i], t);
1161 he->
p.
argv = baseNames;
1164 fi->bnl =
_free(fi->bnl);
1167 fi->bnl = he->
p.
argv;
1173 he->
p.
argv = dirNames;
1176 fi->dnl =
_free(fi->dnl);
1178 fi->dnl = he->
p.
argv;
1183 he->
p.
ui32p = dirIndexes;
1186 fi->dil =
_free(fi->dil);
1193 baseNames =
_free(baseNames);
1194 dirIndexes =
_free(dirIndexes);
1195 dirNames =
_free(dirNames);
1196 fFlags =
_free(fFlags);
1197 fColors =
_free(fColors);
1198 fModes =
_free(fModes);
1227 fi->pretrans =
_free(fi->pretrans);
1228 fi->pretransprog =
_free(fi->pretransprog);
1229 fi->posttrans =
_free(fi->posttrans);
1230 fi->posttransprog =
_free(fi->posttransprog);
1231 fi->verifyscript =
_free(fi->verifyscript);
1232 fi->verifyscriptprog =
_free(fi->verifyscriptprog);
1235 fi->bnl =
_free(fi->bnl);
1236 fi->dnl =
_free(fi->dnl);
1238 fi->flinks =
_free(fi->flinks);
1239 fi->flangs =
_free(fi->flangs);
1240 fi->fdigests =
_free(fi->fdigests);
1241 fi->digests =
_free(fi->digests);
1243 fi->cdict =
_free(fi->cdict);
1245 fi->fuser =
_free(fi->fuser);
1246 fi->fgroup =
_free(fi->fgroup);
1248 fi->fstates =
_free(fi->fstates);
1250 fi->fmtimes =
_free(fi->fmtimes);
1251 fi->fmodes =
_free(fi->fmodes);
1252 fi->fflags =
_free(fi->fflags);
1253 fi->vflags =
_free(fi->vflags);
1254 fi->fsizes =
_free(fi->fsizes);
1255 fi->frdevs =
_free(fi->frdevs);
1256 fi->finodes =
_free(fi->finodes);
1257 fi->dil =
_free(fi->dil);
1259 fi->fcolors =
_free(fi->fcolors);
1260 fi->fcdictx =
_free(fi->fcdictx);
1261 fi->ddict =
_free(fi->ddict);
1262 fi->fddictx =
_free(fi->fddictx);
1263 fi->fddictn =
_free(fi->fddictn);
1270 fi->exclude =
mireFreeAll(fi->exclude, fi->nexclude);
1271 fi->include =
mireFreeAll(fi->include, fi->ninclude);
1273 fi->fn =
_free(fi->fn);
1274 fi->apath =
_free(fi->apath);
1275 fi->fmapflags =
_free(fi->fmapflags);
1277 fi->obnl =
_free(fi->obnl);
1278 fi->odnl =
_free(fi->odnl);
1280 fi->fcontexts =
_free(fi->fcontexts);
1282 fi->actions =
_free(fi->actions);
1283 fi->replacedSizes =
_free(fi->replacedSizes);
1298 if (_rpmfiPool == NULL) {
1314 if (c >=
'0' && c <=
'9')
1316 if (c >=
'A' && c <=
'F')
1317 return (c -
'A') + 10;
1318 if (c >=
'a' && c <=
'f')
1319 return (c -
'a') + 10;
1323 #define _fdupestring(_h, _tag, _data) \
1325 xx = headerGet((_h), he, 0); \
1328 #define _fdupedata(_h, _tag, _data) \
1330 xx = headerGet((_h), he, 0); \
1338 int scareMem = (flags & 0x1);
1339 HE_t he = memset(
alloca(
sizeof(*he)), 0,
sizeof(*he));
1348 assert(scareMem == 0);
1360 fi->magic = RPMFIMAGIC;
1371 if (fi->fsm == NULL)
1380 fi->archiveSize = (xx && he->
p.
ui32p ? he->
p.
ui32p[0] : 0);
1394 if (xx == 0 && fi->isSource) {
1398 fi->bnl = he->
p.
argv;
1408 if (fi->dc == 0 && fi->isSource) {
1410 fi->dnl =
xcalloc(3,
sizeof(*fi->dnl));
1411 fi->dnl[0] = (
const char *)&fi->dnl[2];
1412 fi->dil =
xcalloc(fi->fc,
sizeof(*fi->dil));
1423 if (fi->fcolors != NULL)
1424 for (i = 0; i < (int)fi->fc; i++)
1425 fi->color |= fi->fcolors[i];
1436 if (xx == 0 || fi->fstates == NULL)
1437 fi->fstates =
xcalloc(fi->fc,
sizeof(*fi->fstates));
1442 if (fi->actions == NULL)
1443 fi->actions =
xcalloc(fi->fc,
sizeof(*fi->actions));
1453 fi->fdigestalgos = NULL;
1455 if (fi->fdigestalgos) {
1457 for (i = 0; i < (int)fi->fc; i++) {
1458 if (fi->fdigestalgos[i] == 0)
1461 dalgo = (fi->fdigestalgos[i] & 0xff);
1463 assert(dalgo == (
pgpHashAlgo)fi->fdigestalgos[i]);
1465 fi->fdigestalgos =
_free(fi->fdigestalgos);
1489 fi->digestalgo = dalgo;
1494 t =
xmalloc(fi->fc * fi->digestlen);
1496 for (i = 0; i < (int)fi->fc; i++) {
1497 const char * fdigests;
1500 fdigests = fi->fdigests[i];
1501 if (!(fdigests && *fdigests !=
'\0')) {
1502 memset(t, 0, fi->digestlen);
1506 for (j = 0; j < (int)fi->digestlen; j++, t++, fdigests += 2)
1509 fi->fdigests =
_free(fi->fdigests);
1518 fi->replacedSizes =
xcalloc(fi->fc,
sizeof(*fi->replacedSizes));
1529 const char * fmt =
rpmGetPath(
"%{?_autorelocate_path}", NULL);
1530 const char * errstr;
1540 if (newPath != NULL && *newPath !=
'\0' && p->relocs != NULL)
1541 for (i = 0; i < p->nrelocs; i++) {
1543 if (strcmp(p->relocs[i].oldPath,
"/"))
1545 if (strcmp(p->relocs[i].newPath, newPath))
1553 if (newPath != NULL && *newPath !=
'\0' && i == p->nrelocs) {
1556 xrealloc(p->relocs, (p->nrelocs + 2) *
sizeof(*p->relocs));
1557 p->relocs[p->nrelocs].oldPath =
xstrdup(
"/");
1558 p->relocs[p->nrelocs].newPath =
xstrdup(newPath);
1559 p->autorelocatex = p->nrelocs;
1561 p->relocs[p->nrelocs].oldPath = NULL;
1562 p->relocs[p->nrelocs].newPath = NULL;
1564 newPath =
_free(newPath);
1567 if (fi->actions == NULL)
1568 fi->actions =
xcalloc(fi->fc,
sizeof(*fi->actions));
1579 if (fi->isSource && fi->dc == 1 && *fi->dnl[0] ==
'\0') {
1580 const char ** av =
xcalloc(4+1,
sizeof(*av));
1593 fi->dnl =
_free(fi->dnl);
1595 nb = fi->dc *
sizeof(*av);
1596 for (i = 0; i < (int)fi->dc; i++)
1597 nb += strlen(av[i]) +
sizeof(
"/");
1600 te = (
char *) (&fi->dnl[fi->dc]);
1602 for (i = 0; i < (int)fi->dc; i++) {
1610 for (i = 0; i < (int)fi->fc; i++) {
1620 const char * b = fi->bnl[i];
1621 const char * be = b + strlen(b) -
sizeof(
".spec") - 1;
1623 fi->dil[i] = (be > b && !strcmp(be,
".spec") ? 1 : 0);
1634 for (i = 0; i < (int)fi->fc; i++) {
1635 size_t fnlen = strlen(fi->dnl[fi->dil[i]]) + strlen(fi->bnl[i]);
1636 if (fnlen > fi->fnlen)
1646 fprintf(stderr,
"*** fi %p\t%s[%d]\n", fi, Type, (fi ? fi->fc : 0));
1650 return rpmfiLink(fi, (fi ? fi->Type : NULL));
1658 *relp =
xrealloc(*relp,
sizeof(**relp) * ((*nrelp) + 1));
1660 (*relp)[*nrelp].oldPath = (oldPath ?
xstrdup(oldPath) : NULL);
1661 (*relp)[*nrelp].newPath = (newPath ?
xstrdup(newPath) : NULL);
1674 relocs =
_free(relocs);
1690 newr =
xmalloc((nrelocs + 1) *
sizeof(*relocs));
1700 *nrelocsp = nrelocs;
1708 if (st != NULL && fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc) {
1709 memset(st, 0,
sizeof(*st));
1711 st->st_rdev = fi->frdevs[fi->i];
1712 st->st_ino = fi->finodes[fi->i];
1713 st->st_mode = fi->fmodes[fi->i];
1714 st->st_nlink =
rpmfiFNlink(fi) + (int)S_ISDIR(st->st_mode);
1715 if (
unameToUid(fi->fuser[fi->i], &st->st_uid) == -1)
1717 if (
gnameToGid(fi->fgroup[fi->i], &st->st_gid) == -1)
1719 st->st_size = fi->fsizes[fi->i];
1720 st->st_blksize = 4 * 1024;
1721 st->st_blocks = (st->st_size + (st->st_blksize - 1)) / st->st_blksize;
1724 st->st_mtime = fi->fmtimes[fi->i];
1733 size_t pathlen = strlen(path);
1737 while (pathlen > 0 && path[pathlen-1] ==
'/')
1741 if (!(fi != NULL && fi->i >= 0 && fi->i < (
int)fi->fc))
1745 const char * fn =
rpmfiFN(fi);
1746 size_t fnlen = strlen(fn);
1748 if (pathlen != fnlen || strncmp(path, fn, fnlen))
1756 fprintf(stderr,
"*** rpmfiStat(%p, %s, %p) rc %d\n", fi, path, st, rc);
1764 const char * dn =
name;
1765 size_t dnlen = strlen(dn);
1766 const char ** fnames = NULL;
1773 fmodes =
xcalloc(fi->fc,
sizeof(*fmodes));
1778 const char * fn =
rpmfiFN(fi);
1779 size_t fnlen = strlen(fn);
1783 if (strncmp(dn, fn, dnlen) || fn[dnlen] !=
'/')
1788 xx =
argvAdd(&fnames, fn + dnlen + 1);
1789 fmodes[j++] = fi->fmodes[i];
1793 dir = (DIR *)
avOpendir(name, fnames, fmodes);
1796 fmodes =
_free(fmodes);
1800 fprintf(stderr,
"*** rpmfiOpendir(%p, %s) dir %p\n", fi, name, dir);
1811 const char * FClass;
1817 if ((ac =
rpmfiFC(fi)) <= 0) {
1824 nb = (ac + 1) *
sizeof(*av);
1829 if (FClass && *FClass !=
'\0')
1830 nb += strlen(FClass);
1836 t = ((
char *) av) + ((ac + 1) *
sizeof(*av));
1843 if (FClass && *FClass !=
'\0')
1863 const char * fcontext;
1869 if ((ac =
rpmfiFC(fi)) <= 0) {
1876 nb = (ac + 1) *
sizeof(*av);
1881 if (fcontext && *fcontext !=
'\0')
1882 nb += strlen(fcontext);
1888 t = ((
char *) av) + ((ac + 1) *
sizeof(*av));
1895 if (fcontext && *fcontext !=
'\0')
1919 char * fctxt = NULL;
1920 size_t fctxtlen = 0;
1923 if ((ac =
rpmfiFC(fi)) <= 0) {
1930 nb = ac *
sizeof(*fcnb);
1931 fcnb = memset(
alloca(nb), 0, nb);
1942 fctxt =
xrealloc(fctxt, fctxtlen + fcnb[ac]);
1943 memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
1944 fctxtlen += fcnb[ac];
1951 nb = (ac + 1) *
sizeof(*av) + fctxtlen;
1953 t = ((
char *) av) + ((ac + 1) *
sizeof(*av));
1954 if (fctxt != NULL && fctxtlen > 0)
1955 (void) memcpy(t, fctxt, fctxtlen);
1983 const char ** av = NULL;
1987 char * fctxt = NULL;
1988 size_t fctxtlen = 0;
1991 if ((ac =
rpmfiFC(fi)) <= 0) {
1997 {
const char *fn =
rpmGetPath(
"%{?__file_context_path}", NULL);
1999 if (fn != NULL && *fn !=
'\0')
2006 nb = ac *
sizeof(*fcnb);
2007 fcnb = memset(
alloca(nb), 0, nb);
2020 if (
matchpathcon(fn, fmode, &scon) == 0 && scon != NULL) {
2021 fcnb[ac] = strlen(scon) + 1;
2023 fctxt =
xrealloc(fctxt, fctxtlen + fcnb[ac]);
2024 memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
2025 fctxtlen += fcnb[ac];
2034 nb = (ac + 1) *
sizeof(*av) + fctxtlen;
2036 t = ((
char *) av) + ((ac + 1) *
sizeof(*av));
2037 (void) memcpy(t, fctxt, fctxtlen);
2080 if ((ac =
rpmfiFC(fi)) <= 0) {
2094 nb = (ac + 1) *
sizeof(*av);
2103 mydt = ((ix >> 24) & 0xff);
2104 if (mydt != deptype)
2112 nb += strlen(DNEVR+2) + 1;
2119 t = ((
char *) av) + ((ac + 1) *
sizeof(*av));
2130 mydt = ((ix >> 24) & 0xff);
2131 if (mydt != deptype)
2138 if (DNEVR != NULL) {