diff options
author | jbj <devnull@localhost> | 1999-11-14 19:15:18 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 1999-11-14 19:15:18 +0000 |
commit | 4e62a322a266e9d95007540d10e67fc75bf80aa7 (patch) | |
tree | f1ba2b2704bf0397cc7d0bac2b323480aed56a8a /build | |
parent | 471ba3b2386a15b5cd0ad202238dd38161788416 (diff) | |
download | rpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.gz rpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.tar.bz2 rpm-4e62a322a266e9d95007540d10e67fc75bf80aa7.zip |
lib/rpmio.c: Implement per-fd layers as a stack, add fdPush/fdPop.
lib/rpmio.c: Add fd{Get,Set}{Io,Fp,Fdno} abstraction wrappers.
lib/rpmio.c: Start rationalizing debug output by using fdbg to display the
fd layer stack.
rpm.c: Add --nolibio to disable libio if desired.
rpm2cpio.c: Use Fdopen(..., gzdio) and ufdCopy().
build/build.c: Use Fdopen(..., fpio) rather than fdio.
build/files.c: Use Fdopen(..., fpio) rather than ufdio.
build/parseSpec.c: ditto.
lib/macro.c: ditto.
lib/rpmrc.c: ditto
lib/macro.c: Use Fopen(..., ufdio) in isCompressed() rather that fdOpen().
lib/misc.c: ditto.
lib/misc.c: Avoid fstat by using Stat.
build/pack.c: Add persist fdLink() and use fdFree() in package{Sources,Binaries}
build/pack.c: Try to remove the fdDup before cpioBuildArchive() call.
build/pack.c: Use rpmGenPath with %{_builddir}.
build/parsePreamble.c: Use fdSize rather than Stat to get icon file size.
lib/rpmrc.c: ditto
lib/ftp.c: start capturing ufdio layer syserrno/errcookie.
CVS patchset: 3424
CVS date: 1999/11/14 19:15:18
Diffstat (limited to 'build')
-rw-r--r-- | build/build.c | 4 | ||||
-rw-r--r-- | build/files.c | 2 | ||||
-rw-r--r-- | build/pack.c | 41 | ||||
-rw-r--r-- | build/parsePreamble.c | 29 | ||||
-rw-r--r-- | build/parseSpec.c | 6 |
5 files changed, 56 insertions, 26 deletions
diff --git a/build/build.c b/build/build.c index f1b9d423e..e11bfed3a 100644 --- a/build/build.c +++ b/build/build.c @@ -87,8 +87,12 @@ int doScript(Spec spec, int what, const char *name, StringBuf sb, int test) #ifdef HAVE_FCHMOD (void)fchmod(Fileno(fd), 0600); /* XXX fubar on ufdio */ #endif +#ifdef DYING /* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */ xfd = Fdopen(fd, "w.fdio"); +#else + xfd = Fdopen(fd, "w.fpio"); +#endif strcpy(buf, _preScriptEnvironment); expandMacros(spec, spec->macros, buf, sizeof(buf)); diff --git a/build/files.c b/build/files.c index 77f033809..797b87e09 100644 --- a/build/files.c +++ b/build/files.c @@ -1176,7 +1176,7 @@ static int processPackageFiles(Spec spec, Package pkg, ffn = rpmGetPath("%{_builddir}/", (spec->buildSubdir ? spec->buildSubdir : "") , "/", pkg->fileFile, NULL); - fd = Fopen(ffn, "r.ufdio"); + fd = Fopen(ffn, "r.fpio"); xfree(ffn); if (fd == NULL || Ferror(fd)) { diff --git a/build/pack.c b/build/pack.c index 059acdad8..3791742b8 100644 --- a/build/pack.c +++ b/build/pack.c @@ -59,13 +59,14 @@ int packageSources(Spec spec) memset(csa, 0, sizeof(*csa)); csa->cpioArchiveSize = 0; - csa->cpioFdIn = fdNew(fdio, "init (packageSources)"); + csa->cpioFdIn = fdNew("init (packageSources)"); + csa->cpioFdIn = fdLink(csa->cpioFdIn, "persist (packageSources)"); csa->cpioList = spec->sourceCpioList; csa->cpioCount = spec->sourceCpioCount; rc = writeRPM(spec->sourceHeader, fn, RPMLEAD_SOURCE, csa, spec->passPhrase, &(spec->cookie)); - free(csa->cpioFdIn); + csa->cpioFdIn = fdFree(csa->cpioFdIn, "persist (packageSources)"); xfree(fn); } return rc; @@ -156,13 +157,14 @@ int packageBinaries(Spec spec) memset(csa, 0, sizeof(*csa)); csa->cpioArchiveSize = 0; - csa->cpioFdIn = fdNew(fdio, "init (packageBinaries)"); + csa->cpioFdIn = fdNew("init (packageBinaries)"); + csa->cpioFdIn = fdLink(csa->cpioFdIn, "persist (packageBinaries)"); csa->cpioList = pkg->cpioList; csa->cpioCount = pkg->cpioCount; rc = writeRPM(pkg->header, fn, RPMLEAD_BINARY, csa, spec->passPhrase, NULL); - free(csa->cpioFdIn); + csa->cpioFdIn = fdFree(csa->cpioFdIn, "persist (packageBinaries)"); xfree(fn); if (rc) return rc; @@ -245,6 +247,9 @@ int writeRPM(Header h, const char *fileName, int type, char buf[BUFSIZ]; Header sig; struct rpmlead lead; +#ifdef DYING + int fdno; +#endif if (Fileno(csa->cpioFdIn) < 0) { csa->cpioArchiveSize = 0; @@ -267,6 +272,12 @@ int writeRPM(Header h, const char *fileName, int type, rpmError(RPMERR_CREATE, _("Unable to open temp file")); return RPMERR_CREATE; } + +#ifdef DYING + fd = fdLink(fd, "persist"); /* XXX keep fd from being freed */ + fdno = Fileno(fd); /* XXX HACK HACK HACK to keep fdno open */ +#endif + if (headerWrite(fd, h, HEADER_MAGIC_YES)) { rc = RPMERR_NOSPACE; } else { /* Write the archive and get the size */ @@ -279,6 +290,11 @@ int writeRPM(Header h, const char *fileName, int type, rc = RPMERR_BADARG; } } + +#ifdef DYING + fdSetFdno(fd, fdno); /* XXX HACK HACK HACK to keep fdno open */ +#endif + if (rc != 0) { Fclose(fd); unlink(sigtarget); @@ -419,7 +435,11 @@ static int cpio_doio(FD_t fdo, CSA_t * csa, const char * fmode) int rc; const char *failedFile = NULL; +#ifndef DYING cfd = Fdopen(fdDup(Fileno(fdo)), fmode); +#else + cfd = Fdopen(fdo, fmode); +#endif rc = cpioBuildArchive(cfd, csa->cpioList, csa->cpioCount, NULL, NULL, &csa->cpioArchiveSize, &failedFile); if (rc) { @@ -438,7 +458,7 @@ static int cpio_doio(FD_t fdo, CSA_t * csa, const char * fmode) static int cpio_copy(FD_t fdo, CSA_t *csa) { char buf[BUFSIZ]; - ssize_t nb; + size_t nb; while((nb = Fread(buf, sizeof(buf[0]), sizeof(buf), csa->cpioFdIn)) > 0) { if (Fwrite(buf, sizeof(buf[0]), nb, fdo) != nb) { @@ -448,7 +468,7 @@ static int cpio_copy(FD_t fdo, CSA_t *csa) } csa->cpioArchiveSize += nb; } - if (nb < 0) { + if (Ferror(csa->cpioFdIn)) { rpmError(RPMERR_CPIO, _("cpio_copy read failed: %s"), Fstrerror(csa->cpioFdIn)); return 1; @@ -462,15 +482,8 @@ static StringBuf addFileToTagAux(Spec spec, const char *file, StringBuf sb) const char *fn = buf; FD_t fd; -#ifdef DYING - strcpy(fn, "%{_builddir}/"); - expandMacros(spec, spec->macros, fn, sizeof(fn)); - strcat(fn, spec->buildSubdir); - strcat(fn, "/"); - strcat(fn, file); -#else + /* XXX use rpmGenPath(rootdir, "%{_buildir}/%{_buildsubdir}/", file) */ fn = rpmGetPath("%{_builddir}/", spec->buildSubdir, "/", file, NULL); -#endif fd = Fopen(fn, "r.ufdio"); if (fn != buf) xfree(fn); diff --git a/build/parsePreamble.c b/build/parsePreamble.c index ec9486620..d4ed8e51d 100644 --- a/build/parsePreamble.c +++ b/build/parsePreamble.c @@ -229,22 +229,24 @@ static int readIcon(Header h, const char *file) { const char *fn = NULL; char *icon; +#ifdef DYING struct stat statbuf; +#endif FD_t fd; int rc = 0; - int nb; + off_t size; + size_t nb, iconsize; /* XXX use rpmGenPath(rootdir, "%{_sourcedir}/", file) for icon path. */ fn = rpmGetPath("%{_sourcedir}/", file, NULL); +#ifdef DYING if (Stat(fn, &statbuf)) { rpmError(RPMERR_BADSPEC, _("Unable to stat icon: %s"), fn); rc = RPMERR_BADSPEC; goto exit; } - - icon = xmalloc(statbuf.st_size); - *icon = '\0'; +#endif fd = Fopen(fn, "r.ufdio"); if (fd == NULL || Ferror(fd)) { @@ -253,8 +255,19 @@ static int readIcon(Header h, const char *file) rc = RPMERR_BADSPEC; goto exit; } - nb = Fread(icon, sizeof(char), statbuf.st_size, fd); - if (nb != statbuf.st_size) { + size = fdSize(fd); + iconsize = (size >= 0 ? size : (8 * BUFSIZ)); + if (iconsize == 0) { + Fclose(fd); + rc = 0; + goto exit; + } + + icon = xmalloc(iconsize + 1); + *icon = '\0'; + + nb = Fread(icon, sizeof(char), iconsize, fd); + if (Ferror(fd) || (size >= 0 && nb != size)) { rpmError(RPMERR_BADSPEC, _("Unable to read icon %s: %s"), fn, Fstrerror(fd)); rc = RPMERR_BADSPEC; @@ -264,9 +277,9 @@ static int readIcon(Header h, const char *file) goto exit; if (! strncmp(icon, "GIF", sizeof("GIF")-1)) { - headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, statbuf.st_size); + headerAddEntry(h, RPMTAG_GIF, RPM_BIN_TYPE, icon, iconsize); } else if (! strncmp(icon, "/* XPM", sizeof("/* XPM")-1)) { - headerAddEntry(h, RPMTAG_XPM, RPM_BIN_TYPE, icon, statbuf.st_size); + headerAddEntry(h, RPMTAG_XPM, RPM_BIN_TYPE, icon, iconsize); } else { rpmError(RPMERR_BADSPEC, _("Unknown icon type: %s"), file); rc = RPMERR_BADSPEC; diff --git a/build/parseSpec.c b/build/parseSpec.c index adaae0baf..108006313 100644 --- a/build/parseSpec.c +++ b/build/parseSpec.c @@ -169,10 +169,10 @@ int readLine(Spec spec, int strip) retry: /* Make sure the current file is open */ if (ofi->fd == NULL) { - if ((ofi->fd = Fopen(ofi->fileName, "r.ufdio")) == NULL) { + if ((ofi->fd = Fopen(ofi->fileName, "r.fpio")) == NULL) { /* XXX Fstrerror */ - rpmError(RPMERR_BADSPEC, _("Unable to open: %s\n"), - ofi->fileName); + rpmError(RPMERR_BADSPEC, _("Unable to open %s: %s\n"), + ofi->fileName, Fstrerror(ofi->fd)); return RPMERR_BADSPEC; } spec->lineNum = ofi->lineNum = 0; |