16 #include "../rpmdb/rpmtag.h"
21 #define _IOSM_INTERNAL
23 #define iosmUNSAFE iosmStage
30 #define _RPMFI_INTERNAL
31 #define _RPMFI_NOMETHODS
32 #include "../lib/rpmfi.h"
37 #if defined(_USE_RPMTE)
43 #if defined(_USE_RPMSX)
44 #include "../lib/rpmsx.h"
52 #if defined(_USE_RPMTS)
65 GENfree(
unsigned short *)
71 #define alloca_strdup(_s) strcpy((char *)alloca(strlen(_s)+1), (_s))
87 #if defined(_USE_RPMTS)
92 return (iter ? iter->
ts :
NULL);
101 return (iter ? iter->
fi :
NULL);
105 #define SUFFIX_RPMORIG ".rpmorig"
106 #define SUFFIX_RPMSAVE ".rpmsave"
107 #define SUFFIX_RPMNEW ".rpmnew"
119 const struct stat *
st,
125 const char *
s =
NULL;
131 (st && !S_ISDIR(st->st_mode) ? (subdir ? strlen(subdir) : 0) : 0) +
132 (st && !S_ISDIR(st->st_mode) ? (suffix ? strlen(suffix) : 0) : 0) +
136 if (st && !S_ISDIR(st->st_mode))
137 if (subdir) t =
stpcpy(t, subdir);
139 if (st && !S_ISDIR(st->st_mode))
140 if (suffix) t =
stpcpy(t, suffix);
155 #if !defined(_RPMFI_NOMETHODS)
177 #if !defined(_RPMFI_NOMETHODS)
202 if (iter->
i >= 0) i = iter->
i--;
204 if (iter->
i < (
int) ((
rpmfi)iter->
fi)->fc) i = iter->
i++;
216 const char * aurl = *(
const char **)a;
217 const char * burl = *(
const char **)b;
218 const char * afn =
NULL;
219 const char * bfn =
NULL;
224 #ifdef VERY_OLD_BUGGY_RPM_PACKAGES
226 if (strchr(afn,
'/') ==
NULL)
227 bfn = strrchr(bfn,
'/') + 1;
231 if (afn[0] ==
'.' && afn[1] ==
'/') afn += 2;
232 if (bfn[0] ==
'.' && bfn[1] ==
'/') bfn += 2;
235 if (afn[0] ==
'/') afn += 1;
236 if (bfn[0] ==
'/') bfn += 1;
259 size_t fc = (fi ? fi->fc : 0);
261 if (fi && fc > 0 && fi->apath && iosmPath && *iosmPath) {
262 const char **
p =
NULL;
264 if (fi->apath !=
NULL)
266 bsearch(&iosmPath, fi->apath, fc,
sizeof(iosmPath),
269 iter->
i = p - fi->apath;
301 return _free((
void *)_dnli);
309 return (
int) (dnli ? dnli->
fi->dc : 0);
317 return (dnli ? dnli->
isave : -1);
343 dnli->
i = (
int) (reverse ? fi->dc : 0);
349 #if !defined(_RPMFI_NOMETHODS)
353 for (i = 0; i < (
int)fi->fc; i++)
357 dnli->
active[fi->dil[
i]] = (char)1;
361 #if !defined(_RPMFI_NOMETHODS)
365 for (i = 0; i < (
int)fi->fc; i++)
371 if (!S_ISDIR(fi->fmodes[i]))
375 dnlen = strlen(fi->dnl[dil]);
376 bnlen = strlen(fi->bnl[i]);
378 for (j = 0; j < (
int)fi->dc; j++) {
381 if (!dnli->
active[j] || j == (
int)dil)
385 if (jlen != (dnlen+bnlen+1))
387 if (strncmp(dnl, fi->dnl[dil], dnlen))
389 if (strncmp(dnl+dnlen, fi->bnl[i], bnlen))
391 if (dnl[dnlen+bnlen] !=
'/' || dnl[dnlen+bnlen+1] !=
'\0')
402 for (i = 0; i < (
int)fi->dc; i++) {
403 if (!dnli->
active[i])
continue;
407 D_(
"========== Directories not explicitly included in package:\n"));
429 const char * dn =
NULL;
437 i = (!dnli->
reverse ? dnli->
i++ : --dnli->
i);
438 }
while (i >= 0 && i < (
int)fi->dc && !dnli->
active[
i]);
440 if (i >= 0 && i < (
int)fi->dc)
449 #if defined(WITH_PTHREADS)
450 static void * iosmThread(
void * _iosm)
466 #if defined(WITH_PTHREADS)
485 struct stat *
st = &iosm->
sb;
492 if (iosm->
li->
sb.st_ino == st->st_ino && iosm->
li->
sb.st_dev == st->st_dev)
533 if (!(st->st_size || iosm->
li->
linksLeft == (
int) st->st_nlink))
605 #if !defined(_RPMFI_NOMETHODS)
611 for (i = 0; i < (
int)fi->fc; i++)
616 const char * apath =
NULL;
618 path = apath + fi->striplen;
621 #if !defined(_RPMFI_NOMETHODS)
626 if ((nb = strlen(path)) < 15)
639 #if !defined(_RPMFI_NOMETHODS)
644 for (i = 0; i < (
int)fi->fc; i++)
649 const char * apath =
NULL;
651 path = apath + fi->striplen;
654 #if !defined(_RPMFI_NOMETHODS)
659 if ((nb = strlen(path)) < 15)
671 unsigned int * archiveSize,
const char ** failedFile)
673 #if defined(_USE_RPMTS)
677 #if defined(_USE_RPMTE)
693 fprintf(stderr,
"--> iosmSetup(%p, 0x%x, \"%s\", %p, %p, %p, %p, %p)\n", iosm, goal, afmt, (
void *)_ts, _fi, cfd, archiveSize, failedFile);
700 fprintf(stderr,
"\ttar vectors set\n");
708 fprintf(stderr,
"\tar vectors set\n");
718 fprintf(stderr,
"\tcpio vectors set\n");
729 iosm->
cfd =
fdLink(cfd,
"persist (iosm)");
735 iosm->
iter = (
IOSMI_t) mapInitIterator(fi, reverse);
737 #if defined(_USE_RPMTS)
743 #define _tsmask (RPMTRANS_FLAG_PKGCOMMIT | RPMTRANS_FLAG_COMMIT)
749 iosm->
iter->
ts = (
void *)_ts;
756 #if defined(_USE_RPMTS)
776 #if defined(_USE_RPMTS)
779 static time_t now = 0;
780 if (now == 0) now = time(
NULL);
783 if (tid > 0 && tid < 0xffffffff)
789 if (rc && !ec) ec =
rc;
792 if (rc && !ec) ec =
rc;
807 fprintf(stderr,
"--> iosmTeardown(%p)\n", iosm);
814 #if defined(_USE_RPMTS)
849 if (fi && i >= 0 && i < (
int)fi->fc)
850 iosm->
fcontext = (fi->fcontexts ? fi->fcontexts[i] :
NULL);
861 int teAdding = iosm->
adding;
871 if (fi && i >= 0 && i < (
int)fi->fc) {
875 iosm->
fflags = (fi->fflags ? fi->fflags[
i] : fi->flags);
879 iosm->
dirName = fi->dnl[fi->dil[
i]];
896 if (fi->fstates && teAdding)
901 if (fi->fstates && teAdding)
906 if (fi->fstates && teAdding)
940 const struct stat *
st = &iosm->
sb;
951 struct stat *
st = &iosm->
sb;
955 if (fi && i >= 0 && i < (
int)fi->fc) {
956 mode_t perms = (S_ISDIR(st->st_mode) ? fi->dperms : fi->fperms);
957 mode_t finalMode = (fi->fmodes ? (mode_t)fi->fmodes[i] : perms);
958 dev_t finalRdev = (fi->frdevs ? fi->frdevs[
i] : 0);
959 rpmuint32_t finalMtime = (fi->fmtimes ? fi->fmtimes[
i] : 0);
969 if (fi->fuser &&
unameToUid(fi->fuser[i], &uid)) {
973 _(
"user %s does not exist - using root\n"), fi->fuser[i]);
975 finalMode &= ~S_ISUID;
979 if (fi->fgroup &&
gnameToGid(fi->fgroup[i], &gid)) {
983 _(
"group %s does not exist - using root\n"), fi->fgroup[i]);
985 finalMode &= ~S_ISGID;
990 st->st_mode = (st->st_mode & S_IFMT) | (finalMode & ~S_IFMT);
992 st->st_mode = (st->st_mode & ~S_IFMT) | (finalMode & S_IFMT);
993 if ((S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode))
994 && st->st_nlink == 0)
996 st->st_rdev = finalRdev;
997 st->st_mtime = finalMtime;
1009 iosm->
fdigest = (fi->fdigests ? fi->fdigests[
i] :
NULL);
1033 const struct stat *
st = &iosm->
sb;
1034 size_t left = (size_t) st->st_size;
1067 int asAscii = (iosm->
digest ==
NULL ? 1 : 0);
1072 if (digest ==
NULL) {
1084 digest =
_free(digest);
1106 const char * opath = iosm->
opath;
1107 struct stat *
st = &iosm->
sb;
1108 struct stat * ost = &iosm->
osb;
1113 st->st_size = (writeData ? ost->st_size : 0);
1115 if (S_ISDIR(st->st_mode)) {
1117 }
else if (
S_ISLNK(st->st_mode)) {
1125 st->st_size = iosm->
rdnb;
1131 char *
t = (
char *)
alloca(nb);
1140 const char * apath =
NULL;
1142 iosm->
path = apath + fi->striplen;
1144 iosm->
path = fi->bnl[iosm->
ix];
1151 if (writeData && S_ISREG(st->st_mode)) {
1152 #if defined(HAVE_MMAP)
1153 char * rdbuf =
NULL;
1154 void * mapped = (
void *)-1;
1157 int use_mmap = (st->st_size <= 0x07ffffff);
1164 #if defined(HAVE_MMAP)
1166 mapped = mmap(
NULL, st->st_size, PROT_READ, MAP_SHARED,
Fileno(iosm->
rfd), 0);
1167 if (mapped != (
void *)-1) {
1168 rdbuf = iosm->
rdbuf;
1169 iosm->
rdbuf = (
char *) mapped;
1170 iosm->
rdlen = nmapped = st->st_size;
1171 #if defined(HAVE_MADVISE) && defined(MADV_DONTNEED)
1172 xx = madvise(mapped, nmapped, MADV_DONTNEED);
1181 #if defined(HAVE_MMAP)
1182 if (mapped != (
void *)-1) {
1183 iosm->
rdnb = nmapped;
1199 #if defined(HAVE_MMAP)
1200 if (mapped != (
void *)-1) {
1202 xx = msync(mapped, nmapped, MS_ASYNC);
1203 #if defined(HAVE_MADVISE) && defined(MADV_DONTNEED)
1204 xx = madvise(mapped, nmapped, MADV_DONTNEED);
1206 xx = munmap(mapped, nmapped);
1207 iosm->
rdbuf = rdbuf;
1226 iosm->
opath = opath;
1244 const char * lpath = iosm->
lpath;
1245 const char * nsuffix = iosm->
nsuffix;
1246 int iterIndex = iosm->
ix;
1250 const char * linkpath =
NULL;
1258 for (i = iosm->
li->
nlink - 1; i >= 0; i--) {
1260 if (iosm->
li->
filex[i] < 0)
continue;
1270 const char * apath =
NULL;
1279 iosm->
lpath = linkpath;
1297 linkpath =
_free(linkpath);
1299 iosm->
ix = iterIndex;
1301 iosm->
lpath = lpath;
1318 const char * opath = iosm->
opath;
1319 const char * nsuffix = iosm->
nsuffix;
1320 int iterIndex = iosm->
ix;
1334 for (i = 0; i < iosm->
li->
nlink; i++) {
1335 if (iosm->
li->
filex[i] < 0)
continue;
1359 iosm->
ix = iterIndex;
1362 iosm->
opath = opath;
1380 const char * nsuffix = iosm->
nsuffix;
1381 int iterIndex = iosm->
ix;
1382 struct stat *
st = &iosm->
sb;
1391 if (iosm->
li->
sb.st_ino == st->st_ino && iosm->
li->
sb.st_dev == st->st_dev)
1396 for (i = 0; i < iosm->
li->
nlink; i++) {
1397 if (iosm->
li->
filex[i] < 0)
continue;
1406 iosm->
ix = iterIndex;
1425 char * dn = iosm->
rdbuf;
1434 size_t dnlen = strlen(iosm->
path);
1438 if (iosm->
dnlx[dc] < 1 || (
size_t)iosm->
dnlx[dc] >= dnlen)
1458 }
while ((te - iosm->
path) > iosm->
dnlx[dc]);
1480 struct stat *
st = &iosm->
sb;
1481 struct stat * ost = &iosm->
osb;
1483 mode_t st_mode = st->st_mode;
1485 char * dn = iosm->
rdbuf;
1497 size_t dnlen = strlen(iosm->
path);
1501 if (dc < 0)
continue;
1502 iosm->
dnlx[
dc] = (
unsigned short) dnlen;
1507 if (dnlen <= iosm->ldnlen && !
strcmp(iosm->
path, iosm->
ldn))
1517 for (i = 1, te++; *te !=
'\0'; te++, i++) {
1525 if (i < iosm->ldnlen &&
1526 (iosm->
ldn[i] ==
'/' || iosm->
ldn[i] ==
'\0') &&
1527 !strncmp(iosm->
path, iosm->
ldn, i))
1531 iosm->
dnlx[
dc] = (te - dn);
1541 if (rc == 0 && S_ISDIR(ost->st_mode)) {
1543 iosm->
dnlx[
dc] = (te - dn);
1547 st->st_mode = S_IFDIR | (fi->dperms & 07777);
1550 #if defined(_USE_RPMSX)
1553 if (!fsm->nofcontexts) {
1562 D_(
"%s directory created with perms %04o, context %s.\n"),
1563 iosm->
path, (
unsigned)(st->st_mode & 07777),
1565 #if defined(_USE_RPMSX)
1578 if (iosm->
ldnalloc < (dnlen + 1)) {
1583 strcpy(iosm->
ldn, iosm->
path);
1592 st->st_mode = st_mode;
1604 static int iosmStat(
IOSM_t iosm)
1611 int saveernno =
errno;
1618 }
else if (rc == 0) {
1629 #define IS_DEV_LOG(_x) \
1630 ((_x) != NULL && strlen(_x) >= (sizeof("/dev/log")-1) && \
1631 !strncmp((_x), "/dev/log", sizeof("/dev/log")-1) && \
1632 ((_x)[sizeof("/dev/log")-1] == '\0' || \
1633 (_x)[sizeof("/dev/log")-1] == ';'))
1643 struct stat *
st = &iosm->
sb;
1644 struct stat * ost = &iosm->
osb;
1645 int saveerrno =
errno;
1650 #define _fafilter(_a) \
1651 (!((_a) == FA_CREATE || (_a) == FA_ERASE || (_a) == FA_COPYIN || (_a) == FA_COPYOUT) \
1652 ? iosmFileActionString(_a) : "")
1660 (
unsigned)st->st_mode, (
int)st->st_nlink,
1661 (
int)st->st_uid, (
int)st->st_gid, (
unsigned long)st->st_size,
1665 const char * apath =
NULL;
1668 iosm->
stage = stage;
1672 (
unsigned)st->st_mode, (
int)st->st_nlink,
1673 (
int)st->st_uid, (
int)st->st_gid, (
unsigned long)st->st_size,
1773 for (j = -1, nlink = 0, i = 0; i < iosm->
li->
nlink; i++) {
1784 iosm->
li->
sb.st_nlink = nlink;
1787 iosm->
osb = iosm->
sb;
1812 iosm->
rdsize = 16 * BUFSIZ;
1814 iosm->
wrsize = 16 * BUFSIZ;
1862 _(
"archive file %s was not found in header\n"),
1876 st->st_mode = fi->fmodes[iosm->
ix];
1886 rc = iosmStat(iosm);
1897 }
else if (rc == 0) {
1919 if (S_ISREG(st->st_mode) && st->st_nlink > 1)
1944 if (S_ISREG(st->st_mode))
1953 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
1960 for (li = iosm->
links, prev =
NULL; li; prev = li, li = li->
next)
1979 if (S_ISREG(st->st_mode) && iosm->
lpath !=
NULL) {
1980 const char * opath = iosm->
opath;
1990 iosm->
opath = opath;
1993 if (S_ISREG(st->st_mode)) {
1999 if (rc == 0 && iosm->
osuffix) {
2000 const char * opath = iosm->
opath;
2006 _(
"%s saved as %s\n"),
2010 iosm->
opath = opath;
2018 }
else if (S_ISDIR(st->st_mode)) {
2019 mode_t st_mode = st->st_mode;
2022 st->st_mode &= ~07777;
2023 st->st_mode |= 00700;
2025 st->st_mode = st_mode;
2027 }
else if (
S_ISLNK(st->st_mode)) {
2032 }
else if (S_ISFIFO(st->st_mode)) {
2033 mode_t st_mode = st->st_mode;
2039 st->st_mode = st_mode;
2041 }
else if (S_ISCHR(st->st_mode) ||
2042 S_ISBLK(st->st_mode) ||
2057 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
2068 #if defined(_USE_RPMTS)
2072 if (archivePos > fi->archivePos) {
2073 fi->archivePos = (
unsigned long long) archivePos;
2075 fi->archivePos, fi->archiveSize);
2085 if (iosm->
sufbuf[0] !=
'\0')
2101 rc = ((S_ISREG(st->st_mode) && st->st_nlink > 1)
2111 memset(st, 0,
sizeof(*st));
2112 memset(ost, 0,
sizeof(*ost));
2119 const char * opath = iosm->
opath;
2132 iosm->
opath = opath;
2138 if (S_ISDIR(st->st_mode)) {
2151 _(
"rmdir of %s failed: Directory not empty\n"),
2157 _(
"rmdir of %s failed: %s\n"),
2172 _(
"unlink of %s failed: %s\n"),
2188 if (!S_ISDIR(st->st_mode) &&
2199 (opath ? opath :
""),
2201 opath =
_free(opath);
2208 if (!rc && !getuid()) {
2215 if (!rc && !getuid())
2218 if (!rc && !getuid())
2223 time_t mtime = st->st_mtime;
2225 st->st_mtime = fi->fmtimes[iosm->
ix];
2227 st->st_mtime = mtime;
2282 if (S_ISREG(st->st_mode)) {
2283 char *
path = (
char *)
alloca(strlen(iosm->
path) +
sizeof(
"-RPMDELETE"));
2300 }
else if (S_ISDIR(st->st_mode)) {
2301 if (S_ISDIR(ost->st_mode))
return 0;
2307 if (S_ISDIR(ost->st_mode))
return 0;
2309 }
else if (
S_ISLNK(st->st_mode)) {
2317 }
else if (S_ISFIFO(st->st_mode)) {
2318 if (S_ISFIFO(ost->st_mode))
return 0;
2319 }
else if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
2320 if ((S_ISCHR(ost->st_mode) || S_ISBLK(ost->st_mode)) &&
2321 (ost->st_rdev == st->st_rdev))
return 0;
2322 }
else if (
S_ISSOCK(st->st_mode)) {
2323 if (
S_ISSOCK(ost->st_mode))
return 0;
2337 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
2346 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2355 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
2365 #if defined(ETXTBSY)
2366 if (rc &&
errno == ETXTBSY) {
2367 char *
path = (
char *)
alloca(strlen(iosm->
path) +
sizeof(
"-RPMDELETE"));
2377 if (iosm->
debug && (stage & IOSM_SYSCALL))
2383 rc =
Mkdir(iosm->
path, (st->st_mode & 07777));
2384 if (iosm->
debug && (stage & IOSM_SYSCALL))
2386 iosm->
path, (
unsigned)(st->st_mode & 07777),
2387 (rc < 0 ? strerror(
errno) :
""));
2392 if (iosm->
debug && (stage & IOSM_SYSCALL))
2394 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2403 {
const char * iosmpath =
NULL;
2409 if (iosm->
debug && (stage & IOSM_SYSCALL))
2412 (rc < 0 ? strerror(
errno) :
""));
2416 rc =
Chown(iosm->
path, st->st_uid, st->st_gid);
2417 if (iosm->
debug && (stage & IOSM_SYSCALL))
2419 iosm->
path, (
int)st->st_uid, (
int)st->st_gid,
2420 (rc < 0 ? strerror(
errno) :
""));
2424 #if ! CHOWN_FOLLOWS_SYMLINK
2425 rc =
Lchown(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) :
""));
2434 rc =
Chmod(iosm->
path, (st->st_mode & 07777));
2435 if (iosm->
debug && (stage & IOSM_SYSCALL))
2437 iosm->
path, (
unsigned)(st->st_mode & 07777),
2438 (rc < 0 ? strerror(
errno) :
""));
2442 {
struct utimbuf stamp;
2443 stamp.actime = st->st_mtime;
2444 stamp.modtime = st->st_mtime;
2446 if (iosm->
debug && (stage & IOSM_SYSCALL))
2448 iosm->
path, (
unsigned)st->st_mtime,
2449 (rc < 0 ? strerror(
errno) :
""));
2455 if (iosm->
debug && (stage & IOSM_SYSCALL))
2462 if (iosm->
debug && (stage & IOSM_SYSCALL))
2468 rc =
Mkfifo(iosm->
path, (st->st_mode & 07777));
2469 if (iosm->
debug && (stage & IOSM_SYSCALL))
2471 iosm->
path, (
unsigned)(st->st_mode & 07777),
2472 (rc < 0 ? strerror(
errno) :
""));
2477 rc =
Mknod(iosm->
path, (st->st_mode & ~07777), st->st_rdev);
2479 if (iosm->
debug && (stage & IOSM_SYSCALL))
2481 iosm->
path, (
unsigned)(st->st_mode & ~07777),
2482 (
unsigned)st->st_rdev,
2483 (rc < 0 ? strerror(
errno) :
""));
2488 if (iosm->
debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2490 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2493 memset(ost, 0,
sizeof(*ost));
2498 if (iosm->
debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2500 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2503 memset(ost, 0,
sizeof(*ost));
2509 if (iosm->
debug && (stage & IOSM_SYSCALL))
2533 for (left = st->st_size; left > 0; left -= iosm->
rdnb) {
2551 iosm->
rdbuf[0] =
'\n';
2572 if (iosm->
debug && (stage & IOSM_SYSCALL))
2574 cur, (iosm->
wrbuf == iosm->
wrb ?
"wrbuf" :
"mmap"),
2583 if (iosm->
debug && (stage & IOSM_SYSCALL))
2585 cur, (iosm->
rdbuf == iosm->
rdb ?
"rdbuf" :
"mmap"),
2601 #if defined(POSIX_FADV_WILLNEED)
2604 if (iosm->
debug && (stage & IOSM_SYSCALL))
2610 if (iosm->
debug && (stage & IOSM_SYSCALL))
2612 cur, (
int)iosm->
rdlen, (
int)iosm->
rdnb);
2618 if (iosm->
debug && (stage & IOSM_SYSCALL))
2634 #if defined(POSIX_FADV_DONTNEED)
2636 (
void)
Fadvise(iosm->
wfd, 0, 0, POSIX_FADV_DONTNEED);
2638 if (iosm->
debug && (stage & IOSM_SYSCALL))
2644 if (iosm->
debug && (stage & IOSM_SYSCALL))
2646 cur, (
int)iosm->
rdnb, (
int)iosm->
wrnb);
2652 if (iosm->
debug && (stage & IOSM_SYSCALL))
2666 if (!(stage & IOSM_INTERNAL)) {
2673 #define IOSM_SKIPPING(_a) \
2674 ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR)
2696 default:
return "???";
2762 default:
return "???";
2771 int l, myerrno =
errno;
2773 strcpy(msg,
"cpio: ");
2776 s = msg + strlen(msg);
2777 sprintf((
char *)s,
_(
"(error 0x%x)"), (
unsigned)rc);
2813 l =
sizeof(
msg) - strlen(msg) - 1;
2815 if (l > 0) strncat(msg, s, l);
2819 s =
_(
" failed - ");
2820 if (l > 0) strncat(msg, s, l);
2822 if (l > 0) strncat(msg, strerror(myerrno), l);
int arHeaderRead(void *_iosm, struct stat *st)
Read ar(1) header.
static void fdInitDigest(FD_t fd, pgpHashAlgo hashalgo, int _flags)
Attach digest to fd.
static const char * dnlNextIterator(DNLI_t dnli)
Return next directory name (from file info).
static const char * suffix[]
char * iosmStrerror(int rc)
Return formatted error message on payload handling failure.
iosmMapFlags cpioMapFlags
rpmop rpmtsOp(rpmts ts, rpmtsOpX opx)
Retrieve operation timestamp from a transaction set.
enum iosmMapFlags_e iosmMapFlags
int tarTrailerWrite(void *_iosm)
Write cpio trailer to payload.
struct rpmmi_s * rpmmi
Database iterator.
struct rpmdb_s * rpmdb
Database of headers and tag value indices.
rpmlog(RPMLOG_ERR,"%s\n", buf)
struct rpmte_s * rpmte
An element of a transaction set, i.e.
rpmtime_t rpmswAdd(rpmop to, rpmop from)
Sum statistic counters.
int rpmsxLsetfilecon(rpmsx sx, const char *fn, mode_t mode, const char *scon)
static unsigned long long fdGetCpioPos(FD_t fd)
enum iosmFileAction_e iosmFileAction
File disposition(s) during package install/erase processing.
void * alKey
An added/available package retrieval key.
int Symlink(const char *oldpath, const char *newpath)
symlink(3) clone.
Structures used for an "rpmte" transaction element.
struct rpmPRCO_s * rpmPRCO
Container for commonly extracted dependency set(s).
size_t Fwrite(const void *buf, size_t size, size_t nmemb, FD_t fd)
fwrite(3) clone.
char * xstrdup(const char *str)
FD_t Fopen(const char *path, const char *_fmode)
fopen(3) clone.
static int iosmMkdirs(IOSM_t iosm)
Create (if necessary) directories not explicitly included in package.
static int iosmMapFContext(IOSM_t iosm)
static char *size_t nb
fgets(3) analogue that reads \ continuations.
struct rpmts_s * rpmts
The RPM Transaction Set.
static const char * iosmFsPath(const IOSM_t iosm, const struct stat *st, const char *subdir, const char *suffix)
Build path to file from file info, ornamented with subdir and suffix.
rpmts rpmtsFree(rpmts ts)
Destroy transaction set, closing the database as well.
static void * freeHardLink(struct hardLink_s *li)
Destroy set of hard links.
rpmfi rpmfiUnlink(rpmfi fi, const char *msg)
Unreference a file info set instance.
static int extractRegular(IOSM_t iosm)
Create file from payload stream.
void * rpmsqThread(void *(*start)(void *arg), void *arg)
Call a function in a thread.
int Stat(const char *path, struct stat *st)
stat(2) clone.
static int mapNextIterator(void *_iter)
Return next index into file info.
FD_t fdLink(void *cookie, const char *msg)
static void fdSetCpioPos(FD_t fd, long int cpioPos)
#define reverse(bot, top)
int Fflush(FD_t fd)
fflush(3) clone.
unsigned int * archiveSize
int Link(const char *oldpath, const char *newpath)
link(2) clone.
Structures used for ar(1) archives.
int Fadvise(FD_t fd, off_t offset, off_t length, int advice)
posix_fadvise(2) clone.
static int mapFind(IOSMI_t iter, const char *iosmPath)
Locate archive path in file info.
struct rpmRelocation_s * rpmRelocation
int iosmMapPath(IOSM_t iosm)
Map next file path and action.
enum iosmFileStage_e iosmFileStage
rpmuint32_t rpmtsGetTid(rpmts ts)
Get transaction id, i.e.
const char * rpmfiBN(rpmfi fi)
Return current base name from file info set.
const unsigned char * digest
IOSM_t freeIOSM(IOSM_t iosm)
Destroy I/O state machine instance.
Keeps track of the set of all hard links to a file in an archive.
int Utime(const char *path, const struct utimbuf *buf)
int cpioHeaderWrite(void *_iosm, struct stat *st)
Write cpio header.
Structures used for cpio(1) archives.
int rpmfiFC(rpmfi fi)
Return file count from file info set.
unsigned char rpmuint8_t
Private int typedefs to avoid C99 portability issues.
int(* headerWrite)(void *_iosm, struct stat *st)
sprintf(t," (%u)",(unsigned) dig->nbytes)
#define IOSMERR_CHECK_ERRNO
int Chown(const char *path, uid_t owner, gid_t group)
chown(2) clone.
struct dnli_s * DNLI_t
Directory name iterator.
memset(_r, 0, sizeof(*_r))
rpmts rpmtsLink(rpmts ts, const char *msg)
Reference a transaction set instance.
void * xcalloc(size_t nmemb, size_t size)
assert(key->size==sizeof(hdrNum))
int Rmdir(const char *path)
rmdir(2) clone.
int iosmSetup(IOSM_t iosm, iosmFileStage goal, const char *afmt, const void *_ts, const void *_fi, FD_t cfd, unsigned int *archiveSize, const char **failedFile)
Load external data into I/O state machine.
static void * mapFreeIterator(void *_iter)
Destroy file info iterator.
fprintf(stderr,"--> %s(%p,%p,%p) sig %p sigp %p\n", __FUNCTION__, dig, t, rsactx, sig, sigp)
int gnameToGid(const char *thisGname, gid_t *gid)
FD_t fdFree(FD_t fd, const char *msg)
static int saveHardLink(IOSM_t iosm)
Save hard link in chain.
static void * dnlInitIterator(const IOSM_t iosm, int reverse)
Create directory name iterator.
int Rename(const char *oldpath, const char *newpath)
rename(2) clone.
enum pgpHashAlgo_e pgpHashAlgo
9.4.
int(* _iosmNext)(IOSM_t iosm, iosmFileStage nstage)
Vector to iosmNext.
int Mkdir(const char *path, mode_t mode)
mkdir(2) clone.
int Lstat(const char *path, struct stat *st)
lstat(2) clone.
static int dnlCount(const DNLI_t dnli)
int rpmsqJoin(void *thread)
Wait for thread to terminate.
unsigned long long rpmuint64_t
int iosmFileActionSkipped(iosmFileAction action)
Is the file going to be skipped?
Structures used for tar(1) archives.
int(* trailerWrite)(void *_iosm)
static void * dnlFreeIterator(const void *_dnli)
Destroy directory name iterator.
void * rpmtsNotify(rpmts ts, rpmte te, rpmCallbackType what, rpmuint64_t amount, rpmuint64_t total)
Perform transaction progress notify callback.
The FD_t File Handle data structure.
struct iosmIterator_s * IOSMI_t
Iterator across package file info, forward on install, backward on erase.
The structure used to store values parsed from a spec file.
int Mknod(const char *path, mode_t mode, dev_t dev)
mknod(3) clone.
size_t Fread(void *buf, size_t size, size_t nmemb, FD_t fd)
fread(3) clone.
IOSM_t newIOSM(void)
Create I/O state machine instance.
int iosmStage(IOSM_t iosm, iosmFileStage stage)
File state machine driver.
void * iosmGetFi(const IOSM_t iosm)
Retrieve transaction element file info from I/O state machine iterator.
int iosmTeardown(IOSM_t iosm)
Clean I/O state machine.
Iterator across package file info, forward on install, backward on erase.
int Fclose(FD_t fd)
fclose(3) clone.
struct rpmds_s * rpmds
Dependency tag sets from a header, so that a header can be discarded early.
int rpmfiNext(rpmfi fi)
Return next file iterator index.
#define IOSM_SKIPPING(_a)
int Readlink(const char *path, char *buf, size_t bufsiz)
readlink(2) clone.
int cpioHeaderRead(void *_iosm, struct stat *st)
Read cpio header.
int iosmMapAttrs(IOSM_t iosm)
Map file stat(2) info.
static void * iter
Create file info iterator.
int Ferror(FD_t fd)
ferror(3) clone.
int cpioTrailerWrite(void *_iosm)
Write cpio trailer.
rpmfi rpmfiInit(rpmfi fi, int fx)
Initialize file iterator index.
static int writeLinkedFile(IOSM_t iosm)
Write set of linked files to payload stream.
return strcmp(ame->name, bme->name)
void * iosmGetTs(const IOSM_t iosm)
Retrieve transaction set from I/O state machine iterator.
static int iosmMakeLinks(IOSM_t iosm)
Create pending hard links to existing file.
urltype urlPath(const char *url, const char **pathp)
Return path component of URL.
rpmfi rpmfiLink(rpmfi fi, const char *msg)
Reference a file info set instance.
int arHeaderWrite(void *_iosm, struct stat *st)
Write ar(1) header.
char * stpcpy(char *dest, const char *src)
struct iosm_s * IOSM_t
File state machine data.
rpmtransFlags rpmtsFlags(rpmts ts)
Get transaction flags, i.e.
const char * iosmFileStageString(iosmFileStage a)
Return formatted string representation of file stages.
struct hardLink_s * links
Structures and prototypes used for an "rpmts" transaction set.
int arTrailerWrite(void *_iosm)
Write ar(1) trailer.
int Lchown(const char *path, uid_t owner, gid_t group)
lchown(2) clone.
rpmElementType rpmteType(rpmte te)
Retrieve type of transaction element.
static int arSetup(IOSM_t iosm, rpmfi fi)
int Fileno(FD_t fd)
fileno(3) clone.
static void
Print copy of spec file, filling in Group/Description/Summary from specspo.
int Chmod(const char *path, mode_t mode)
chmod(2) clone.
static void fdFiniDigest(FD_t fd, pgpHashAlgo hashalgo, void *datap, size_t *lenp, int asAscii)
File state machine to handle archive I/O and system call's.
static rpmop fdstat_op(FD_t fd, fdOpX opx)
int
Save source and expand field into target.
struct rpmfi_s * rpmfi
File info tag sets from a header, so that a header can be discarded early.
static int iosmCommitLinks(IOSM_t iosm)
Commit hard linked file set atomically.
const char * iosmFileActionString(iosmFileAction a)
Return formatted string representation of file disposition.
static int iosmRmdirs(IOSM_t iosm)
Remove (if created) directories not explicitly included in package.
static int writeFile(IOSM_t iosm, int writeData)
Write next item to payload stream.
int unameToUid(const char *thisUname, uid_t *uid)
static int dnlIndex(const DNLI_t dnli)
int(* headerRead)(void *_iosm, struct stat *st)
const char * rpmsxMatch(rpmsx sx, const char *fn, mode_t mode)
Return security context for a file.
static void * _free(const void *p)
Wrapper to free(3), hides const compilation noise, permit NULL, return NULL.
int tarHeaderRead(void *_iosm, struct stat *st)
Read tar header from payload.
int tarHeaderWrite(void *_iosm, struct stat *st)
Write tar header to payload.
static int iosmStrCmp(const void *a, const void *b)
File name and stat information.
int Mkfifo(const char *path, mode_t mode)
mkfifo(3) clone.
int iosmNext(IOSM_t iosm, iosmFileStage nstage)
File state machine driver.
const unsigned char * digest
int Unlink(const char *path)
unlink(2) clone.