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
This commit is contained in:
jbj 1999-11-14 19:15:18 +00:00
parent 471ba3b238
commit 4e62a322a2
20 changed files with 524 additions and 459 deletions

View File

@ -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));

View File

@ -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)) {

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -48,7 +48,7 @@ FD_t fadOpen(const char * path, int flags, int perms)
/* XXX Fstrerror */
return NULL;
fdSetIoCookie(fd, fadio);
fdSetIo(fd, fadio);
fadSetFirstFree(fd, 0);
fadSetFileSize(fd, Fseek(fd, 0, SEEK_END));

View File

@ -304,7 +304,7 @@ static int getHostAddress(const char * host, struct in_addr * address)
return 0;
}
static int tcpConnect(const char *host, int port)
static int tcpConnect(FD_t ctrl, const char *host, int port)
{
struct sockaddr_in sin;
int fdno = -1;
@ -339,6 +339,7 @@ static int tcpConnect(const char *host, int port)
return fdno;
errxit:
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
if (fdno >= 0)
close(fdno);
return rc;
@ -364,14 +365,17 @@ int httpOpen(urlinfo u, FD_t ctrl, const char *httpcmd)
path = (u->proxyh || u->proxyp > 0) ? u->url : u->path;
reopen:
if (fdio->fileno(ctrl) >= 0 && fdWritable(ctrl, 0) < 1)
if (fdio->fileno(ctrl) >= 0 && (rc = fdWritable(ctrl, 0)) < 1) {
if (_ftp_debug)
fprintf(stderr, "*** httpOpen closing ctrl fdno %d rc %d\n", fdio->fileno(ctrl), rc);
fdio->close(ctrl);
}
if (fdio->fileno(ctrl) < 0) {
rc = tcpConnect(host, port);
rc = tcpConnect(ctrl, host, port);
fdSetFdno(ctrl, (rc >= 0 ? rc : -1));
if (rc < 0)
goto errxit;
goto errxit2;
ctrl = fdLink(ctrl, "open ctrl (httpOpen)");
}
@ -431,6 +435,8 @@ fprintf(stderr, "*** httpOpen ctrl %p reopening ...\n", ctrl);
return fdio->fileno(ctrl);
errxit:
fdSetSyserrno(ctrl, errno, ftpStrerror(rc));
errxit2:
if (fdio->fileno(ctrl) >= 0)
fdio->close(ctrl);
return rc;
@ -445,8 +451,10 @@ int ftpOpen(urlinfo u)
int rc;
URLSANE(u);
if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL))
return FTPERR_BAD_HOSTNAME;
if (((host = (u->proxyh ? u->proxyh : u->host)) == NULL)) {
rc = FTPERR_BAD_HOSTNAME;
goto errxit;
}
if ((port = (u->proxyp > 0 ? u->proxyp : u->port)) < 0) port = IPPORT_FTP;
@ -469,10 +477,10 @@ int ftpOpen(urlinfo u)
fdio->close(u->ctrl);
if (fdio->fileno(u->ctrl) < 0) {
rc = tcpConnect(host, port);
rc = tcpConnect(u->ctrl, host, port);
fdSetFdno(u->ctrl, (rc >= 0 ? rc : -1));
if (rc < 0)
goto errxit;
goto errxit2;
}
if ((rc = ftpCheckResponse(u, NULL)))
@ -491,6 +499,8 @@ int ftpOpen(urlinfo u)
return fdio->fileno(u->ctrl);
errxit:
fdSetSyserrno(u->ctrl, errno, ftpStrerror(rc));
errxit2:
if (fdio->fileno(u->ctrl) >= 0)
fdio->close(u->ctrl);
return rc;
@ -625,20 +635,17 @@ int ftpFileDesc(urlinfo u, const char *cmd, FD_t data)
sizeof(dataAddress)) < 0) {
if (errno == EINTR)
continue;
fdio->close(data);
rc = FTPERR_FAILED_DATA_CONNECT;
goto errxit;
}
DBG(0, (stderr, "-> %s", cmd));
if (fdio->write(u->ctrl, cmd, cmdlen) != cmdlen) {
fdio->close(data);
rc = FTPERR_SERVER_IO_ERROR;
goto errxit;
}
if ((rc = ftpCheckResponse(u, NULL))) {
fdio->close(data);
goto errxit;
}
@ -648,5 +655,9 @@ int ftpFileDesc(urlinfo u, const char *cmd, FD_t data)
return 0;
errxit:
fdSetSyserrno(u->ctrl, errno, ftpStrerror(rc));
errxit2:
if (fdio->fileno(data) >= 0)
fdio->close(data);
return rc;
}

