Mageia Bugzilla – Attachment 1182 Details for
Bug 1962
genhdlist2 doesn't reuse most of the existing hdlist
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
New Account
|
Forgot Password
[patch]
patch from Panu Matilainen that makes headerRead works properly again for the previous test case
rpm-4.9.x-kill-libio.patch (text/plain), 4.96 KB, created by
Thierry Vignaud
on 2011-12-06 16:17:54 CET
(
hide
)
Description:
patch from Panu Matilainen that makes headerRead works properly again for the previous test case
Filename:
MIME Type:
Creator:
Thierry Vignaud
Created:
2011-12-06 16:17:54 CET
Size:
4.96 KB
patch
obsolete
>From: Panu Matilainen >Date: 22 Nov 2011 > >Right... I had forgotten just how much had changed in this area since 4.9.x and just how broken things had been. > >The header reading IO has been hardwired to ufdio (see timedRead() in rpmio.c) for pretty much all of its life, eliminating any possibility of compressed io working. The other piece of the puzzle is rpm's libio usage which affects the rpm io semantics to vary between fread() and read() styles. Which the header stuff can't cope with, hence the hardwire to ufdio. > >The attached patch makes my previous code snippet to read headers directly from compressed stream work on rpm-4.9.x too. It's essentially commit 3ab3a931b4dd84eedcb35229187e5be8d14f9418 from master + unconditionally disable libio usage. Rpm itself should be ok with this change as is (at least the test-suite still passes) but I can't guarantee it wont break anything else in your setup. Eg if you have code that's tuned to the exact semantics it had before... but then again it might just as well fix some "mysteriously broken things" for you. > >diff --git a/lib/header.c b/lib/header.c >index 8bea91a..06eb59e 100644 >--- a/lib/header.c >+++ b/lib/header.c >@@ -983,8 +983,7 @@ Header headerRead(FD_t fd, int magicp) > if (magicp == HEADER_MAGIC_YES) > i += 2; > >- /* FIX: cast? */ >- if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block))) >+ if (Fread(block, 1, i*sizeof(*block), fd) != i*sizeof(*block)) > goto exit; > > i = 0; >@@ -1010,8 +1009,7 @@ Header headerRead(FD_t fd, int magicp) > ei[1] = htonl(dl); > len -= sizeof(il) + sizeof(dl); > >- /* FIX: cast? */ >- if (timedRead(fd, (char *)&ei[2], len) != len) >+ if (Fread((char *)&ei[2], 1, len, fd) != len) > goto exit; > > h = headerLoad(ei); >diff --git a/lib/package.c b/lib/package.c >index e1795dd..51fd20b 100644 >--- a/lib/package.c >+++ b/lib/package.c >@@ -468,7 +468,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, > *msg = NULL; > > memset(block, 0, sizeof(block)); >- if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) { >+ if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { > rasprintf(&buf, > _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx); > goto exit; >@@ -494,7 +494,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, > ei = xmalloc(uc); > ei[0] = block[2]; > ei[1] = block[3]; >- if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) { >+ if ((xx = Fread((char *)&ei[2], 1, nb, fd)) != nb) { > rasprintf(&buf, _("hdr blob(%zd): BAD, read returned %d\n"), nb, xx); > goto exit; > } >diff --git a/lib/rpmlead.c b/lib/rpmlead.c >index d41a413..101d3ff 100644 >--- a/lib/rpmlead.c >+++ b/lib/rpmlead.c >@@ -116,8 +116,7 @@ rpmRC rpmLeadRead(FD_t fd, rpmlead lead) > { > assert(lead != NULL); > memset(lead, 0, sizeof(*lead)); >- /* FIX: remove timed read */ >- if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) { >+ if (Fread(lead, 1, sizeof(*lead), fd) != sizeof(*lead)) { > if (Ferror(fd)) { > rpmlog(RPMLOG_ERR, _("read failed: %s (%d)\n"), > Fstrerror(fd), errno); >diff --git a/lib/signature.c b/lib/signature.c >index 74d74a4..5fb4493 100644 >--- a/lib/signature.c >+++ b/lib/signature.c >@@ -86,7 +86,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) > goto exit; > > memset(block, 0, sizeof(block)); >- if ((xx = timedRead(fd, (void *)block, sizeof(block))) != sizeof(block)) { >+ if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { > rasprintf(&buf, _("sigh size(%d): BAD, read returned %d\n"), > (int)sizeof(block), xx); > goto exit; >@@ -117,7 +117,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) > ei[1] = block[3]; > pe = (entryInfo) &ei[2]; > dataStart = (unsigned char *) (pe + il); >- if ((xx = timedRead(fd, (void *)pe, nb)) != nb) { >+ if ((xx = Fread(pe, 1, nb, fd)) != nb) { > rasprintf(&buf, > _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx); > goto exit; >@@ -206,7 +206,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) > rpm_loff_t archSize = 0; > > /* Position at beginning of header. */ >- if (pad && (trc = timedRead(fd, (void *)block, pad)) != pad) { >+ if (pad && (trc = Fread(block, 1, pad, fd)) != pad) { > rasprintf(&buf, > _("sigh pad(%zd): BAD, read %zd bytes\n"), pad, trc); > goto exit; >diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c >index 2fbbf91..9614c55 100644 >--- a/rpmio/rpmio.c >+++ b/rpmio/rpmio.c >@@ -16,9 +16,7 @@ > > #include "debug.h" > >-#if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION) >-#define _USE_LIBIO 1 >-#endif >+#define _USE_LIBIO 0 > > typedef struct _FDSTACK_s { > FDIO_t io; >@@ -653,7 +651,7 @@ static const FDIO_t ufdio = &ufdio_s ; > > ssize_t timedRead(FD_t fd, void * bufptr, size_t length) > { >- return ufdio->read(fd, bufptr, length); >+ return Fread(bufptr, 1, length, fd); > } > > /* =============================================================== */
From: Panu Matilainen Date: 22 Nov 2011 Right... I had forgotten just how much had changed in this area since 4.9.x and just how broken things had been. The header reading IO has been hardwired to ufdio (see timedRead() in rpmio.c) for pretty much all of its life, eliminating any possibility of compressed io working. The other piece of the puzzle is rpm's libio usage which affects the rpm io semantics to vary between fread() and read() styles. Which the header stuff can't cope with, hence the hardwire to ufdio. The attached patch makes my previous code snippet to read headers directly from compressed stream work on rpm-4.9.x too. It's essentially commit 3ab3a931b4dd84eedcb35229187e5be8d14f9418 from master + unconditionally disable libio usage. Rpm itself should be ok with this change as is (at least the test-suite still passes) but I can't guarantee it wont break anything else in your setup. Eg if you have code that's tuned to the exact semantics it had before... but then again it might just as well fix some "mysteriously broken things" for you. diff --git a/lib/header.c b/lib/header.c index 8bea91a..06eb59e 100644 --- a/lib/header.c +++ b/lib/header.c @@ -983,8 +983,7 @@ Header headerRead(FD_t fd, int magicp) if (magicp == HEADER_MAGIC_YES) i += 2; - /* FIX: cast? */ - if (timedRead(fd, (char *)block, i*sizeof(*block)) != (i * sizeof(*block))) + if (Fread(block, 1, i*sizeof(*block), fd) != i*sizeof(*block)) goto exit; i = 0; @@ -1010,8 +1009,7 @@ Header headerRead(FD_t fd, int magicp) ei[1] = htonl(dl); len -= sizeof(il) + sizeof(dl); - /* FIX: cast? */ - if (timedRead(fd, (char *)&ei[2], len) != len) + if (Fread((char *)&ei[2], 1, len, fd) != len) goto exit; h = headerLoad(ei); diff --git a/lib/package.c b/lib/package.c index e1795dd..51fd20b 100644 --- a/lib/package.c +++ b/lib/package.c @@ -468,7 +468,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, *msg = NULL; memset(block, 0, sizeof(block)); - if ((xx = timedRead(fd, (char *)block, sizeof(block))) != sizeof(block)) { + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { rasprintf(&buf, _("hdr size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx); goto exit; @@ -494,7 +494,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags, ei = xmalloc(uc); ei[0] = block[2]; ei[1] = block[3]; - if ((xx = timedRead(fd, (char *)&ei[2], nb)) != nb) { + if ((xx = Fread((char *)&ei[2], 1, nb, fd)) != nb) { rasprintf(&buf, _("hdr blob(%zd): BAD, read returned %d\n"), nb, xx); goto exit; } diff --git a/lib/rpmlead.c b/lib/rpmlead.c index d41a413..101d3ff 100644 --- a/lib/rpmlead.c +++ b/lib/rpmlead.c @@ -116,8 +116,7 @@ rpmRC rpmLeadRead(FD_t fd, rpmlead lead) { assert(lead != NULL); memset(lead, 0, sizeof(*lead)); - /* FIX: remove timed read */ - if (timedRead(fd, (char *)lead, sizeof(*lead)) != sizeof(*lead)) { + if (Fread(lead, 1, sizeof(*lead), fd) != sizeof(*lead)) { if (Ferror(fd)) { rpmlog(RPMLOG_ERR, _("read failed: %s (%d)\n"), Fstrerror(fd), errno); diff --git a/lib/signature.c b/lib/signature.c index 74d74a4..5fb4493 100644 --- a/lib/signature.c +++ b/lib/signature.c @@ -86,7 +86,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) goto exit; memset(block, 0, sizeof(block)); - if ((xx = timedRead(fd, (void *)block, sizeof(block))) != sizeof(block)) { + if ((xx = Fread(block, 1, sizeof(block), fd)) != sizeof(block)) { rasprintf(&buf, _("sigh size(%d): BAD, read returned %d\n"), (int)sizeof(block), xx); goto exit; @@ -117,7 +117,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) ei[1] = block[3]; pe = (entryInfo) &ei[2]; dataStart = (unsigned char *) (pe + il); - if ((xx = timedRead(fd, (void *)pe, nb)) != nb) { + if ((xx = Fread(pe, 1, nb, fd)) != nb) { rasprintf(&buf, _("sigh blob(%d): BAD, read returned %d\n"), (int)nb, xx); goto exit; @@ -206,7 +206,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg) rpm_loff_t archSize = 0; /* Position at beginning of header. */ - if (pad && (trc = timedRead(fd, (void *)block, pad)) != pad) { + if (pad && (trc = Fread(block, 1, pad, fd)) != pad) { rasprintf(&buf, _("sigh pad(%zd): BAD, read %zd bytes\n"), pad, trc); goto exit; diff --git a/rpmio/rpmio.c b/rpmio/rpmio.c index 2fbbf91..9614c55 100644 --- a/rpmio/rpmio.c +++ b/rpmio/rpmio.c @@ -16,9 +16,7 @@ #include "debug.h" -#if HAVE_LIBIO_H && defined(_G_IO_IO_FILE_VERSION) -#define _USE_LIBIO 1 -#endif +#define _USE_LIBIO 0 typedef struct _FDSTACK_s { FDIO_t io; @@ -653,7 +651,7 @@ static const FDIO_t ufdio = &ufdio_s ; ssize_t timedRead(FD_t fd, void * bufptr, size_t length) { - return ufdio->read(fd, bufptr, length); + return Fread(bufptr, 1, length, fd); } /* =============================================================== */
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 1962
:
1181
| 1182 |
1183
|
1184