RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   11-Mar-2008 05:00:57
  Branch: HEAD                             Handle: 2008031104005601

  Modified files:
    rpm                     CHANGES
    rpm/lib                 fsm.c psm.c
    rpm/rpmio               ar.c cpio.c iosm.c tar.c

  Log:
    - jbj: mark write padding for possible refactoring to common code.
    - jbj: ar: verify archive magic.
    - jbj: ar: arSetup is only needed when creating archives. read EOF is wonky.
    - jbj: verify that cpio/tar payloads can be created and installed.
    - jbj: psm: fix: adding ar payloads broke install payload detection.
    - jbj: use _IOSMRC macro to ensure read/write rc are handled consistently.

  Summary:
    Revision    Changes     Path
    1.2235      +6  -0      rpm/CHANGES
    2.167       +3  -2      rpm/lib/fsm.c
    2.296       +4  -4      rpm/lib/psm.c
    1.16        +46 -18     rpm/rpmio/ar.c
    1.9         +37 -17     rpm/rpmio/cpio.c
    1.20        +3  -1      rpm/rpmio/iosm.c
    1.10        +39 -15     rpm/rpmio/tar.c
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.2234 -r1.2235 CHANGES
  --- rpm/CHANGES       10 Mar 2008 21:18:06 -0000      1.2234
  +++ rpm/CHANGES       11 Mar 2008 04:00:56 -0000      1.2235
  @@ -1,4 +1,10 @@
   5.0.0 -> 5.1a1:
  +    - jbj: mark write padding for possible refactoring to common code.
  +    - jbj: ar: verify archive magic.
  +    - jbj: ar: arSetup is only needed when creating archives. read EOF is 
wonky.
  +    - jbj: verify that cpio/tar payloads can be created and installed.
  +    - jbj: psm: fix: adding ar payloads broke install payload detection.
  +    - jbj: use _IOSMRC macro to ensure read/write rc are handled 