View File

@ -348,7 +348,7 @@ static int installArchive(FD_t fd, struct fileInfo * files,
(void)notify(h, RPMCALLBACK_INST_PROGRESS, 0, archiveSize, pkgKey,
notifyData);
cfd = Fdopen(fdDup(Fileno(fd)), "r.gzdio");
cfd = Fdopen(fd, "r.gzdio");
rc = cpioInstallArchive(cfd, map, mappedFiles,
((notify && archiveSize) || specFile) ? callback : NULL,
&info, &failedFile);

View File

@ -1300,7 +1300,7 @@ initMacros(MacroContext *mc, const char *macrofiles)
strncat(buf, mfile, sizeof(buf) - strlen(buf));
buf[sizeof(buf)-1] = '\0';
fd = Fopen(buf, "r.ufdio");
fd = Fopen(buf, "r.fpio");
if (fd == NULL || Ferror(fd))
continue;
@ -1357,11 +1357,7 @@ int isCompressed(const char *file, int *compressed)
*compressed = COMPRESSED_NOT;
#ifdef DYING
fd = fdOpen(file, O_RDONLY, 0);
#else
fd = Fopen(file, "r.ufdio");
#endif
if (fd == NULL || Ferror(fd)) {
/* XXX Fstrerror */
rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));

View File

