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)
183 iter->
i = (iter->
reverse ? (fi->fc - 1) : 0);
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;
238 return strcmp(afn, bfn);
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)
383 (void)
urlPath(fi->dnl[j], &dnl);
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')
394 dnli->
active[j] = (char)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"));
409 (void)
urlPath(fi->dnl[i], &dnl);
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)
497 if (iosm->
li == NULL) {
501 iosm->
li->
nlink = (int) st->st_nlink;
506 memset(iosm->
li->
filex, -1, (st->st_nlink *
sizeof(iosm->
li->
filex[0])));
533 if (!(st->st_size || iosm->
li->
linksLeft == (
int) st->st_nlink))
584 while ((iosm->
li = iosm->
links) != NULL) {
605 #if !defined(_RPMFI_NOMETHODS)
611 for (i = 0; i < (int)fi->fc; i++)
616 const char * apath = NULL;
617 (void)
urlPath(fi->apath[ix], &apath);
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;
650 (void)
urlPath(fi->apath[ix], &apath);
651 path = apath + fi->striplen;
654 #if !defined(_RPMFI_NOMETHODS)
659 if ((nb = strlen(path)) < 15)
670 const void * _ts,
const void *
_fi,
FD_t cfd,
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);
698 if (afmt != NULL && (!strcmp(afmt,
"tar") || !strcmp(afmt,
"ustar"))) {
700 fprintf(stderr,
"\ttar vectors set\n");
706 if (afmt != NULL && !strcmp(afmt,
"ar")) {
708 fprintf(stderr,
"\tar vectors set\n");
718 fprintf(stderr,
"\tcpio vectors set\n");
729 iosm->
cfd =
fdLink(cfd,
"persist (iosm)");
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)
784 sprintf(iosm->
sufbuf,
";%08x", (
unsigned)tid);
789 if (rc && !ec) ec = rc;
792 if (rc && !ec) ec = rc;
807 fprintf(stderr,
"--> iosmTeardown(%p)\n", iosm);
813 if (iosm->
iter != NULL) {
814 #if defined(_USE_RPMTS)
822 if (iosm->
cfd != NULL) {
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);
1011 iosm->
digest = (fi->digests ? (fi->digests + (iosm->
digestlen * i)) : NULL);
1033 const struct stat * st = &iosm->
sb;
1034 size_t left = (size_t) st->st_size;
1042 if (st->st_size > 0 && (iosm->
fdigest != NULL || iosm->
digest != NULL))
1066 void * digest = NULL;
1067 int asAscii = (iosm->
digest == NULL ? 1 : 0);
1072 if (digest == NULL) {
1077 if (iosm->
digest != NULL) {
1081 if (strcmp((
char *)digest, iosm->
fdigest))
1084 digest =
_free(digest);
1105 const char * path = iosm->
path;
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;
1130 size_t nb=strlen(iosm->
dirName) + strlen(iosm->
baseName) +
sizeof(
".");
1131 char * t = (
char *)
alloca(nb);
1140 const char * apath = NULL;
1141 (void)
urlPath(fi->apath[iosm->
ix], &apath);
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;
1220 if (iosm->
rfd != NULL)
1223 iosm->
opath = opath;
1240 const char * path = iosm->
path;
1241 const char * lpath = iosm->
lpath;
1242 const char * nsuffix = iosm->
nsuffix;
1243 int iterIndex = iosm->
ix;
1247 const char * linkpath = NULL;
1255 for (i = iosm->
li->
nlink - 1; i >= 0; i--) {
1257 if (iosm->
li->
filex[i] < 0)
continue;
1267 const char * apath = NULL;
1276 iosm->
lpath = linkpath;
1294 linkpath =
_free(linkpath);
1296 iosm->
ix = iterIndex;
1298 iosm->
lpath = lpath;
1314 const char * path = iosm->
path;
1315 const char * opath = iosm->
opath;
1316 const char * nsuffix = iosm->
nsuffix;
1317 int iterIndex = iosm->
ix;
1331 for (i = 0; i < iosm->
li->
nlink; i++) {
1332 if (iosm->
li->
filex[i] < 0)
continue;
1356 iosm->
ix = iterIndex;
1359 iosm->
opath = opath;
1376 const char * path = iosm->
path;
1377 const char * nsuffix = iosm->
nsuffix;
1378 int iterIndex = iosm->
ix;
1379 struct stat * st = &iosm->
sb;
1388 if (iosm->
li->
sb.st_ino == st->st_ino && iosm->
li->
sb.st_dev == st->st_dev)
1392 for (i = 0; i < iosm->
li->
nlink; i++) {
1393 if (iosm->
li->
filex[i] < 0)
continue;
1402 iosm->
ix = iterIndex;
1419 const char * path = iosm->
path;
1421 char * dn = iosm->
rdbuf;
1428 if (iosm->
ldn != NULL && iosm->
dnlx != NULL)
1430 size_t dnlen = strlen(iosm->
path);
1434 if (iosm->
dnlx[dc] < 1 || (
size_t)iosm->
dnlx[dc] >= dnlen)
1454 }
while ((te - iosm->
path) > iosm->
dnlx[dc]);
1476 struct stat * st = &iosm->
sb;
1477 struct stat * ost = &iosm->
osb;
1478 const char * path = iosm->
path;
1479 mode_t st_mode = st->st_mode;
1481 char * dn = iosm->
rdbuf;
1489 iosm->
dnlx = (
unsigned short *) (dc ?
xcalloc(dc,
sizeof(*iosm->
dnlx)) : NULL);
1491 if (iosm->
dnlx != NULL)
1493 size_t dnlen = strlen(iosm->
path);
1497 if (dc < 0)
continue;
1498 iosm->
dnlx[
dc] = (
unsigned short) dnlen;
1503 if (dnlen <= iosm->ldnlen && !strcmp(iosm->
path, iosm->
ldn))
1512 (void)
urlPath(dn, (
const char **)&te);
1513 for (i = 1, te++; *te !=
'\0'; te++, i++) {
1521 if (i < iosm->ldnlen &&
1522 (iosm->
ldn[i] ==
'/' || iosm->
ldn[i] ==
'\0') &&
1523 !strncmp(iosm->
path, iosm->
ldn, i))
1527 iosm->
dnlx[
dc] = (te - dn);
1537 if (rc == 0 && S_ISDIR(ost->st_mode)) {
1539 iosm->
dnlx[
dc] = (te - dn);
1543 st->st_mode = S_IFDIR | (fi->dperms & 07777);
1546 #if defined(_USE_RPMSX)
1549 if (!fsm->nofcontexts) {
1558 D_(
"%s directory created with perms %04o, context %s.\n"),
1559 iosm->
path, (
unsigned)(st->st_mode & 07777),
1561 #if defined(_USE_RPMSX)
1574 if (iosm->
ldnalloc < (dnlen + 1)) {
1578 if (iosm->
ldn != NULL) {
1579 strcpy(iosm->
ldn, iosm->
path);
1588 st->st_mode = st_mode;
1600 static int iosmStat(
IOSM_t iosm)
1606 if (iosm->
path != NULL) {
1607 int saveernno =
errno;
1614 }
else if (rc == 0) {
1625 #define IS_DEV_LOG(_x) \
1626 ((_x) != NULL && strlen(_x) >= (sizeof("/dev/log")-1) && \
1627 !strncmp((_x), "/dev/log", sizeof("/dev/log")-1) && \
1628 ((_x)[sizeof("/dev/log")-1] == '\0' || \
1629 (_x)[sizeof("/dev/log")-1] == ';'))
1639 struct stat * st = &iosm->
sb;
1640 struct stat * ost = &iosm->
osb;
1641 int saveerrno =
errno;
1646 #define _fafilter(_a) \
1647 (!((_a) == FA_CREATE || (_a) == FA_ERASE || (_a) == FA_COPYIN || (_a) == FA_COPYOUT) \
1648 ? iosmFileActionString(_a) : "")
1656 (
unsigned)st->st_mode, (
int)st->st_nlink,
1657 (
int)st->st_uid, (
int)st->st_gid, (
unsigned long)st->st_size,
1661 const char * apath = NULL;
1664 iosm->
stage = stage;
1668 (
unsigned)st->st_mode, (int)st->st_nlink,
1669 (
int)st->st_uid, (int)st->st_gid, (
unsigned long)st->st_size,
1764 while ((iosm->
li = iosm->
links) != NULL) {
1769 for (j = -1, nlink = 0, i = 0; i < iosm->
li->
nlink; i++) {
1780 iosm->
li->
sb.st_nlink = nlink;
1783 iosm->
osb = iosm->
sb;
1808 iosm->
rdsize = 16 * BUFSIZ;
1810 iosm->
wrsize = 16 * BUFSIZ;
1858 _(
"archive file %s was not found in header\n"),
1872 st->st_mode = fi->fmodes[iosm->
ix];
1882 rc = iosmStat(iosm);
1884 if (iosm->
path != NULL &&
1893 }
else if (rc == 0) {
1915 if (S_ISREG(st->st_mode) && st->st_nlink > 1)
1940 if (S_ISREG(st->st_mode))
1949 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
1956 for (li = iosm->
links, prev = NULL; li; prev = li, li = li->
next)
1975 if (S_ISREG(st->st_mode) && iosm->
lpath != NULL) {
1976 const char * opath = iosm->
opath;
1986 iosm->
opath = opath;
1989 if (S_ISREG(st->st_mode)) {
1990 const char * path = iosm->
path;
1995 if (rc == 0 && iosm->
osuffix) {
1996 const char * opath = iosm->
opath;
2002 _(
"%s saved as %s\n"),
2006 iosm->
opath = opath;
2014 }
else if (S_ISDIR(st->st_mode)) {
2015 mode_t st_mode = st->st_mode;
2018 st->st_mode &= ~07777;
2019 st->st_mode |= 00700;
2021 st->st_mode = st_mode;
2023 }
else if (
S_ISLNK(st->st_mode)) {
2024 assert(iosm->
lpath != NULL);
2028 }
else if (S_ISFIFO(st->st_mode)) {
2029 mode_t st_mode = st->st_mode;
2035 st->st_mode = st_mode;
2037 }
else if (S_ISCHR(st->st_mode) ||
2038 S_ISBLK(st->st_mode) ||
2053 if (S_ISREG(st->st_mode) && st->st_nlink > 1) {
2064 #if defined(_USE_RPMTS)
2068 if (archivePos > fi->archivePos) {
2069 fi->archivePos = (
unsigned long long) archivePos;
2071 fi->archivePos, fi->archiveSize);
2081 if (iosm->
sufbuf[0] !=
'\0')
2097 rc = ((S_ISREG(st->st_mode) && st->st_nlink > 1)
2107 memset(st, 0,
sizeof(*st));
2108 memset(ost, 0,
sizeof(*ost));
2115 const char * opath = iosm->
opath;
2116 const char * path = iosm->
path;
2128 iosm->
opath = opath;
2134 if (S_ISDIR(st->st_mode)) {
2147 _(
"rmdir of %s failed: Directory not empty\n"),
2153 _(
"rmdir of %s failed: %s\n"),
2168 _(
"unlink of %s failed: %s\n"),
2184 if (!S_ISDIR(st->st_mode) &&
2193 const char * opath =
iosmFsPath(iosm, st, NULL, NULL);
2195 (opath ? opath :
""),
2197 opath =
_free(opath);
2204 if (!rc && !getuid()) {
2211 if (!rc && !getuid())
2214 if (!rc && !getuid())
2219 time_t mtime = st->st_mtime;
2221 st->st_mtime = fi->fmtimes[iosm->
ix];
2223 st->st_mtime = mtime;
2241 while ((iosm->
li = iosm->
links) != NULL) {
2278 if (S_ISREG(st->st_mode)) {
2279 char * path = (
char *)
alloca(strlen(iosm->
path) +
sizeof(
"-RPMDELETE"));
2296 }
else if (S_ISDIR(st->st_mode)) {
2297 if (S_ISDIR(ost->st_mode))
return 0;
2303 if (S_ISDIR(ost->st_mode))
return 0;
2305 }
else if (
S_ISLNK(st->st_mode)) {
2311 if (!strcmp(iosm->
lpath, iosm->
rdbuf))
return 0;
2313 }
else if (S_ISFIFO(st->st_mode)) {
2314 if (S_ISFIFO(ost->st_mode))
return 0;
2315 }
else if (S_ISCHR(st->st_mode) || S_ISBLK(st->st_mode)) {
2316 if ((S_ISCHR(ost->st_mode) || S_ISBLK(ost->st_mode)) &&
2317 (ost->st_rdev == st->st_rdev))
return 0;
2318 }
else if (
S_ISSOCK(st->st_mode)) {
2319 if (
S_ISSOCK(ost->st_mode))
return 0;
2333 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
2336 (void)
Chmod(iosm->
path, stb.st_mode & 0777);
2342 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2351 && S_ISREG(stb.st_mode) && (stb.st_mode & 06000) != 0)
2354 (void)
Chmod(iosm->
path, stb.st_mode & 0777);
2361 #if defined(ETXTBSY)
2362 if (rc &&
errno == ETXTBSY) {
2363 char * path = (
char *)
alloca(strlen(iosm->
path) +
sizeof(
"-RPMDELETE"));
2373 if (iosm->
debug && (stage & IOSM_SYSCALL))
2379 rc =
Mkdir(iosm->
path, (st->st_mode & 07777));
2380 if (iosm->
debug && (stage & IOSM_SYSCALL))
2382 iosm->
path, (
unsigned)(st->st_mode & 07777),
2383 (rc < 0 ? strerror(
errno) :
""));
2388 if (iosm->
debug && (stage & IOSM_SYSCALL))
2390 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2399 {
const char * iosmpath = NULL;
2401 || !strcmp(iosm->
fcontext,
"<<none>>"))
2405 if (iosm->
debug && (stage & IOSM_SYSCALL))
2408 (rc < 0 ? strerror(
errno) :
""));
2412 rc =
Chown(iosm->
path, st->st_uid, st->st_gid);
2413 if (iosm->
debug && (stage & IOSM_SYSCALL))
2415 iosm->
path, (
int)st->st_uid, (
int)st->st_gid,
2416 (rc < 0 ? strerror(
errno) :
""));
2420 #if ! CHOWN_FOLLOWS_SYMLINK
2421 rc =
Lchown(iosm->
path, st->st_uid, st->st_gid);
2422 if (iosm->
debug && (stage & IOSM_SYSCALL))
2424 iosm->
path, (
int)st->st_uid, (
int)st->st_gid,
2425 (rc < 0 ? strerror(
errno) :
""));
2430 rc =
Chmod(iosm->
path, (st->st_mode & 07777));
2431 if (iosm->
debug && (stage & IOSM_SYSCALL))
2433 iosm->
path, (
unsigned)(st->st_mode & 07777),
2434 (rc < 0 ? strerror(
errno) :
""));
2438 {
struct utimbuf stamp;
2439 stamp.actime = st->st_mtime;
2440 stamp.modtime = st->st_mtime;
2442 if (iosm->
debug && (stage & IOSM_SYSCALL))
2444 iosm->
path, (
unsigned)st->st_mtime,
2445 (rc < 0 ? strerror(
errno) :
""));
2451 if (iosm->
debug && (stage & IOSM_SYSCALL))
2458 if (iosm->
debug && (stage & IOSM_SYSCALL))
2464 rc =
Mkfifo(iosm->
path, (st->st_mode & 07777));
2465 if (iosm->
debug && (stage & IOSM_SYSCALL))
2467 iosm->
path, (
unsigned)(st->st_mode & 07777),
2468 (rc < 0 ? strerror(
errno) :
""));
2473 rc =
Mknod(iosm->
path, (st->st_mode & ~07777), st->st_rdev);
2475 if (iosm->
debug && (stage & IOSM_SYSCALL))
2477 iosm->
path, (
unsigned)(st->st_mode & ~07777),
2478 (
unsigned)st->st_rdev,
2479 (rc < 0 ? strerror(
errno) :
""));
2484 if (iosm->
debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2486 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2489 memset(ost, 0,
sizeof(*ost));
2494 if (iosm->
debug && (stage & IOSM_SYSCALL) && rc &&
errno != ENOENT)
2496 iosm->
path, (rc < 0 ? strerror(
errno) :
""));
2499 memset(ost, 0,
sizeof(*ost));
2505 if (iosm->
debug && (stage & IOSM_SYSCALL))
2529 for (left = st->st_size; left > 0; left -= iosm->
rdnb) {
2547 iosm->
rdbuf[0] =
'\n';
2549 memset(iosm->
rdbuf, 0, left);
2568 if (iosm->
debug && (stage & IOSM_SYSCALL))
2570 cur, (iosm->
wrbuf == iosm->
wrb ?
"wrbuf" :
"mmap"),
2579 if (iosm->
debug && (stage & IOSM_SYSCALL))
2581 cur, (iosm->
rdbuf == iosm->
rdb ?
"rdbuf" :
"mmap"),
2597 #if defined(POSIX_FADV_WILLNEED)
2598 (void)
Fadvise(iosm->
rfd, 0, 0, POSIX_FADV_WILLNEED);
2600 if (iosm->
debug && (stage & IOSM_SYSCALL))
2606 if (iosm->
debug && (stage & IOSM_SYSCALL))
2608 cur, (
int)iosm->
rdlen, (
int)iosm->
rdnb);
2613 if (iosm->
rfd != NULL) {
2614 if (iosm->
debug && (stage & IOSM_SYSCALL))
2630 #if defined(POSIX_FADV_DONTNEED)
2632 (
void)
Fadvise(iosm->
wfd, 0, 0, POSIX_FADV_DONTNEED);
2634 if (iosm->
debug && (stage & IOSM_SYSCALL))
2640 if (iosm->
debug && (stage & IOSM_SYSCALL))
2642 cur, (
int)iosm->
rdnb, (
int)iosm->
wrnb);
2647 if (iosm->
wfd != NULL) {
2648 if (iosm->
debug && (stage & IOSM_SYSCALL))
2662 if (!(stage & IOSM_INTERNAL)) {
2669 #define IOSM_SKIPPING(_a) \
2670 ((_a) == FA_SKIP || (_a) == FA_SKIPNSTATE || (_a) == FA_SKIPNETSHARED || (_a) == FA_SKIPCOLOR)
2692 default:
return "???";
2758 default:
return "???";
2767 int l, myerrno =
errno;
2769 strcpy(msg,
"cpio: ");
2772 s = msg + strlen(msg);
2773 sprintf((
char *)s,
_(
"(error 0x%x)"), (
unsigned)rc);
2809 l =
sizeof(msg) - strlen(msg) - 1;
2811 if (l > 0) strncat(msg, s, l);
2815 s =
_(
" failed - ");
2816 if (l > 0) strncat(msg, s, l);
2818 if (l > 0) strncat(msg, strerror(myerrno), l);