consistently.
       - jbj: make sure cpio/tar/ar are as similar as possible.
       - jbj: keep tar.c parallel to ar.c coding conventions. cpio.c next.
       - jbj: clean up most rpmio gcc -W warnings.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/fsm.c
  ============================================================================
  $ cvs diff -u -r2.166 -r2.167 fsm.c
  --- rpm/lib/fsm.c     10 Mar 2008 21:18:06 -0000      2.166
  +++ rpm/lib/fsm.c     11 Mar 2008 04:00:57 -0000      2.167
  @@ -633,6 +633,7 @@
   fprintf(stderr, "--> fsmSetup(%p, 0x%x, \"%s\", %p, %p, %p, %p, %p)\n", fsm, 
goal, afmt, (void *)ts, fi, cfd, archiveSize, failedFile);
   /[EMAIL PROTECTED] [EMAIL PROTECTED]/
   
  +    _iosmNext = &fsmNext;
       if (fsm->headerRead == NULL) {
        if (afmt != NULL && (!strcmp(afmt, "tar") || !strcmp(afmt, "ustar"))) {
   if (fsm->debug < 0)
  @@ -646,12 +647,12 @@
        if (afmt != NULL && !strcmp(afmt, "ar")) {
   if (fsm->debug < 0)
   fprintf(stderr, "\tar vectors set\n");
  -         _fsmNext = &fsmNext;
            fsm->headerRead = &arHeaderRead;
            fsm->headerWrite = &arHeaderWrite;
            fsm->trailerWrite = &arTrailerWrite;
            fsm->blksize = 2;
  -         (void) arSetup(fsm, fi);
  +         if (goal == IOSM_PKGBUILD || goal == IOSM_PKGERASE)
  +             (void) arSetup(fsm, fi);
        } else
   #endif
        {
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/psm.c
  ============================================================================
  $ cvs diff -u -r2.295 -r2.296 psm.c
  --- rpm/lib/psm.c     10 Mar 2008 04:46:13 -0000      2.295
  +++ rpm/lib/psm.c     11 Mar 2008 04:00:57 -0000      2.296
  @@ -2445,12 +2445,12 @@
        he->tag = RPMTAG_PAYLOADFORMAT;
        xx = headerGet(fi->h, he, 0);
        payload_format = he->p.str;
  -     if (!xx || payload_format == NULL
  -      || !(!strcmp(payload_format, "tar") || !strcmp(payload_format, 
"ustar"))
  +     if (!xx || payload_format == NULL || !(
  +       !strcmp(payload_format, "tar") || !strcmp(payload_format, "ustar")
   #if defined(SUPPORT_AR_PAYLOADS)
  -      || !(!strcmp(payload_format, "ar"))
  +      || !strcmp(payload_format, "ar")
   #endif
  -        )
  +        ))
        {
            payload_format = _free(payload_format);
            payload_format = xstrdup("cpio");
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/ar.c
  ============================================================================
  $ cvs diff -u -r1.15 -r1.16 ar.c
  --- rpm/rpmio/ar.c    10 Mar 2008 21:18:07 -0000      1.15
  +++ rpm/rpmio/ar.c    11 Mar 2008 04:00:57 -0000      1.16
  @@ -3,6 +3,8 @@
    *  Handle ar(1) archives.
    */
   
  +#undef       JBJ_WRITEPAD
  +
   #include "system.h"
   
   #include <rpmio_internal.h>  /* XXX fdGetCpioPos writing AR_MAGIC */
  @@ -50,6 +52,10 @@
       return ret;
   }
   
  +/* Translate archive read/write ssize_t return for iosmStage(). */
  +#define      _IOSMRC(_rc)    \
  +     if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)
  +
   static ssize_t arRead(void * _iosm, void * buf, size_t count)
        /[EMAIL PROTECTED] fileSystem @*/
        /[EMAIL PROTECTED] _iosm, *buf, fileSystem @*/
  @@ -57,18 +63,20 @@
       IOSM_t iosm = _iosm;
       char * t = buf;
       size_t nb = 0;
  +    size_t rc;
   
   if (_ar_debug)
  -fprintf(stderr, "          arRead(%p, %p[%u])\n", iosm, buf, 
(unsigned)count);
  +fprintf(stderr, "\t  arRead(%p, %p[%u])\n", iosm, buf, (unsigned)count);
   
       while (count > 0) {
  -     size_t rc;
   
        /* Read next ar block. */
        iosm->wrlen = count;
        rc = _iosmNext(iosm, IOSM_DREAD);
  -     if (!rc && iosm->rdnb != iosm->wrlen)
  +     if (!rc && iosm->rdnb != iosm->wrlen) {
  +         if (iosm->rdnb == 0) return -IOSMERR_HDR_TRAILER;   /* EOF */
            rc = IOSMERR_READ_FAILED;
  +     }
        if (rc) return -rc;
   
        /* Append to buffer. */
  @@ -93,15 +101,23 @@
   
       /* XXX Read AR_MAGIC to beginning of ar(1) archive. */
       if (fdGetCpioPos(iosm->cfd) == 0) {
  -     (void) arRead(iosm, iosm->wrbuf, sizeof(AR_MAGIC)-1);
  +     rc = arRead(iosm, iosm->wrbuf, sizeof(AR_MAGIC)-1);
  +     _IOSMRC(rc);
  +
  +     /* Verify archive magic. */
  +     if (strncmp(iosm->wrbuf, AR_MAGIC, sizeof(AR_MAGIC)-1))
  +         return IOSMERR_BAD_MAGIC;
       }
   
   top:
  +    /* Make sure block aligned. */
  +    rc = _iosmNext(iosm, IOSM_POS);
  +    if (rc) return (int) rc;
  +
       rc = arRead(iosm, hdr, sizeof(*hdr));
  -    if (rc <= 0) return (int) -rc;
  +    _IOSMRC(rc);
   if (_ar_debug)
   fprintf(stderr, "==> %p[%u] \"%.*s\"\n", hdr, (unsigned)rc, 
(int)sizeof(*hdr)-2, (char *)hdr);
  -    rc = 0;
   
       /* Verify header marker. */
       if (strncmp(hdr->marker, AR_MARKER, sizeof(AR_MARKER)-1))
  @@ -117,7 +133,7 @@
            size_t i;
   
            rc = arRead(iosm, iosm->wrbuf, st->st_size);
  -         if (rc <= 0) return (int) -rc;
  +         _IOSMRC(rc);
   
            iosm->wrbuf[rc] = '\0';
            iosm->lmtab = t = xstrdup(iosm->wrbuf);
  @@ -136,7 +152,7 @@
        /* GNU: on "/": Skip symbol table. */
        if (hdr->name[1] == ' ') {
            rc = arRead(iosm, iosm->wrbuf, st->st_size);
  -         if (rc <= 0) return (int) -rc;
  +         _IOSMRC(rc);
            goto top;
        }
        /* GNU: on "/123": Read "123" offset to substitute long member name. */
  @@ -187,12 +203,12 @@
       IOSM_t iosm = _iosm;
       const char * s = buf;
       size_t nb = 0;
  +    size_t rc;
   
   if (_ar_debug)
  -fprintf(stderr, "    arWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
  +fprintf(stderr, "\tarWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
   
       while (count > 0) {
  -     size_t rc;
   
        /* XXX DWRITE uses rdnb for I/O length. */
        iosm->rdnb = count;
  @@ -207,6 +223,12 @@
        nb += iosm->rdnb;
        count -= iosm->rdnb;
       }
  +
  +#if defined(JBJ_WRITEPAD)
  +    /* Pad to next block boundary. */
  +    if ((rc = _iosmNext(iosm, IOSM_PAD)) != 0) return -rc;
  +#endif
  +
       return nb;
   }
   
  @@ -224,7 +246,7 @@
       if (fdGetCpioPos(iosm->cfd) == 0) {
        /* Write ar(1) magic. */
        rc = arWrite(iosm, AR_MAGIC, sizeof(AR_MAGIC)-1);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
        /* GNU: on "//":        Write long member name string table. */
        if (iosm->lmtab != NULL) {
            memset(hdr, (int) ' ', sizeof(*hdr));
  @@ -234,14 +256,15 @@
            strncpy(hdr->marker, AR_MARKER, sizeof(AR_MARKER)-1);
   
            rc = arWrite(iosm, hdr, sizeof(*hdr));
  -         if (rc < 0) return (int) -rc;
  +         _IOSMRC(rc);
            rc = arWrite(iosm, iosm->lmtab, iosm->lmtablen);
  -         if (rc < 0) return (int) -rc;
  +         _IOSMRC(rc);
  +#if !defined(JBJ_WRITEPAD)
            rc = _iosmNext(iosm, IOSM_PAD);
  -         if (rc)     return rc;
  +         if (rc) return rc;
  +#endif
        }
       }
  -    rc = 0;
   
       memset(hdr, (int)' ', sizeof(*hdr));
   
  @@ -276,7 +299,7 @@
   fprintf(stderr, "==> %p[%u] \"%.*s\"\n", hdr, (unsigned)rc, 
(int)sizeof(*hdr), (char *)hdr);
   
       rc = arWrite(iosm, hdr, sizeof(*hdr));
  -    if (rc < 0)      return (int) -rc;
  +    _IOSMRC(rc);
       rc = 0;
   
       return rc;
  @@ -285,12 +308,17 @@
   int arTrailerWrite(void * _iosm)
   {
       IOSM_t iosm = _iosm;
  -    int rc = 0;
  +    size_t rc = 0;
   
   if (_ar_debug)
   fprintf(stderr, "    arTrailerWrite(%p)\n", iosm);
   
  +#if defined(JBJ_WRITEPAD)
  +    rc = arWrite(iosm, NULL, 0);     /* XXX _iosmNext(iosm, IOSM_PAD) */
  +    _IOSMRC(rc);
  +#else
       rc = _iosmNext(iosm, IOSM_PAD);  /* XXX likely unnecessary. */
  +#endif
   
  -    return rc;
  +    return (int) rc;
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/cpio.c
  ============================================================================
  $ cvs diff -u -r1.8 -r1.9 cpio.c
  --- rpm/rpmio/cpio.c  10 Mar 2008 21:18:07 -0000      1.8
  +++ rpm/rpmio/cpio.c  11 Mar 2008 04:00:57 -0000      1.9
  @@ -2,6 +2,7 @@
    * \file rpmio/cpio.c
    *  Handle cpio(1) archives.
    */
  +#undef       JBJ_WRITEPAD
   
   #include "system.h"
   
  @@ -49,12 +50,9 @@
       return ret;
   }
   
  -#define GET_NUM_FIELD(phys, log) \
  -     log = strntoul(phys, &end, 16, sizeof(phys)); \
  -     if ( (end - phys) != sizeof(phys) ) return IOSMERR_BAD_HEADER;
  -#define SET_NUM_FIELD(phys, val, space) \
  -     sprintf(space, "%8.8lx", (unsigned long) (val)); \
  -     memcpy(phys, space, 8)
  +/* Translate archive read/write ssize_t return for iosmStage(). */
  +#define      _IOSMRC(_rc)    \
  +     if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)
   
   static ssize_t cpioRead(void * _iosm, void * buf, size_t count)
        /[EMAIL PROTECTED] fileSystem @*/
  @@ -63,12 +61,12 @@
       IOSM_t iosm = _iosm;
       char * t = buf;
       size_t nb = 0;
  +    size_t rc;
   
   if (_cpio_debug)
   fprintf(stderr, "          cpioRead(%p, %p[%u])\n", iosm, buf, 
(unsigned)count);
   
       while (count > 0) {
  -     size_t rc;
   
        /* Read next cpio block. */
        iosm->wrlen = count;
  @@ -87,6 +85,13 @@
       return nb;
   }
   
  +#define GET_NUM_FIELD(phys, log) \
  +     log = strntoul(phys, &end, 16, sizeof(phys)); \
  +     if ( (end - phys) != sizeof(phys) ) return IOSMERR_BAD_HEADER;
  +#define SET_NUM_FIELD(phys, val, space) \
  +     sprintf(space, "%8.8lx", (unsigned long) (val)); \
  +     memcpy(phys, space, 8)
  +
   int cpioHeaderRead(void * _iosm, struct stat * st)
   {
       IOSM_t iosm = _iosm;
  @@ -102,7 +107,7 @@
   
       /* Read next header. */
       rc = cpioRead(iosm, hdr, PHYS_HDR_SIZE);
  -    if (rc < 0) return (int) -rc;
  +    _IOSMRC(rc);
   
       /* Verify header magic. */
       if (strncmp(CPIO_CRC_MAGIC, hdr->magic, sizeof(CPIO_CRC_MAGIC)-1) &&
  @@ -140,24 +145,26 @@
        if (rc < 0) {
            t = _free(t);
            iosm->path = NULL;
  -         rc = IOSMERR_BAD_HEADER;
  -         return (int) rc;
        }
  +     _IOSMRC(rc);
        t[nb] = '\0';
        iosm->path = t;
       }
   
       /* Read link name. */
       if (S_ISLNK(st->st_mode)) {
  +
  +     /* Make sure block aligned. */
        rc = _iosmNext(iosm, IOSM_POS);
  -     if (rc) return (int) rc;
  +     if (rc) return (int) -rc;
  +
        nb = (size_t) st->st_size;
        rc = cpioRead(iosm, t, nb);
        if (rc < 0) {
            t = _free(t);
            iosm->lpath = NULL;
  -         return (int) -rc;
        }
  +     _IOSMRC(rc);
        t[nb] = '\0';
        iosm->lpath = t;
       }
  @@ -180,12 +187,12 @@
       IOSM_t iosm = _iosm;
       const char * s = buf;
       size_t nb = 0;
  +    size_t rc;
   
   if (_cpio_debug)
  -fprintf(stderr, "  cpioWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
  +fprintf(stderr, "\t  cpioWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
   
       while (count > 0) {
  -     size_t rc;
   
        /* XXX DWRITE uses rdnb for I/O length. */
        iosm->rdnb = count;
  @@ -200,6 +207,12 @@
        nb += iosm->rdnb;
        count -= iosm->rdnb;
       }
  +
  +#if defined(JBJ_WRITEPAD)
  +    /* Pad to next block boundary. */
  +    if ((rc = _iosmNext(iosm, IOSM_PAD)) != 0) return -rc;
  +#endif
  +
       return nb;
   }
   
  @@ -236,19 +249,23 @@
       memcpy(iosm->rdbuf + PHYS_HDR_SIZE, iosm->path, nb);
       nb += PHYS_HDR_SIZE;
       rc = cpioWrite(iosm, hdr, nb);
  -    if (rc < 0)      return (int) -rc;
  +    _IOSMRC(rc);
   
       if (S_ISLNK(st->st_mode)) {
   assert(iosm->lpath != NULL);
  +#if !defined(JBJ_WRITEPAD)
        rc = _iosmNext(iosm, IOSM_PAD);
        if (rc) return (int) rc;
  +#endif
   
        nb = strlen(iosm->lpath);
        rc = cpioWrite(iosm, iosm->lpath, nb);
  -     if (rc < 0)     return (int) -rc;
  +     _IOSMRC(rc);
       }
   
  +#if !defined(JBJ_WRITEPAD)
       rc = _iosmNext(iosm, IOSM_PAD);
  +#endif
   
       return (int) rc;
   }
  @@ -274,13 +291,16 @@
       nb += PHYS_HDR_SIZE;
   
       rc = cpioWrite(iosm, hdr, nb);
  -    if (rc < 0)      return (int) -rc;
  +    _IOSMRC(rc);
   
       /*
        * GNU cpio pads to 512 bytes here, but we don't. This may matter for
        * tape device(s) and/or concatenated cpio archives. <shrug>
        */
  +#if !defined(JBJ_WRITEPAD)
       rc = _iosmNext(iosm, IOSM_PAD);
  +#endif
  +    rc = 0;
   
       return (int) rc;
   }
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/iosm.c
  ============================================================================
  $ cvs diff -u -r1.19 -r1.20 iosm.c
  --- rpm/rpmio/iosm.c  10 Mar 2008 21:18:07 -0000      1.19
  +++ rpm/rpmio/iosm.c  11 Mar 2008 04:00:57 -0000      1.20
  @@ -682,6 +682,7 @@
   fprintf(stderr, "--> iosmSetup(%p, 0x%x, \"%s\", %p, %p, %p, %p, %p)\n", 
iosm, goal, afmt, (void *)_ts, _fi, cfd, archiveSize, failedFile);
   /[EMAIL PROTECTED] [EMAIL PROTECTED]/
   
  +    _iosmNext = &iosmNext;
       if (iosm->headerRead == NULL) {
        if (afmt != NULL && (!strcmp(afmt, "tar") || !strcmp(afmt, "ustar"))) {
   if (iosm->debug < 0)
  @@ -698,7 +699,8 @@
            iosm->headerWrite = &arHeaderWrite;
            iosm->trailerWrite = &arTrailerWrite;
            iosm->blksize = 2;
  -         (void) arSetup(iosm, fi);
  +         if (goal == IOSM_PKGBUILD || goal == IOSM_PKGERASE)
  +             (void) arSetup(iosm, fi);
        } else
        {
   if (iosm->debug < 0)
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmio/tar.c
  ============================================================================
  $ cvs diff -u -r1.9 -r1.10 tar.c
  --- rpm/rpmio/tar.c   10 Mar 2008 21:18:07 -0000      1.9
  +++ rpm/rpmio/tar.c   11 Mar 2008 04:00:57 -0000      1.10
  @@ -3,6 +3,8 @@
    *  Handle ustar archives.
    */
   
  +#undef JBJ_WRITEPAD
  +
   #include "system.h"
   
   #include <rpmio.h>
  @@ -52,6 +54,10 @@
       return ret;
   }
   
  +/* Translate archive read/write ssize_t return for iosmStage(). */
  +#define      _IOSMRC(_rc)    \
  +     if ((_rc) <= 0) return ((_rc) ? (int) -rc : IOSMERR_HDR_TRAILER)
  +
   static ssize_t tarRead(void * _iosm, void * buf, size_t count)
        /[EMAIL PROTECTED] fileSystem @*/
        /[EMAIL PROTECTED] _iosm, *buf, fileSystem @*/
  @@ -61,7 +67,7 @@
       size_t nb = 0;
   
   if (_tar_debug)
  -fprintf(stderr, "         tarRead(%p, %p[%u])\n", iosm, buf, 
(unsigned)count);
  +fprintf(stderr, "\ttarRead(%p, %p[%u])\n", iosm, buf, (unsigned)count);
   
       while (count > 0) {
        size_t rc;
  @@ -102,7 +108,7 @@
   
       if (rc > 0)              /* success */
        t[rc] = '\0';
  -     else            /* failure */
  +     else            /* failure or EOF */
        t = _free(t);
       if (fnp != NULL)
        *fnp = t;
  @@ -125,13 +131,13 @@
       int zblk = 0;
   
   if (_tar_debug)
  -fprintf(stderr, "    tarHeaderRead(%p, %p)\n", iosm, st);
  +fprintf(stderr, "  tarHeaderRead(%p, %p)\n", iosm, st);
   
   top:
       do {
        /* Read next header. */
        rc = tarRead(_iosm, hdr, TAR_BLOCK_SIZE);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
   
        /* Look for end-of-archive, i.e. 2 (or more) zero blocks. */
        if (hdr->name[0] == '\0' && hdr->checksum[0] == '\0') {
  @@ -218,12 +224,12 @@
   #endif
       case 'K':                /* GNU long (>100 chars) link name */
        rc = tarHeaderReadName(iosm, st->st_size, &iosm->lpath);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
        goto top;
        /[EMAIL PROTECTED]@*/ break;
       case 'L':                /* GNU long (>100 chars) file name */
        rc = tarHeaderReadName(iosm, st->st_size, &iosm->path);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
        goto top;
        /[EMAIL PROTECTED]@*/ break;
       }
  @@ -279,12 +285,12 @@
       IOSM_t iosm = _iosm;
       const char * s = buf;
       size_t nb = 0;
  +    size_t rc;
   
   if (_tar_debug)
  -fprintf(stderr, "   tarWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
  +fprintf(stderr, "\t   tarWrite(%p, %p[%u])\n", iosm, buf, (unsigned)count);
   
       while (count > 0) {
  -     size_t rc;
   
        /* XXX DWRITE uses rdnb for I/O length. */
        iosm->rdnb = count;
  @@ -299,6 +305,12 @@
        nb += iosm->rdnb;
        count -= iosm->rdnb;
       }
  +
  +#if defined(JBJ_WRITEPAD)
  +    /* Pad to next block boundary. */
  +    if ((rc = _iosmNext(iosm, IOSM_PAD)) != 0) return rc;
  +#endif
  +
       return nb;
   }
   
  @@ -314,10 +326,12 @@
   {
       ssize_t rc = tarWrite(_iosm, path, strlen(path));
   
  +#if !defined(JBJ_WRITEPAD)
       if (rc >= 0) {
        rc = _iosmNext(_iosm, IOSM_PAD);
        if (rc) rc = -rc;
       }
  +#endif
   
   if (_tar_debug)
   fprintf(stderr, "\ttarHeaderWriteName(%p, %s) rc 0x%x\n", _iosm, path, 
(unsigned)rc);
  @@ -395,9 +409,9 @@
        strncpy(hdr->uname, "root", sizeof(hdr->uname));
        strncpy(hdr->gname, "root", sizeof(hdr->gname));
        rc = tarHeaderWriteBlock(iosm, st, hdr);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
        rc = tarHeaderWriteName(iosm, iosm->path);
  -     if (rc < 0) return (int) -rc;
  +     _IOSMRC(rc);
       }
   
       if (iosm->lpath && iosm->lpath[0] != '0') {
  @@ -414,9 +428,9 @@
            strncpy(hdr->uname, "root", sizeof(hdr->uname));
            strncpy(hdr->gname, "root", sizeof(hdr->gname));
            rc = tarHeaderWriteBlock(iosm, st, hdr);
  -         if (rc < 0) return (int) -rc;
  +         _IOSMRC(rc);
            rc = tarHeaderWriteName(iosm, iosm->lpath);
  -         if (rc < 0) return (int) -rc;
  +         _IOSMRC(rc);
        }
       }
   
  @@ -467,10 +481,13 @@
       sprintf(hdr->devMinor, "%07o", (unsigned) (dev & 07777777));
   
       rc = tarHeaderWriteBlock(iosm, st, hdr);
  -    if (rc < 0) return (int) -rc;
  +    _IOSMRC(rc);
  +    rc = 0;
   
  +#if !defined(JBJ_WRITEPAD)
       /* XXX Padding is unnecessary but shouldn't hurt. */
       rc = _iosmNext(iosm, IOSM_PAD);
  +#endif
   
       return (int) rc;
   }
  @@ -478,15 +495,22 @@
   int tarTrailerWrite(void * _iosm)
   {
       IOSM_t iosm = _iosm;
  -    int rc = 0;
  +    ssize_t rc = 0;
   
   if (_tar_debug)
   fprintf(stderr, "    tarTrailerWrite(%p)\n", iosm);
   
       /* Pad up to 20 blocks (10Kb) of zeroes. */
       iosm->blksize *= 20;
  +#if defined(JBJ_WRITEPAD)
  +    rc = tarWrite(iosm, NULL, 0);    /* XXX _iosmNext(iosm, IOSM_PAD) */
  +#else
       rc = _iosmNext(iosm, IOSM_PAD);
  +#endif
       iosm->blksize /= 20;
  +#if defined(JBJ_WRITEPAD)
  +    _IOSMRC(rc);
  +#endif
   
  -    return rc;
  +    return (int) -rc;
   }
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                [email protected]

Reply via email to