@ -404,7 +404,7 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
}
/* XXX FIXME: build/build.c Fdopen assertion failure, makeTempFile uses fdio */
#ifndef NOTYET
#ifdef DYING
fd = fdio->open(tfn, (O_CREAT|O_RDWR|O_EXCL), 0700);
#else
fd = Fopen(tfn, "w+x.ufdio");
@ -424,14 +424,16 @@ int makeTempFile(const char * prefix, const char ** fnptr, FD_t * fdptr) {
}
#ifndef NOTYET
fstat(Fileno(fd), &sb2);
if (fstat(Fileno(fd), &sb2) == 0)
#else
Stat(tfn, &sb2);
if (Stat(tfn, &sb2) == 0)
#endif
if (sb2.st_ino != sb.st_ino || sb2.st_dev != sb.st_dev) {
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
xfree(tfn);
return 1;
{
if (sb2.st_ino != sb.st_ino || sb2.st_dev != sb.st_dev) {
rpmError(RPMERR_SCRIPT, _("error creating temporary file %s"), tfn);
xfree(tfn);
return 1;
}
}
if (fnptr)

View File

@ -18,7 +18,7 @@ typedef /*@null@*/ FD_t fdio_ref_function_t ( /*@only@*/ void * cookie,
typedef /*@null@*/ FD_t fdio_deref_function_t ( /*@only@*/ FD_t fd,
const char * msg, const char * file, unsigned line);
typedef /*@null@*/ FD_t fdio_new_function_t (FDIO_t iop, const char * msg,
typedef /*@null@*/ FD_t fdio_new_function_t (const char * msg,
const char * file, unsigned line);
typedef int fdio_fileno_function_t (void * cookie);
@ -89,9 +89,15 @@ int Access (const char * path, int amode);
/*@observer@*/ extern FDIO_t gzdio;
void fdPush(FD_t fd, FDIO_t io, void * fp, int fdno);
void fdPop(FD_t fd);
void fdSetFdno(FD_t fd, int fdno);
/*@null@*/ const FDIO_t fdGetIoCookie(FD_t fd);
void fdSetIoCookie(FD_t fd, FDIO_t iop);
off_t fdSize(FD_t fd);
void fdSetSyserrno(FD_t fd, int syserrno, const void * errcookie);
/*@null@*/ const FDIO_t fdGetIo(FD_t fd);
void fdSetIo(FD_t fd, FDIO_t io);
int fdGetRdTimeoutSecs(FD_t fd);
@ -115,7 +121,7 @@ extern /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
#define fdLink(_fd, _msg) fdio->ref(_fd, _msg, __FILE__, __LINE__)
#define fdFree(_fd, _msg) fdio->deref(_fd, _msg, __FILE__, __LINE__)
#define fdNew(_iop, _msg) fdio->new(_iop, _msg, __FILE__, __LINE__)
#define fdNew(_msg) fdio->new(_msg, __FILE__, __LINE__)
#if 0
#define fdFileno fdio->fileno
@ -131,6 +137,7 @@ extern /*@null@*/ FILE *fdFdopen( /*@only@*/ void * cookie, const char * mode);
/*@dependent@*/ /*@null@*/ void * ufdGetUrlinfo(FD_t fd);
/*@observer@*/ const char * urlStrerror(const char * url);
int ufdCopy(FD_t sfd, FD_t tfd);
int ufdGetFile( /*@killref@*/ FD_t sfd, FD_t tfd);
const char *const ftpStrerror(int errorNumber);

View File

@ -104,7 +104,7 @@ static int currTables[2] = { RPM_MACHTABLE_INSTOS, RPM_MACHTABLE_INSTARCH };
static struct rpmvarValue values[RPMVAR_NUM];
/* prototypes */
static int doReadRC(FD_t fd, const char * filename);
static int doReadRC(FD_t fd, const char * urlfn);
static void rpmSetVarArch(int var, const char * val, const char * arch);
static void rebuildCompatTables(int type, const char *name);
@ -548,7 +548,7 @@ int rpmReadRC(const char * rcfiles)
strcat(fn, r);
/* Read another rcfile */
fd = Fopen(fn, "r.ufdio");
fd = Fopen(fn, "r.fpio");
if (fd == NULL || Ferror(fd)) {
/* XXX Only /usr/lib/rpm/rpmrc must exist in default rcfiles list */
if (rcfiles == defrcfiles && myrcfiles != r)
@ -579,7 +579,7 @@ int rpmReadRC(const char * rcfiles)
return rc;
}
static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
static int doReadRC( /*@killref@*/ FD_t fd, const char * urlfn)
{
const char *s;
char *se, *next;
@ -587,17 +587,18 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
struct rpmOption searchOption, * option;
int rc;
/* XXX fstat doesn't work on ufdio, default to 64K */
{ struct stat sb;
int fdno = Fileno(fd);
size_t nb;
fstat(fdno, &sb);
nb = (sb.st_size > 0 ? sb.st_size : (8*BUFSIZ - 2));
/* XXX really need rc = Slurp(fd, const char * filename, char ** buf) */
{ off_t size = fdSize(fd);
size_t nb = (size >= 0 ? size : (8*BUFSIZ - 2));
if (nb == 0) {
Fclose(fd);
return 0;
}
next = alloca(nb + 2);
next[0] = '\0';
rc = Fread(next, sizeof(*next), nb, fd);
if (Ferror(fd) || (sb.st_size > 0 && rc != nb)) { /* XXX Feof(fd) */
rpmError(RPMERR_RPMRC, _("Failed to read %s: %s."), filename,
if (Ferror(fd) || (size > 0 && rc != nb)) { /* XXX Feof(fd) */
rpmError(RPMERR_RPMRC, _("Failed to read %s: %s."), urlfn,
Fstrerror(fd));
rc = 1;
} else
@ -635,7 +636,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
if (*se != ':') {
rpmError(RPMERR_RPMRC, _("missing ':' (found 0x%02x) at %s:%d"),
(0xff & *se), filename, linenum);
(0xff & *se), urlfn, linenum);
return 1;
}
*se++ = '\0'; /* terminate keyword or option, point to value */
@ -652,7 +653,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
arch = val = fn = NULL;
if (*se == '\0') {
rpmError(RPMERR_RPMRC, _("missing argument for %s at %s:%d"),
option->name, filename, linenum);
option->name, urlfn, linenum);
return 1;
}
@ -669,16 +670,16 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
fn = rpmGetPath(s, NULL);
if (fn == NULL || *fn == '\0') {
rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\""),
option->name, filename, linenum, s);
option->name, urlfn, linenum, s);
if (fn) xfree(fn);
return 1;
/*@notreached@*/
}
fdinc = Fopen(fn, "r.ufdio");
fdinc = Fopen(fn, "r.fpio");
if (fdinc == NULL || Ferror(fdinc)) {
rpmError(RPMERR_RPMRC, _("cannot open %s at %s:%d: %s"),
fn, filename, linenum, Fstrerror(fdinc));
fn, urlfn, linenum, Fstrerror(fdinc));
rc = 1;
} else {
rc = doReadRC(fdinc, fn);
@ -691,7 +692,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
fn = rpmGetPath(se, NULL);
if (fn == NULL || *fn == '\0') {
rpmError(RPMERR_RPMRC, _("%s expansion failed at %s:%d \"%s\""),
option->name, filename, linenum, fn);
option->name, urlfn, linenum, fn);
if (fn) xfree(fn);
return 1;
}
@ -718,7 +719,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
if (*se == '\0') {
rpmError(RPMERR_RPMRC,
_("missing architecture for %s at %s:%d"),
option->name, filename, linenum);
option->name, urlfn, linenum);
return 1;
}
*se++ = '\0';
@ -726,7 +727,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
if (*se == '\0') {
rpmError(RPMERR_RPMRC,
_("missing argument for %s at %s:%d"),
option->name, filename, linenum);
option->name, urlfn, linenum);
return 1;
}
}
@ -763,7 +764,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
if (*rest == '_') rest++;
if (!strcmp(rest, "compat")) {
if (machCompatCacheAdd(se, filename, linenum,
if (machCompatCacheAdd(se, urlfn, linenum,
&tables[i].cache))
return 1;
gotit = 1;
@ -771,13 +772,13 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
!strcmp(rest, "translate")) {
if (addDefault(&tables[i].defaults,
&tables[i].defaultsLength,
se, filename, linenum))
se, urlfn, linenum))
return 1;
gotit = 1;
} else if (tables[i].hasCanon &&
!strcmp(rest, "canon")) {
if (addCanon(&tables[i].canons, &tables[i].canonsLength,
se, filename, linenum))
se, urlfn, linenum))
return 1;
gotit = 1;
}
@ -785,7 +786,7 @@ static int doReadRC( /*@killref@*/ FD_t fd, const char * filename)
if (!gotit) {
rpmError(RPMERR_RPMRC, _("bad option '%s' at %s:%d"),
s, filename, linenum);
s, urlfn, linenum);
}
}
}

