15 #include "../rpmdb/rpmtag.h"
20 #define _IOSM_INTERNAL
22 #define iosmUNSAFE iosmStage
29 #define _RPMFI_INTERNAL
30 #define _RPMFI_NOMETHODS
31 #include "../lib/rpmfi.h"
36 #if defined(_USE_RPMTE)
42 #if defined(_USE_RPMSX)
43 #include "../lib/rpmsx.h"
51 #if defined(_USE_RPMTS)
63 #define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s))
79 #if defined(_USE_RPMTS)
80 void * iosmGetTs(
const IOSM_t iosm)
82 const IOSMI_t iter = iosm->iter;
84 return (iter ? iter->ts : NULL);
91 const IOSMI_t iter = iosm->iter;
93 return (iter ? iter->fi : NULL);
97 #define SUFFIX_RPMORIG ".rpmorig"
98 #define SUFFIX_RPMSAVE ".rpmsave"
99 #define SUFFIX_RPMNEW ".rpmnew"
111 const struct stat *
st,
117 const char * s = NULL;
122 nb = strlen(iosm->dirName) +
123 (st && !S_ISDIR(st->st_mode) ? (subdir ? strlen(subdir) : 0) : 0) +
124 (st && !S_ISDIR(st->st_mode) ? (suffix ? strlen(suffix) : 0) : 0) +
125 strlen(iosm->baseName) + 1;
127 t =
stpcpy(t, iosm->dirName);
128 if (st && !S_ISDIR(st->st_mode))
129 if (subdir) t =
stpcpy(t, subdir);
130 t =
stpcpy(t, iosm->baseName);
131 if (st && !S_ISDIR(st->st_mode))
132 if (suffix) t =
stpcpy(t, suffix);
147 #if !defined(_RPMFI_NOMETHODS)
168 iter =
xcalloc(1,
sizeof(*iter));
169 #if !defined(_RPMFI_NOMETHODS)
175 iter->i = (iter->reverse ? (fi->fc - 1) : 0);
176 iter->isave = iter->i;
194 if (iter->i >= 0) i = iter->i--;
196 if (iter->i < (
int) ((
rpmfi)iter->fi)->fc) i = iter->i++;
208 const char * aurl = *(
const char **)a;
209 const char * burl = *(
const char **)b;
210 const char * afn = NULL;
211 const char * bfn = NULL;
216 #ifdef VERY_OLD_BUGGY_RPM_PACKAGES
218 if (strchr(afn,
'/') == NULL)
219 bfn = strrchr(bfn,
'/') + 1;
223 if (afn[0] ==
'.' && afn[1] ==
'/') afn += 2;
224 if (bfn[0] ==
'.' && bfn[1] ==
'/') bfn += 2;
227 if (afn[0] ==
'/') afn += 1;
228 if (bfn[0] ==
'/') bfn += 1;
230 return strcmp(afn, bfn);
239 static int mapFind( IOSMI_t iter,
const char * iosmPath)
246 const rpmfi fi = iter->fi;
248 #if !defined(_RPMFI_NOMETHODS)
251 size_t fc = (fi ? fi->fc : 0);
253 if (fi && fc > 0 && fi->apath && iosmPath && *iosmPath) {
254 const char ** p = NULL;
256 if (fi->apath != NULL)
257 p = bsearch(&iosmPath, fi->apath, fc,
sizeof(iosmPath),
260 iter->i = p - fi->apath;
300 return (
int) (dnli ? dnli->
fi->dc : 0);
308 return (dnli ? dnli->
isave : -1);
331 dnli =
xcalloc(1,
sizeof(*dnli));
334 dnli->
i = (int) (reverse ? fi->dc : 0);
340 #if !defined(_RPMFI_NOMETHODS)
344 for (i = 0; i < (int)fi->fc; i++)
348 dnli->
active[fi->dil[i]] = (
char)1;
352 #if !defined(_RPMFI_NOMETHODS)
356 for (i = 0; i < (int)fi->fc; i++)
362 if (!S_ISDIR(fi->fmodes[i]))
366 dnlen = strlen(fi->dnl[dil]);
367 bnlen = strlen(fi->bnl[i]);
369 for (j = 0; j < (int)fi->dc; j++) {
372 if (!dnli->
active[j] || j == (
int)dil)
374 (void)
urlPath(fi->dnl[j], &dnl);
376 if (jlen != (dnlen+bnlen+1))
378 if (strncmp(dnl, fi->dnl[dil], dnlen))
380 if (strncmp(dnl+dnlen, fi->bnl[i], bnlen))
382 if (dnl[dnlen+bnlen] !=
'/' || dnl[dnlen+bnlen+1] !=
'\0')
385 dnli->
active[j] = (char)0;
393 for (i = 0; i < (int)fi->dc; i++) {
394 if (!dnli->
active[i])
continue;
398 D_(
"========== Directories not explicitly included in package:\n"));
400 (void)
urlPath(fi->dnl[i], &dnl);
420 const char * dn = NULL;
428 i = (!dnli->
reverse ? dnli->
i++ : --dnli->
i);
429 }
while (i >= 0 && i < (
int)fi->dc && !dnli->
active[i]);
431 if (i >= 0 && i < (
int)fi->dc)
440 #if defined(WITH_PTHREADS)
441 static void * iosmThread(
void * arg)
447 return ((
void *) ((
long)
iosmStage(iosm, iosm->nstage)));
456 iosm->nstage = nstage;
457 #if defined(WITH_PTHREADS)
458 if (iosm->multithreaded)
476 struct stat * st = &iosm->sb;
482 for (iosm->li = iosm->links; iosm->li; iosm->li = iosm->li->next) {
483 if (iosm->li->sb.st_ino == st->st_ino && iosm->li->sb.st_dev == st->st_dev)
488 if (iosm->li == NULL) {
489 iosm->li =
xcalloc(1,
sizeof(*iosm->li));
490 iosm->li->next = NULL;
492 iosm->li->nlink = (int) st->st_nlink;
493 iosm->li->linkIndex = iosm->ix;
494 iosm->li->createdPath = -1;
496 iosm->li->filex =
xcalloc(st->st_nlink,
sizeof(iosm->li->filex[0]));
497 memset(iosm->li->filex, -1, (st->st_nlink *
sizeof(iosm->li->filex[0])));
498 iosm->li->nsuffix =
xcalloc(st->st_nlink,
sizeof(*iosm->li->nsuffix));
501 iosm->li->linksLeft = (int) st->st_nlink;
503 iosm->li->linksLeft = 0;
506 iosm->li->next = iosm->links;
508 iosm->links = iosm->li;
512 iosm->li->filex[iosm->li->linksLeft] = iosm->ix;
514 iosm->li->nsuffix[iosm->li->linksLeft] = iosm->nsuffix;
519 return (iosm->li->linksLeft > 0);
524 if (!(st->st_size || iosm->li->linksLeft == (
int) st->st_nlink))
530 for (j = iosm->li->linksLeft - 1; j >= 0; j--) {
531 ix = iosm->li->filex[j];
543 iosm->li->linkIndex = j;
544 iosm->path =
_free(iosm->path);
559 li->nsuffix =
_free(li->nsuffix);
560 li->filex =
_free(li->filex);
574 iosm->path =
_free(iosm->path);
575 while ((iosm->li = iosm->links) != NULL) {
576 iosm->links = iosm->li->next;
577 iosm->li->next = NULL;
580 iosm->dnlx =
_free(iosm->dnlx);
581 iosm->ldn =
_free(iosm->ldn);
596 #if !defined(_RPMFI_NOMETHODS)
602 for (i = 0; i < (int)fi->fc; i++)
607 const char * apath = NULL;
608 (void)
urlPath(fi->apath[ix], &apath);
609 path = apath + fi->striplen;
612 #if !defined(_RPMFI_NOMETHODS)
617 if ((nb = strlen(path)) < 15)
627 iosm->lmtab = t =
xmalloc(lmtablen + 1);
628 iosm->lmtablen = lmtablen;
630 #if !defined(_RPMFI_NOMETHODS)
635 for (i = 0; i < (int)fi->fc; i++)
640 const char * apath = NULL;
641 (void)
urlPath(fi->apath[ix], &apath);
642 path = apath + fi->striplen;
645 #if !defined(_RPMFI_NOMETHODS)
650 if ((nb = strlen(path)) < 15)
661 const void * _ts,
const void *
_fi,
FD_t cfd,
662 unsigned int * archiveSize,
const char ** failedFile)
664 #if defined(_USE_RPMTS)
668 #if defined(_USE_RPMTE)
680 iosm->adding = adding;
684 fprintf(stderr,
"--> iosmSetup(%p, 0x%x, \"%s\", %p, %p, %p, %p, %p)\n", iosm, goal, afmt, (
void *)_ts, _fi, cfd, archiveSize, failedFile);
688 if (iosm->headerRead == NULL) {
689 if (afmt != NULL && (!strcmp(afmt,
"tar") || !strcmp(afmt,
"ustar"))) {
691 fprintf(stderr,
"\ttar vectors set\n");
697 if (afmt != NULL && !strcmp(afmt,
"ar")) {
699 fprintf(stderr,
"\tar vectors set\n");
709 fprintf(stderr,
"\tcpio vectors set\n");
720 iosm->cfd =
fdLink(cfd,
"persist (iosm)");
728 #if defined(_USE_RPMTS)
729 iosm->iter->ts =
rpmtsLink(ts,
"mapIterator");
734 #define _tsmask (RPMTRANS_FLAG_PKGCOMMIT | RPMTRANS_FLAG_COMMIT)
740 iosm->iter->ts = (
void *)_ts;
742 iosm->nofcontexts = 1;
743 iosm->nofdigests = 1;
749 #if defined(_USE_RPMTS)
756 iosm->archiveSize = archiveSize;
757 if (iosm->archiveSize)
758 *iosm->archiveSize = 0;
759 iosm->failedFile = failedFile;
760 if (iosm->failedFile)
761 *iosm->failedFile = NULL;
764 memset(iosm->sufbuf, 0,
sizeof(iosm->sufbuf));
767 #if defined(_USE_RPMTS)
770 static time_t now = 0;
771 if (now == 0) now = time(NULL);
774 if (tid > 0 && tid < 0xffffffff)
775 sprintf(iosm->sufbuf,
";%08x", (
unsigned)tid);
780 if (rc && !ec) ec = rc;
783 if (rc && !ec) ec = rc;
785 if (iosm->archiveSize && ec == 0)
798 fprintf(stderr,
"--> iosmTeardown(%p)\n", iosm);
802 iosm->lmtab =
_free(iosm->lmtab);
804 #if defined(_USE_RPMTS)
810 iosm->iter->ts = NULL;
813 if (iosm->cfd != NULL) {
814 iosm->cfd =
fdFree(iosm->cfd,
"persist (iosm)");
817 iosm->failedFile = NULL;
832 iosm->fcontext = NULL;
833 if (!iosm->nofcontexts) {
835 int xx =
matchpathcon(iosm->path, iosm->sb.st_mode, &scon);
838 if (!xx && scon != NULL)
839 iosm->fcontext = scon;
846 if (fi && i >= 0 && i < (
int)fi->fc)
847 iosm->fcontext = (fi->fcontexts ? fi->fcontexts[i] : NULL);
858 int teAdding = iosm->adding;
862 iosm->osuffix = NULL;
863 iosm->nsuffix = NULL;
866 iosm->mapFlags = fi->mapflags;
868 if (fi && i >= 0 && i < (
int)fi->fc) {
870 iosm->astriplen = fi->astriplen;
871 iosm->action = (fi->actions ? fi->actions[i] : fi->action);
872 iosm->fflags = (fi->fflags ? fi->fflags[i] : fi->flags);
873 iosm->mapFlags = (fi->fmapflags ? fi->fmapflags[i] : fi->mapflags);
876 iosm->dirName = fi->dnl[fi->dil[i]];
877 iosm->baseName = fi->bnl[i];
879 switch (iosm->action) {
893 if (fi->fstates && teAdding)
898 if (fi->fstates && teAdding)
903 if (fi->fstates && teAdding)
937 const struct stat * st = &iosm->sb;
938 iosm->path =
_free(iosm->path);
939 iosm->path =
iosmFsPath(iosm, st, iosm->subdir,
940 (iosm->suffix ? iosm->suffix : iosm->nsuffix));
948 struct stat * st = &iosm->sb;
952 if (fi && i >= 0 && i < (
int)fi->fc) {
953 mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms);
954 mode_t finalMode = (fi->fmodes ? (mode_t)fi->fmodes[i] : perms);
955 dev_t finalRdev = (fi->frdevs ? fi->frdevs[i] : 0);
956 rpmuint32_t finalMtime = (fi->fmtimes ? fi->fmtimes[i] : 0);
960 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK)
968 if (fi->fuser &&
unameToUid(fi->fuser[i], &uid)) {
969 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK)
974 _(
"user %s does not exist - using root\n"), fi->fuser[i]);
976 finalMode &= ~S_ISUID;
977 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK)
982 if (fi->fgroup &&
gnameToGid(fi->fgroup[i], &gid)) {
983 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK)
988 _(
"group %s does not exist - using root\n"), fi->fgroup[i]);
990 finalMode &= ~S_ISGID;
991 #if defined(RPM_VENDOR_OPENPKG) || defined(RPM_VENDOR_MANDRIVA) || defined(RPM_VENDOR_ARK)
997 st->st_mode = (st->st_mode & S_IFMT) | (finalMode & ~S_IFMT);
999 st->st_mode = (st->st_mode & ~S_IFMT) | (finalMode & S_IFMT);
1000 if ((S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
1001 && st->st_nlink == 0)
1003 st->st_rdev = finalRdev;
1004 st->st_mtime = finalMtime;
1014 if (!iosm->nofdigests) {
1015 iosm->fdigestalgo = fi->digestalgo;
1016 iosm->fdigest = (fi->fdigests ? fi->fdigests[i] : NULL);
1017 iosm->digestlen = fi->digestlen;
1018 iosm->digest = (fi->digests ? (fi->digests + (iosm->digestlen * i)) : NULL);
1020 iosm->fdigestalgo = 0;
1021 iosm->fdigest = NULL;
1022 iosm->digestlen = 0;
1023 iosm->digest = NULL;
1040 const struct stat * st = &iosm->sb;
1041 size_t left = (size_t) st->st_size;
1049 if (st->st_size > 0 && (iosm->fdigest != NULL || iosm->digest != NULL))
1054 iosm->wrlen = (left > iosm->wrsize ? iosm->wrsize : left);
1070 xx = fsync(
Fileno(iosm->wfd));
1072 if (st->st_size > 0 && (iosm->fdigest || iosm->digest)) {
1073 void * digest = NULL;
1074 int asAscii = (iosm->digest == NULL ? 1 : 0);
1076 (void)
Fflush(iosm->wfd);
1077 fdFiniDigest(iosm->wfd, iosm->fdigestalgo, &digest, NULL, asAscii);
1079 if (digest == NULL) {
1080 rc = IOSMERR_DIGEST_MISMATCH;
1084 if (iosm->digest != NULL) {
1085 if (memcmp(digest, iosm->digest, iosm->digestlen))
1086 rc = IOSMERR_DIGEST_MISMATCH;
1088 if (strcmp(digest, iosm->fdigest))
1089 rc = IOSMERR_DIGEST_MISMATCH;
1091 digest =
_free(digest);
1112 const char * path = iosm->path;
1113 const char * opath = iosm->opath;
1114 struct stat * st = &iosm->sb;
1115 struct stat * ost = &iosm->osb;
1120 st->st_size = (writeData ? ost->st_size : 0);
1122 if (S_ISDIR(st->st_mode)) {
1124 }
else if (
S_ISLNK(st->st_mode)) {
1132 st->st_size = iosm->rdnb;
1133 iosm->lpath =
xstrdup(iosm->rdbuf);
1137 size_t nb=strlen(iosm->dirName) + strlen(iosm->baseName) +
sizeof(
".");
1147 const char * apath = NULL;
1148 (void)
urlPath(fi->apath[iosm->ix], &apath);
1149 iosm->path = apath + fi->striplen;
1151 iosm->path = fi->bnl[iosm->ix];
1158 if (writeData && S_ISREG(st->st_mode)) {
1159 #if defined(HAVE_MMAP)
1160 char * rdbuf = NULL;
1161 void * mapped = (
void *)-1;
1164 int use_mmap = (st->st_size <= 0x07ffffff);
1171 #if defined(HAVE_MMAP)
1173 mapped = mmap(NULL, st->st_size, PROT_READ, MAP_SHARED,
Fileno(iosm->rfd), 0);
1174 if (mapped != (
void *)-1) {
1175 rdbuf = iosm->rdbuf;
1176 iosm->rdbuf = (
char *) mapped;
1177 iosm->rdlen = nmapped = st->st_size;
1178 #if defined(HAVE_MADVISE) && defined(MADV_DONTNEED)
1179 xx = madvise(mapped, nmapped, MADV_DONTNEED);
1188 #if defined(HAVE_MMAP)
1189 if (mapped != (
void *)-1) {
1190 iosm->rdnb = nmapped;
1194 iosm->rdlen = (left > iosm->rdsize ? iosm->rdsize : left),
1206 #if defined(HAVE_MMAP)
1207 if (mapped != (
void *)-1) {
1209 xx = msync(mapped, nmapped, MS_ASYNC);
1210 #if defined(HAVE_MADVISE) && defined(MADV_DONTNEED)
1211 xx = madvise(mapped, nmapped, MADV_DONTNEED);
1213 xx = munmap(mapped, nmapped);
1214 iosm->rdbuf = rdbuf;
1217 xx = fsync(
Fileno(iosm->rfd));
1227 if (iosm->rfd != NULL)
1230 iosm->opath = opath;
1247 const char * path = iosm->path;
1248 const char * lpath = iosm->lpath;
1249 const char * nsuffix = iosm->nsuffix;
1250 int iterIndex = iosm->ix;
1254 const char * linkpath = NULL;
1259 iosm->nsuffix = NULL;
1262 for (i = iosm->li->nlink - 1; i >= 0; i--) {
1264 if (iosm->li->filex[i] < 0)
continue;
1266 iosm->ix = iosm->li->filex[i];
1274 const char * apath = NULL;
1276 (void)
urlPath(iosm->path, &apath);
1278 t =
xmalloc(
sizeof(
".") + strlen(apath + iosm->astriplen));
1279 (void)
stpcpy(
stpcpy(t,
"."), apath + iosm->astriplen);
1283 iosm->lpath = linkpath;
1286 rc =
writeFile(iosm, (iosm->lpath == NULL));
1291 if (iosm->failedFile && rc != 0 && *iosm->failedFile == NULL) {
1293 *iosm->failedFile =
xstrdup(iosm->path);
1296 iosm->path =
_free(iosm->path);
1297 iosm->li->filex[i] = -1;
1301 linkpath =
_free(linkpath);
1303 iosm->ix = iterIndex;
1304 iosm->nsuffix = nsuffix;
1305 iosm->lpath = lpath;
1321 const char * path = iosm->path;
1322 const char * opath = iosm->opath;
1323 const char * nsuffix = iosm->nsuffix;
1324 int iterIndex = iosm->ix;
1331 iosm->nsuffix = NULL;
1334 iosm->ix = iosm->li->filex[iosm->li->createdPath];
1336 iosm->opath = iosm->path;
1338 for (i = 0; i < iosm->li->nlink; i++) {
1339 if (iosm->li->filex[i] < 0)
continue;
1340 if (iosm->li->createdPath == i)
continue;
1342 iosm->ix = iosm->li->filex[i];
1343 iosm->path =
_free(iosm->path);
1349 if (!(rc == IOSMERR_ENOENT))
break;
1353 if (iosm->failedFile && rc != 0 && *iosm->failedFile == NULL) {
1355 *iosm->failedFile =
xstrdup(iosm->path);
1358 iosm->li->linksLeft--;
1360 iosm->path =
_free(iosm->path);
1361 iosm->opath =
_free(iosm->opath);
1363 iosm->ix = iterIndex;
1364 iosm->nsuffix = nsuffix;
1366 iosm->opath = opath;
1383 const char * path = iosm->path;
1384 const char * nsuffix = iosm->nsuffix;
1385 int iterIndex = iosm->ix;
1386 struct stat * st = &iosm->sb;
1391 iosm->nsuffix = NULL;
1394 for (iosm->li = iosm->links; iosm->li; iosm->li = iosm->li->next) {
1395 if (iosm->li->sb.st_ino == st->st_ino && iosm->li->sb.st_dev == st->st_dev)
1399 for (i = 0; i < iosm->li->nlink; i++) {
1400 if (iosm->li->filex[i] < 0)
continue;
1401 iosm->ix = iosm->li->filex[i];
1405 iosm->path =
_free(iosm->path);
1406 iosm->li->filex[i] = -1;
1409 iosm->ix = iterIndex;
1410 iosm->nsuffix = nsuffix;
1426 const char * path = iosm->path;
1428 char * dn = iosm->rdbuf;
1435 if (iosm->ldn != NULL && iosm->dnlx != NULL)
1437 size_t dnlen = strlen(iosm->path);
1441 if (iosm->dnlx[dc] < 1 || (
size_t)iosm->dnlx[dc] >= dnlen)
1445 te =
stpcpy(dn, iosm->path) - 1;
1461 }
while ((te - iosm->path) > iosm->dnlx[dc]);
1483 struct stat * st = &iosm->sb;
1484 struct stat * ost = &iosm->osb;
1485 const char * path = iosm->path;
1486 mode_t st_mode = st->st_mode;
1488 char * dn = iosm->rdbuf;
1496 iosm->dnlx = (dc ?
xcalloc(dc,
sizeof(*iosm->dnlx)) : NULL);
1498 if (iosm->dnlx != NULL)
1500 size_t dnlen = strlen(iosm->path);
1504 if (dc < 0)
continue;
1505 iosm->dnlx[
dc] = (
unsigned short) dnlen;
1510 if (dnlen <= iosm->ldnlen && !strcmp(iosm->path, iosm->ldn))
1515 (void)
stpcpy(dn, iosm->path);
1519 (void)
urlPath(dn, (
const char **)&te);
1520 for (i = 1, te++; *te !=
'\0'; te++, i++) {
1528 if (i < iosm->ldnlen &&
1529 (iosm->ldn[i] ==
'/' || iosm->ldn[i] ==
'\0') &&
1530 !strncmp(iosm->path, iosm->ldn, i))
1534 iosm->dnlx[
dc] = (te - dn);
1544 if (rc == 0 && S_ISDIR(ost->st_mode)) {
1546 iosm->dnlx[
dc] = (te - dn);
1547 }
else if (rc == IOSMERR_ENOENT) {
1550 st->st_mode = S_IFDIR | (fi->dperms & 07777);
1553 #if defined(_USE_RPMSX)
1557 if (!fsm->nofcontexts
1561 iosm->fcontext = scon;
1565 iosm->fcontext = NULL;
1566 if (iosm->fcontext == NULL)
1568 D_(
"%s directory created with perms %04o, no context.\n"),
1569 iosm->path, (
unsigned)(st->st_mode & 07777));
1572 D_(
"%s directory created with perms %04o, context %s.\n"),
1573 iosm->path, (
unsigned)(st->st_mode & 07777),
1575 #if defined(_USE_RPMSX)
1576 iosm->fcontext = NULL;
1590 if (iosm->ldnalloc < (dnlen + 1)) {
1591 iosm->ldnalloc = dnlen + 100;
1592 iosm->ldn =
xrealloc(iosm->ldn, iosm->ldnalloc);
1594 if (iosm->ldn != NULL) {
1595 strcpy(iosm->ldn, iosm->path);
1596 iosm->ldnlen = dnlen;
1604 st->st_mode = st_mode;
1616 static int iosmStat(
IOSM_t iosm)
1622 if (iosm->path != NULL) {
1623 int saveernno =
errno;
1626 if (rc == IOSMERR_ENOENT) {
1630 }
else if (rc == 0) {
1641 #define IS_DEV_LOG(_x) \
1642 ((_x) != NULL && strlen(_x) >= (sizeof("/dev/log")-1) && \
1643 !strncmp((_x), "/dev/log", sizeof("/dev/log")-1) && \
1644 ((_x)[sizeof("/dev/log")-1] == '\0' || \
1645 (_x)[sizeof("/dev/log")-1] == ';'))
1655 struct stat * st = &iosm->sb;
1656 struct stat * ost = &iosm->osb;
1657 int saveerrno =
errno;
1662 #define _fafilter(_a) \
1663 (!((_a) == FA_CREATE || (_a) == FA_ERASE || (_a) == FA_COPYIN || (_a) == FA_COPYOUT) \
1664 ? iosmFileActionString(_a) : "")
1672 (
unsigned)st->st_mode, (
int)st->st_nlink,
1673 (
int)st->st_uid, (
int)st->st_gid, (
unsigned long)st->st_size,
1674 (iosm->path ? iosm->path :
""),
1677 const char * apath = NULL;
1679 (void)
urlPath(iosm->path, &apath);
1680 iosm->stage = stage;
1684 (
unsigned)st->st_mode, (int)st->st_nlink,
1685 (
int)st->st_uid, (int)st->st_gid, (
unsigned long)st->st_size,
1686 (apath ? apath + iosm->astriplen :
""),
1700 if (rc == IOSMERR_HDR_TRAILER) {
1735 if (rc == IOSMERR_HDR_TRAILER) {
1751 if (rc == IOSMERR_HDR_TRAILER) {
1780 while ((iosm->li = iosm->links) != NULL) {
1781 iosm->links = iosm->li->next;
1782 iosm->li->next = NULL;
1785 for (j = -1, nlink = 0, i = 0; i < iosm->li->nlink; i++) {
1786 if (iosm->li->filex[i] < 0)
1793 iosm->li->filex[0] = iosm->li->filex[j];
1794 iosm->li->filex[j] = -1;
1796 iosm->li->sb.st_nlink = nlink;
1798 iosm->sb = iosm->li->sb;
1799 iosm->osb = iosm->sb;
1812 iosm->path =
_free(iosm->path);
1813 iosm->lpath =
_free(iosm->lpath);
1814 iosm->opath =
_free(iosm->opath);
1815 iosm->dnlx =
_free(iosm->dnlx);
1817 iosm->ldn =
_free(iosm->ldn);
1818 iosm->ldnalloc = iosm->ldnlen = 0;
1820 iosm->rdsize = iosm->wrsize = 0;
1821 iosm->rdbuf = iosm->rdb =
_free(iosm->rdb);
1822 iosm->wrbuf = iosm->wrb =
_free(iosm->wrb);
1824 iosm->rdsize = 16 * BUFSIZ;
1825 iosm->rdbuf = iosm->rdb =
xmalloc(iosm->rdsize);
1826 iosm->wrsize = 16 * BUFSIZ;
1827 iosm->wrbuf = iosm->wrb =
xmalloc(iosm->wrsize);
1830 iosm->mkdirsdone = 0;
1841 if (!rc) iosm->mkdirsdone = 1;
1846 iosm->path =
_free(iosm->path);
1847 iosm->lpath =
_free(iosm->lpath);
1849 iosm->diskchecked = iosm->exists = 0;
1850 iosm->subdir = NULL;
1851 iosm->suffix = (iosm->sufbuf[0] !=
'\0' ? iosm->sufbuf : NULL);
1853 iosm->osuffix = NULL;
1854 iosm->nsuffix = NULL;
1874 _(
"archive file %s was not found in header file list\n"),
1877 if (iosm->failedFile && *iosm->failedFile == NULL)
1878 *iosm->failedFile =
xstrdup(iosm->path);
1879 rc = IOSMERR_UNMAPPED_FILE;
1881 rc = IOSMERR_HDR_TRAILER;
1889 st->st_mode = fi->fmodes[iosm->ix];
1900 rc = iosmStat(iosm);
1902 if (iosm->path != NULL &&
1907 if (rc == IOSMERR_ENOENT) {
1911 }
else if (rc == 0) {
1919 iosm->diskchecked = 1;
1933 if (S_ISREG(st->st_mode) && st->st_nlink > 1)
1954 if (iosm->postpone) {
1957 if (S_ISREG(st->st_mode))
1966 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
1967 struct hardLink_s * li, * prev;
1973 for (li = iosm->links, prev = NULL; li; prev = li, li = li->next)
1978 iosm->links = iosm->li->next;
1980 prev->next = iosm->li->next;
1981 iosm->li->next = NULL;
1992 if (S_ISREG(st->st_mode) && iosm->lpath != NULL) {
1993 const char * opath = iosm->opath;
1994 char * t =
xmalloc(strlen(iosm->lpath+1) + strlen(iosm->suffix) + 1);
1995 (void)
stpcpy(t, iosm->lpath+1);
1999 if (iosm->failedFile && rc != 0 && *iosm->failedFile == NULL) {
2000 *iosm->failedFile =
xstrdup(iosm->path);
2002 iosm->opath =
_free(iosm->opath);
2003 iosm->opath = opath;
2006 if (S_ISREG(st->st_mode)) {
2007 const char * path = iosm->path;
2009 iosm->path =
iosmFsPath(iosm, st, NULL, NULL);
2012 if (rc == 0 && iosm->osuffix) {
2013 const char * opath = iosm->opath;
2014 iosm->opath = iosm->path;
2015 iosm->path =
iosmFsPath(iosm, st, NULL, iosm->osuffix);
2019 _(
"%s saved as %s\n"),
2020 (iosm->opath ? iosm->opath :
""),
2021 (iosm->path ? iosm->path :
""));
2022 iosm->path =
_free(iosm->path);
2023 iosm->opath = opath;
2029 if (!(rc == IOSMERR_ENOENT))
return rc;
2031 }
else if (S_ISDIR(st->st_mode)) {
2032 mode_t st_mode = st->st_mode;
2034 if (rc == IOSMERR_ENOENT) {
2035 st->st_mode &= ~07777;
2036 st->st_mode |= 00700;
2038 st->st_mode = st_mode;
2040 }
else if (
S_ISLNK(st->st_mode)) {
2041 assert(iosm->lpath != NULL);
2043 if (rc == IOSMERR_ENOENT)
2045 }
else if (S_ISFIFO(st->st_mode)) {
2046 mode_t st_mode = st->st_mode;
2049 if (rc == IOSMERR_ENOENT) {
2052 st->st_mode = st_mode;
2054 }
else if (S_ISCHR(st->st_mode) ||
2055 S_ISBLK(st->st_mode) ||
2059 if (rc == IOSMERR_ENOENT)
2063 if (iosm->repackaged)
2068 rc = IOSMERR_UNKNOWN_FILETYPE;
2070 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
2071 iosm->li->createdPath = iosm->li->linkIndex;
2084 if (archivePos > fi->archivePos) {
2085 fi->archivePos = (
unsigned long long) archivePos;
2086 #if defined(_USE_RPMTS)
2088 fi->archivePos, fi->archiveSize);
2098 if (iosm->sufbuf[0] !=
'\0')
2108 if (iosm->failedFile && *iosm->failedFile == NULL)
2109 *iosm->failedFile =
xstrdup(iosm->path);
2112 if (!iosm->postpone && iosm->commit) {
2114 rc = ((S_ISREG(st->st_mode) && st->st_nlink > 1)
2121 iosm->path =
_free(iosm->path);
2122 iosm->lpath =
_free(iosm->lpath);
2123 iosm->opath =
_free(iosm->opath);
2124 memset(st, 0,
sizeof(*st));
2125 memset(ost, 0,
sizeof(*ost));
2129 if (iosm->osuffix && iosm->diskchecked &&
2130 (iosm->exists || (iosm->goal ==
IOSM_PKGINSTALL && S_ISREG(st->st_mode))))
2132 const char * opath = iosm->opath;
2133 const char * path = iosm->path;
2134 iosm->opath =
iosmFsPath(iosm, st, NULL, NULL);
2135 iosm->path =
iosmFsPath(iosm, st, NULL, iosm->osuffix);
2139 (iosm->opath ? iosm->opath :
""),
2140 (iosm->path ? iosm->path :
""));
2142 iosm->path =
_free(iosm->path);
2144 iosm->opath =
_free(iosm->opath);
2145 iosm->opath = opath;
2151 if (S_ISDIR(st->st_mode)) {
2155 case IOSMERR_ENOENT:
2156 case IOSMERR_ENOTEMPTY:
2164 _(
"rmdir of %s failed: Directory not empty\n"),
2169 (iosm->strict_erasures ?
RPMLOG_ERR : RPMLOG_DEBUG),
2170 _(
"rmdir of %s failed: %s\n"),
2171 iosm->path, strerror(
errno));
2178 case IOSMERR_ENOENT:
2185 _(
"unlink of %s failed: %s\n"),
2186 iosm->path, strerror(
errno));
2192 if (!iosm->strict_erasures) rc = 0;
2201 if (!S_ISDIR(st->st_mode) &&
2202 (iosm->subdir || iosm->suffix || iosm->nsuffix))
2204 iosm->opath = iosm->path;
2205 iosm->path =
iosmFsPath(iosm, st, NULL, iosm->nsuffix);
2208 (void)
Unlink(iosm->opath);
2209 else if (iosm->nsuffix) {
2210 const char * opath =
iosmFsPath(iosm, st, NULL, NULL);
2212 (opath ? opath :
""),
2213 (iosm->path ? iosm->path :
""));
2214 opath =
_free(opath);
2216 iosm->opath =
_free(iosm->opath);
2221 if (!rc && !getuid()) {
2225 iosm->fcontext = NULL;
2228 if (!rc && !getuid())
2231 if (!rc && !getuid())
2236 time_t mtime = st->st_mtime;
2238 st->st_mtime = fi->fmtimes[iosm->ix];
2240 st->st_mtime = mtime;
2249 else if (iosm->failedFile && *iosm->failedFile == NULL) {
2250 *iosm->failedFile = iosm->path;
2255 iosm->path =
_free(iosm->path);
2258 while ((iosm->li = iosm->links) != NULL) {
2259 iosm->links = iosm->li->next;
2260 iosm->li->next = NULL;
2262 iosm->commit && iosm->li->linksLeft)
2264 for (i = 0 ; i < iosm->li->linksLeft; i++) {
2265 if (iosm->li->filex[i] < 0)
2267 rc = IOSMERR_MISSING_HARDLINK;
2268 if (iosm->failedFile && *iosm->failedFile == NULL) {
2269 iosm->ix = iosm->li->filex[i];
2271 *iosm->failedFile = iosm->path;
2281 rc = IOSMERR_MISSING_HARDLINK;
2285 iosm->ldn =
_free(iosm->ldn);
2286 iosm->ldnalloc = iosm->ldnlen = 0;
2287 iosm->rdbuf = iosm->rdb =
_free(iosm->rdb);
2288 iosm->wrbuf = iosm->wrb =
_free(iosm->wrb);
2291 if (iosm->diskchecked && !iosm->exists) {
2292 rc = IOSMERR_ENOENT;
2295 if (S_ISREG(st->st_mode)) {
2296 char * path =
alloca(strlen(iosm->path) +
sizeof(
"-RPMDELETE"));
2297 (void)
stpcpy(
stpcpy(path, iosm->path),
"-RPMDELETE");
2302 iosm->opath = iosm->path;
2308 rc = IOSMERR_UNLINK_FAILED;
2309 iosm->path = iosm->opath;
2311 return (rc ? rc : IOSMERR_ENOENT);
2313 }
else if (S_ISDIR(st->st_mode)) {
2314 if (S_ISDIR(ost->st_mode))
return 0;
2317 if (rc == IOSMERR_ENOENT) rc = 0;
2320 if (S_ISDIR(ost->st_mode))
return 0;
2322 }
else if (
S_ISLNK(st->st_mode)) {
2328 if (!strcmp(iosm->lpath, iosm->rdbuf))
return 0;
2330 }
else if (S_ISFIFO(st->st_mode)) {
2331 if (S_ISFIFO(ost->st_mode))
return 0;
2332 }
else if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
2333 if ((S_ISCHR(ost->st_mode) || S_ISBLK(ost->st_mode)) &&
2334 (ost->st_rdev == st->st_rdev))
return 0;
2335 }
else if (
S_ISSOCK(st->st_mode)) {
2336 if (
S_ISSOCK(ost->st_mode))
return 0;
2341 if (rc == 0) rc = IOSMERR_ENOENT;
2342 return (rc ? rc : IOSMERR_ENOENT);
2349 if (
Lstat(iosm->path, &stb) == 0 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0) {
2351 (void)
Chmod(iosm->path, stb.st_mode & 0777);
2357 iosm->path, (rc < 0 ? strerror(
errno) :
""));
2359 rc = (
errno == ENOENT ? IOSMERR_ENOENT : IOSMERR_UNLINK_FAILED);
2365 if (
Lstat(iosm->path, &stb) == 0 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0) {
2367 (void)
Chmod(iosm->path, stb.st_mode & 0777);
2370 rc =
Rename(iosm->opath, iosm->path);
2372 if (iosm->repackaged)
2374 #if defined(ETXTBSY)
2375 if (rc &&
errno == ETXTBSY) {
2376 char * path =
alloca(strlen(iosm->path) +
sizeof(
"-RPMDELETE"));
2377 (void)
stpcpy(
stpcpy(path, iosm->path),
"-RPMDELETE");
2382 rc =
Rename(iosm->path, path);
2383 if (!rc) rc =
Rename(iosm->opath, iosm->path);
2386 if (iosm->debug && (stage & IOSM_SYSCALL))
2388 iosm->opath, iosm->path, (rc < 0 ? strerror(
errno) :
""));
2389 if (rc < 0) rc = IOSMERR_RENAME_FAILED;
2392 rc =
Mkdir(iosm->path, (st->st_mode & 07777));
2393 if (iosm->debug && (stage & IOSM_SYSCALL))
2395 iosm->path, (
unsigned)(st->st_mode & 07777),
2396 (rc < 0 ? strerror(
errno) :
""));
2397 if (rc < 0) rc = IOSMERR_MKDIR_FAILED;
2400 rc =
Rmdir(iosm->path);
2401 if (iosm->debug && (stage & IOSM_SYSCALL))
2403 iosm->path, (rc < 0 ? strerror(
errno) :
""));
2406 case ENOENT: rc = IOSMERR_ENOENT;
break;
2407 case ENOTEMPTY: rc = IOSMERR_ENOTEMPTY;
break;
2408 default: rc = IOSMERR_RMDIR_FAILED;
break;
2412 {
const char * iosmpath = NULL;
2413 if (iosm->fcontext == NULL || *iosm->fcontext ==
'\0'
2414 || !strcmp(iosm->fcontext,
"<<none>>"))
2416 (void)
urlPath(iosm->path, &iosmpath);
2418 if (iosm->debug && (stage & IOSM_SYSCALL))
2420 iosm->path, iosm->fcontext,
2421 (rc < 0 ? strerror(
errno) :
""));
2422 if (rc < 0) rc = (
errno == EOPNOTSUPP ? 0 : IOSMERR_LSETFCON_FAILED);
2425 rc =
Chown(iosm->path, st->st_uid, st->st_gid);
2426 if (iosm->debug && (stage & IOSM_SYSCALL))
2428 iosm->path, (
int)st->st_uid, (
int)st->st_gid,
2429 (rc < 0 ? strerror(
errno) :
""));
2430 if (rc < 0) rc = IOSMERR_CHOWN_FAILED;
2433 #if ! CHOWN_FOLLOWS_SYMLINK
2434 rc =
Lchown(iosm->path, st->st_uid, st->st_gid);
2435 if (iosm->debug && (stage & IOSM_SYSCALL))
2437 iosm->path, (
int)st->st_uid, (
int)st->st_gid,
2438 (rc < 0 ? strerror(
errno) :
""));
2439 if (rc < 0) rc = IOSMERR_CHOWN_FAILED;
2443 rc =
Chmod(iosm->path, (st->st_mode & 07777));
2444 if (iosm->debug && (stage & IOSM_SYSCALL))
2446 iosm->path, (
unsigned)(st->st_mode & 07777),
2447 (rc < 0 ? strerror(
errno) :
""));
2448 if (rc < 0) rc = IOSMERR_CHMOD_FAILED;
2451 {
struct utimbuf stamp;
2452 stamp.actime = st->st_mtime;
2453 stamp.modtime = st->st_mtime;
2454 rc =
Utime(iosm->path, &stamp);
2455 if (iosm->debug && (stage & IOSM_SYSCALL))
2457 iosm->path, (
unsigned)st->st_mtime,
2458 (rc < 0 ? strerror(
errno) :
""));
2459 if (rc < 0) rc = IOSMERR_UTIME_FAILED;
2463 rc =
Symlink(iosm->lpath, iosm->path);
2464 if (iosm->debug && (stage & IOSM_SYSCALL))
2466 iosm->lpath, iosm->path, (rc < 0 ? strerror(
errno) :
""));
2467 if (rc < 0) rc = IOSMERR_SYMLINK_FAILED;
2470 rc =
Link(iosm->opath, iosm->path);
2471 if (iosm->debug && (stage & IOSM_SYSCALL))
2473 iosm->opath, iosm->path, (rc < 0 ? strerror(
errno) :
""));
2474 if (rc < 0) rc = IOSMERR_LINK_FAILED;
2477 rc =
Mkfifo(iosm->path, (st->st_mode & 07777));
2478 if (iosm->debug && (stage & IOSM_SYSCALL))
2480 iosm->path, (
unsigned)(st->st_mode & 07777),
2481 (rc < 0 ? strerror(
errno) :
""));
2482 if (rc < 0) rc = IOSMERR_MKFIFO_FAILED;
2486 rc =
Mknod(iosm->path, (st->st_mode & ~07777), st->st_rdev);
2488 if (iosm->debug && (stage & IOSM_SYSCALL))
2490 iosm->path, (
unsigned)(st->st_mode & ~07777),
2491 (
unsigned)st->st_rdev,
2492 (rc < 0 ? strerror(
errno) :
""));
2493 if (rc < 0) rc = IOSMERR_MKNOD_FAILED;
2496 rc =
Lstat(iosm->path, ost);
2497 if (iosm->debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2499 iosm->path, (rc < 0 ? strerror(
errno) :
""));
2501 rc = (
errno == ENOENT ? IOSMERR_ENOENT : IOSMERR_LSTAT_FAILED);
2502 memset(ost, 0,
sizeof(*ost));
2506 rc =
Stat(iosm->path, ost);
2507 if (iosm->debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2509 iosm->path, (rc < 0 ? strerror(
errno) :
""));
2511 rc = (
errno == ENOENT ? IOSMERR_ENOENT : IOSMERR_STAT_FAILED);
2512 memset(ost, 0,
sizeof(*ost));
2517 rc =
Readlink(iosm->path, iosm->rdbuf, iosm->rdsize - 1);
2518 if (iosm->debug && (stage & IOSM_SYSCALL))
2520 iosm->path, (
int)(iosm->rdsize -1), (rc < 0 ? strerror(
errno) :
""));
2521 if (rc < 0) rc = IOSMERR_READLINK_FAILED;
2524 iosm->rdbuf[iosm->rdnb] =
'\0';
2535 iosm->path =
_free(iosm->path);
2536 rc = IOSMERR_HDR_TRAILER;
2542 for (left = st->st_size; left > 0; left -= iosm->rdnb) {
2543 iosm->wrlen = (left > iosm->wrsize ? iosm->wrsize : left);
2550 left = (iosm->blksize - (
fdGetCpioPos(iosm->cfd) % iosm->blksize)) % iosm->blksize;
2557 left = (iosm->blksize - (
fdGetCpioPos(iosm->cfd) % iosm->blksize)) % iosm->blksize;
2559 if (iosm->blksize == 2)
2560 iosm->rdbuf[0] =
'\n';
2562 memset(iosm->rdbuf, 0, left);
2569 rc = (*iosm->trailerWrite) (iosm);
2574 rc = (*iosm->headerRead) (iosm, st);
2577 rc = (*iosm->headerWrite) (iosm, st);
2580 iosm->rdnb =
Fread(iosm->wrbuf,
sizeof(*iosm->wrbuf), iosm->wrlen, iosm->cfd);
2581 if (iosm->debug && (stage & IOSM_SYSCALL))
2583 cur, (iosm->wrbuf == iosm->wrb ?
"wrbuf" :
"mmap"),
2584 (
int)iosm->wrlen, (
int)iosm->rdnb);
2585 if (iosm->rdnb != iosm->wrlen ||
Ferror(iosm->cfd))
2586 rc = IOSMERR_READ_FAILED;
2591 iosm->wrnb =
Fwrite(iosm->rdbuf,
sizeof(*iosm->rdbuf), iosm->rdnb, iosm->cfd);
2592 if (iosm->debug && (stage & IOSM_SYSCALL))
2594 cur, (iosm->rdbuf == iosm->rdb ?
"rdbuf" :
"mmap"),
2595 (
int)iosm->rdnb, (
int)iosm->wrnb);
2596 if (iosm->rdnb != iosm->wrnb ||
Ferror(iosm->cfd))
2597 rc = IOSMERR_WRITE_FAILED;
2603 iosm->rfd =
Fopen(iosm->path,
"r.fdio");
2604 if (iosm->rfd == NULL ||
Ferror(iosm->rfd)) {
2607 rc = IOSMERR_OPEN_FAILED;
2610 if (iosm->debug && (stage & IOSM_SYSCALL))
2612 iosm->path, iosm->rfd, iosm->rdbuf);
2615 iosm->rdnb =
Fread(iosm->rdbuf,
sizeof(*iosm->rdbuf), iosm->rdlen, iosm->rfd);
2616 if (iosm->debug && (stage & IOSM_SYSCALL))
2618 cur, (
int)iosm->rdlen, (
int)iosm->rdnb);
2619 if (iosm->rdnb != iosm->rdlen ||
Ferror(iosm->rfd))
2620 rc = IOSMERR_READ_FAILED;
2623 if (iosm->rfd != NULL) {
2624 if (iosm->debug && (stage & IOSM_SYSCALL))
2628 (void)
Fclose(iosm->rfd);
2634 iosm->wfd =
Fopen(iosm->path,
"w.fdio");
2635 if (iosm->wfd == NULL ||
Ferror(iosm->wfd)) {
2638 rc = IOSMERR_OPEN_FAILED;
2640 if (iosm->debug && (stage & IOSM_SYSCALL))
2642 iosm->path, iosm->wfd, iosm->wrbuf);
2645 iosm->wrnb =
Fwrite(iosm->wrbuf,
sizeof(*iosm->wrbuf), iosm->rdnb, iosm->wfd);
2646 if (iosm->debug && (stage & IOSM_SYSCALL))
2648 cur, (
int)iosm->rdnb, (
int)iosm->wrnb);
2649 if (iosm->rdnb != iosm->wrnb ||
Ferror(iosm->wfd))
2650 rc = IOSMERR_WRITE_FAILED;
2653 if (iosm->wfd != NULL) {
2654 if (iosm->debug && (stage & IOSM_SYSCALL))
2658 (void)
Fclose(iosm->wfd);
2668 if (!(stage & IOSM_INTERNAL)) {
2669 iosm->rc = (rc == IOSMERR_HDR_TRAILER ? 0 : rc);
2675 #define IOSM_SKIPPING(_a) \
2676 ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR)
2698 default:
return "???";
2764 default:
return "???";
2773 int l, myerrno =
errno;
2775 strcpy(msg,
"cpio: ");
2778 s = msg + strlen(msg);
2779 sprintf(s,
_(
"(error 0x%x)"), (
unsigned)rc);
2782 case IOSMERR_BAD_MAGIC: s =
_(
"Bad magic");
break;
2783 case IOSMERR_BAD_HEADER: s =
_(
"Bad/unreadable header");
break;
2785 case IOSMERR_OPEN_FAILED: s =
"open";
break;
2786 case IOSMERR_CHMOD_FAILED: s =
"chmod";
break;
2787 case IOSMERR_CHOWN_FAILED: s =
"chown";
break;
2788 case IOSMERR_WRITE_FAILED: s =
"write";
break;
2789 case IOSMERR_UTIME_FAILED: s =
"utime";
break;
2790 case IOSMERR_UNLINK_FAILED: s =
"unlink";
break;
2791 case IOSMERR_RENAME_FAILED: s =
"rename";
break;
2792 case IOSMERR_SYMLINK_FAILED: s =
"symlink";
break;
2793 case IOSMERR_STAT_FAILED: s =
"stat";
break;
2794 case IOSMERR_LSTAT_FAILED: s =
"lstat";
break;
2795 case IOSMERR_MKDIR_FAILED: s =
"mkdir";
break;
2796 case IOSMERR_RMDIR_FAILED: s =
"rmdir";
break;
2797 case IOSMERR_MKNOD_FAILED: s =
"mknod";
break;
2798 case IOSMERR_MKFIFO_FAILED: s =
"mkfifo";
break;
2799 case IOSMERR_LINK_FAILED: s =
"link";
break;
2800 case IOSMERR_READLINK_FAILED: s =
"readlink";
break;
2801 case IOSMERR_READ_FAILED: s =
"read";
break;
2802 case IOSMERR_COPY_FAILED: s =
"copy";
break;
2803 case IOSMERR_LSETFCON_FAILED: s =
"lsetfilecon";
break;
2805 case IOSMERR_HDR_SIZE: s =
_(
"Header size too big");
break;
2806 case IOSMERR_UNKNOWN_FILETYPE: s =
_(
"Unknown file type");
break;
2807 case IOSMERR_MISSING_HARDLINK: s =
_(
"Missing hard link(s)");
break;
2808 case IOSMERR_DIGEST_MISMATCH: s =
_(
"File digest mismatch");
break;
2809 case IOSMERR_INTERNAL: s =
_(
"Internal error");
break;
2810 case IOSMERR_UNMAPPED_FILE: s =
_(
"Archive file not in header");
break;
2811 case IOSMERR_ENOENT: s = strerror(ENOENT);
break;
2812 case IOSMERR_ENOTEMPTY: s = strerror(ENOTEMPTY);
break;
2815 l =
sizeof(msg) - strlen(msg) - 1;
2817 if (l > 0) strncat(msg, s, l);
2820 if ((rc & IOSMERR_CHECK_ERRNO) && myerrno) {
2821 s =
_(
" failed - ");
2822 if (l > 0) strncat(msg, s, l);
2824 if (l > 0) strncat(msg, strerror(myerrno), l);