View File

@ -64,20 +64,22 @@ DBGREFS(0, (stderr, "--> url %p -- %d %s at %s:%u\n", u, u->nrefs, msg, file, li
if (--u->nrefs > 0)
return u;
if (u->ctrl) {
void * uctrl = u->ctrl;
if (fdio->fileno(u->ctrl) >= 0)
fdio->close(u->ctrl);
u->ctrl = fdio->deref(u->ctrl, "persist ctrl (urlFree)", file, line);
if (u->ctrl)
fprintf(stderr, _("warning: u %p ctrl nrefs != 0 (%s %s)\n"),
u, u->host, u->service);
fprintf(stderr, _("warning: u %p ctrl %p nrefs != 0 (%s %s)\n"),
u, uctrl, u->host, u->service);
}
if (u->data) {
void * udata = u->data;
if (fdio->fileno(u->data) >= 0)
fdio->close(u->data);
u->data = fdio->deref(u->data, "persist data (urlFree)", file, line);
if (u->data)
fprintf(stderr, _("warning: data nrefs != 0 (%s %s)\n"),
u, u->host, u->service);
fprintf(stderr, _("warning: u %p data %p nrefs != 0 (%s %s)\n"),
u, udata, u->host, u->service);
}
if (u->buf) {
free(u->buf);

File diff suppressed because it is too large Load Diff

3
rpm.c
View File

@ -70,6 +70,7 @@ static int initdb;
static int justdb;
static int noDeps;
static int noGpg;
extern int noLibio;
static int noMd5;
static int noOrder;
static int noPgp;
@ -132,6 +133,7 @@ static struct poptOption optionsTable[] = {
{ "justdb", '\0', 0, &justdb, 0, NULL, NULL},
{ "nodeps", '\0', 0, &noDeps, 0, NULL, NULL},
{ "nogpg", '\0', 0, &noGpg, 0, NULL, NULL},
{ "nolibio", '\0', 0, &noLibio, 0, NULL, NULL},
{ "nomd5", '\0', 0, &noMd5, 0, NULL, NULL},
{ "noorder", '\0', 0, &noOrder, 0, NULL, NULL},
{ "nopgp", '\0', 0, &noPgp, 0, NULL, NULL},
@ -581,6 +583,7 @@ int main(int argc, const char ** argv)
justdb = 0;
noDeps = 0;
noGpg = 0;
noLibio = 0;
noMd5 = 0;
noOrder = 0;
noPgp = 0;

View File

@ -7,10 +7,8 @@
int main(int argc, char **argv)
{
FD_t fdi, fdo;
Header hd;
Header h;
int rc, isSource;
char buffer[1024];
int ct;
FD_t gzdi;
setprogname(argv[0]); /* Retrofit glibc __progname */
@ -20,13 +18,13 @@ int main(int argc, char **argv)
fdi = Fopen(argv[1], "r.ufdio");
}
if (Fileno(fdi) < 0) {
perror("cannot open package");
if (fdi == NULL || Ferror(fdi)) {
fprintf(stderr, _("cannot open package: %s\n"), Fstrerror(fdi));
exit(EXIT_FAILURE);
}
fdo = fdDup(STDOUT_FILENO);
rc = rpmReadPackageHeader(fdi, &hd, &isSource, NULL, NULL);
rc = rpmReadPackageHeader(fdi, &h, &isSource, NULL, NULL);
switch (rc) {
case 0:
break;
@ -40,12 +38,15 @@ int main(int argc, char **argv)
break;
}
#ifdef DYING
gzdi = gzdFdopen(fdi, "r"); /* XXX gzdi == fdi */
#else
gzdi = Fdopen(fdi, "r.gzdio"); /* XXX gzdi == fdi */
#endif
if (gzdi == NULL || Ferror(gzdi)) {
fprintf(stderr, _("cannot re-open payload: %s\n"), Fstrerror(gzdi));
exit(EXIT_FAILURE);
}
#ifdef DYING
{ char buffer[BUFSIZ];
int ct;
while ((ct = Fread(buffer, sizeof(buffer[0]), sizeof(buffer), gzdi)) > 0) {
Fwrite(buffer, sizeof(buffer[0]), ct, fdo);
}
@ -56,6 +57,12 @@ int main(int argc, char **argv)
} else {
rc = EXIT_SUCCESS;
}
}
#else
rc = ufdCopy(gzdi, fdo);
rc = (rc <= 0) ? EXIT_FAILURE : EXIT_SUCCESS;
Fclose(fdo);
#endif
Fclose(gzdi); /* XXX gzdi == fdi */

View File

@ -1300,7 +1300,7 @@ initMacros(MacroContext *mc, const char *macrofiles)
strncat(buf, mfile, sizeof(buf) - strlen(buf));
buf[sizeof(buf)-1] = '\0';
fd = Fopen(buf, "r.ufdio");
fd = Fopen(buf, "r.fpio");
if (fd == NULL || Ferror(fd))
continue;
@ -1357,11 +1357,7 @@ int isCompressed(const char *file, int *compressed)
*compressed = COMPRESSED_NOT;
#ifdef DYING
fd = fdOpen(file, O_RDONLY, 0);
#else
fd = Fopen(file, "r.ufdio");
#endif
if (fd == NULL || Ferror(fd)) {
/* XXX Fstrerror */
rpmError(RPMERR_BADSPEC, _("File %s: %s"), file, Fstrerror(fd));

View File

@ -147,13 +147,13 @@ varprefix = @varprefix@
AUTOMAKE_OPTIONS = 1.4 foreign
EXTRA_DIST = convertrpmrc.sh find-lang.sh freshen.sh getpo.sh perl.prov perl.req vpkg-provides.sh
EXTRA_DIST = convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req perl.prov perl.req rpmdiff u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
installprefix = $(DESTDIR)
configdir = ${prefix}/lib/rpm
config_SCRIPTS = convertrpmrc.sh find-lang.sh freshen.sh getpo.sh perl.prov perl.req vpkg-provides.sh
config_SCRIPTS = convertrpmrc.sh find-lang.sh find-prov.pl find-req.pl freshen.sh get_magic.pl getpo.sh http.req magic.prov magic.req perl.prov perl.req rpmdiff u_pkg.sh vpkg-provides.sh vpkg-provides2.sh
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
CONFIG_HEADER = ../config.h

View File

@ -761,7 +761,7 @@ rewriteBinaryRPM(char *fni, char *fno, message_list_ty *mlp)
DPRINTF(99, ("rewriteBinaryRPM(\"%s\",\"%s\",%p)\n", fni, fno, mlp));
csa->cpioArchiveSize = 0;
csa->cpioFdIn = fdNew(fdio, "init (rewriteBinary)");
csa->cpioFdIn = fdNew("init (rewriteBinary)");
csa->cpioList = NULL;
csa->cpioCount = 0;
csa->lead = &lead; /* XXX FIXME: exorcize lead/arch/os */

View File

@ -444,7 +444,7 @@ rewriteRPM(const char *fni, const char *fno, cmd_t *cmds[], int ncmds)
int rc;
csa->cpioArchiveSize = 0;
csa->cpioFdIn = fdNew(fdio, "init (rewriteRPM)");
csa->cpioFdIn = fdNew("init (rewriteRPM)");
csa->cpioList = NULL;
csa->cpioCount = 0;
csa->lead = &lead; /* XXX FIXME: exorcize lead/arch/os */