pkgsrc-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

pkg/45065: archivers/pax minix support



>Number:         45065
>Category:       pkg
>Synopsis:       archivers/pax minix support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    pkg-manager
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 15 13:30:00 +0000 2011
>Originator:     Thomas Cort
>Release:        N/A
>Organization:
Minix3
>Environment:
Minix 192.168.122.210 3.2.0 i686
>Description:
pax does not compile on Minix because Minix lacks struct stat.st_blksize and 
setrlimit(). Additionally, Minix has definitions that are incompatible with 
some pre-processor macros pax defines.

After applying the patch below you need to run autoconf and autoheader.
>How-To-Repeat:
Attempt to compile pax on Minix...

cd /usr/pkgsrc/archivers/pax && bmake
>Fix:
diff --git a/archivers/pax/files/ar_io.c b/archivers/pax/files/ar_io.c
index e1b59c9..2e5e321 100644
--- a/archivers/pax/files/ar_io.c
+++ b/archivers/pax/files/ar_io.c
@@ -347,11 +347,16 @@ ar_open(const char *name)
                        break;
                }
 
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
                if ((arsb.st_blksize > 0) && (arsb.st_blksize < MAXBLK) &&
                    ((arsb.st_blksize % BLKMULT) == 0))
                        rdblksz = arsb.st_blksize;
                else
                        rdblksz = DEVBLK;
+#else
+               rdblksz = DEVBLK;
+#endif
+
                /*
                 * For performance go for large reads when we can without harm
                 */
@@ -1063,8 +1068,13 @@ ar_rdsync(void)
                 * try to step over the bad part of the device.
                 */
                io_ok = 0;
-               if (((fsbz = arsb.st_blksize) <= 0) || (artyp != ISREG))
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
+               if (((fsbz = arsb.st_blksize) <= 0) || (artyp != ISREG))        
                        fsbz = BLKMULT;
+#else
+               fsbz = BLKMULT;
+#endif
+
                if ((cpos = lseek(arfd, (off_t)0L, SEEK_CUR)) < 0)
                        break;
                mpos = fsbz - (cpos % (off_t)fsbz);
diff --git a/archivers/pax/files/buf_subs.c b/archivers/pax/files/buf_subs.c
index c0590d7..8099230 100644
--- a/archivers/pax/files/buf_subs.c
+++ b/archivers/pax/files/buf_subs.c
@@ -725,8 +725,10 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *left)
        if (ofd < 0)
                sz = PAXPATHLEN+1;
        else if (fstat(ofd, &sb) == 0) {
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
                if (sb.st_blksize > 0)
                        sz = (int)sb.st_blksize;
+#endif
        } else
                syswarn(0, errno,
                    "Unable to obtain block size for file %s", fnm);
@@ -814,8 +816,12 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
         * check for holes in the source file. If none, we will use regular
         * write instead of file write.
         */
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
         if (((off_t)(arcn->sb.st_blocks * BLKMULT)) >= arcn->sb.st_size)
-               ++no_hole;
+                ++no_hole;
+#else
+       ++no_hole;
+#endif
 
        /*
         * by default, remember the previously obtained stat information
@@ -831,8 +837,10 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
         * if the size is zero, use the default MINFBSZ
         */
        if (fstat(fd2, &sb) == 0) {
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
                if (sb.st_blksize > 0)
                        sz = sb.st_blksize;
+#endif
        } else
                syswarn(0, errno,
                    "Unable to obtain block size for file %s", fnm);
diff --git a/archivers/pax/files/configure.ac b/archivers/pax/files/configure.ac
index 5d40780..70c264e 100644
--- a/archivers/pax/files/configure.ac
+++ b/archivers/pax/files/configure.ac
@@ -22,6 +22,7 @@ AC_CHECK_HEADERS([sys/cdefs.h sys/ioctl.h sys/mman.h 
sys/mtio.h sys/param.h \
        sys/resource.h sys/stat.h sys/tape.h sys/time.h sys/types.h sys/uio.h \
        sys/wait.h])
 AC_CHECK_MEMBERS([struct stat.st_flags],,, [#include <sys/stat.h>])
+AC_CHECK_MEMBERS([struct stat.st_blksize], [:], [:], [ #include <sys/stat.h> ])
 AC_CHECK_DECLS([UF_SETTABLE, SF_SETTABLE])
 AH_BOTTOM([/* Define to 1 if the user- and root-changeable masks were detected 
*/
 #if HAVE_STRUCT_STAT_ST_FLAGS && HAVE_DECL_UF_SETTABLE && HAVE_DECL_SF_SETTABLE
diff --git a/archivers/pax/files/cpio.c b/archivers/pax/files/cpio.c
index 57f3281..d47b0cb 100644
--- a/archivers/pax/files/cpio.c
+++ b/archivers/pax/files/cpio.c
@@ -614,10 +614,10 @@ vcpio_rd(ARCHD *arcn, char *buf)
            HEX);
        devmajor = (dev_t)asc_ul(hd->c_maj, sizeof(hd->c_maj), HEX);
        devminor = (dev_t)asc_ul(hd->c_min, sizeof(hd->c_min), HEX);
-       arcn->sb.st_dev = TODEV(devmajor, devminor);
+       arcn->sb.st_dev = PAX_TODEV(devmajor, devminor);
        devmajor = (dev_t)asc_ul(hd->c_rmaj, sizeof(hd->c_maj), HEX);
        devminor = (dev_t)asc_ul(hd->c_rmin, sizeof(hd->c_min), HEX);
-       arcn->sb.st_rdev = TODEV(devmajor, devminor);
+       arcn->sb.st_rdev = PAX_TODEV(devmajor, devminor);
        arcn->crc = asc_ul(hd->c_chksum, sizeof(hd->c_chksum), HEX);
 
        /*
@@ -787,13 +787,13 @@ vcpio_wr(ARCHD *arcn)
                HEX) ||
            ul_asc((u_long)arcn->sb.st_nlink, hd->c_nlink, sizeof(hd->c_nlink),
                HEX) ||
-           ul_asc((u_long)MAJOR(arcn->sb.st_dev),hd->c_maj, sizeof(hd->c_maj),
+           ul_asc((u_long)PAX_MAJOR(arcn->sb.st_dev),hd->c_maj, 
sizeof(hd->c_maj),
                HEX) ||
-           ul_asc((u_long)MINOR(arcn->sb.st_dev),hd->c_min, sizeof(hd->c_min),
+           ul_asc((u_long)PAX_MINOR(arcn->sb.st_dev),hd->c_min, 
sizeof(hd->c_min),
                HEX) ||
-           ul_asc((u_long)MAJOR(arcn->sb.st_rdev),hd->c_rmaj,sizeof(hd->c_maj),
+           
ul_asc((u_long)PAX_MAJOR(arcn->sb.st_rdev),hd->c_rmaj,sizeof(hd->c_maj),
                HEX) ||
-           ul_asc((u_long)MINOR(arcn->sb.st_rdev),hd->c_rmin,sizeof(hd->c_min),
+           
ul_asc((u_long)PAX_MINOR(arcn->sb.st_rdev),hd->c_rmin,sizeof(hd->c_min),
                HEX) ||
            ul_asc((u_long)nsz, hd->c_namesize, sizeof(hd->c_namesize), HEX))
                goto out;
diff --git a/archivers/pax/files/file_subs.c b/archivers/pax/files/file_subs.c
index b12a613..1d012c9 100644
--- a/archivers/pax/files/file_subs.c
+++ b/archivers/pax/files/file_subs.c
@@ -1141,8 +1141,12 @@ set_crc(ARCHD *arcn, int fd)
                return 0;
        }
 
+#ifdef HAVE_STRUCT_STAT_ST_BLKSIZE
        if ((size = (u_long)arcn->sb.st_blksize) > (u_long)sizeof(tbuf))
                size = (u_long)sizeof(tbuf);
+#else
+       size = (u_long)sizeof(tbuf);
+#endif
 
        /*
         * read all the bytes we think that there are in the file. If the user
diff --git a/archivers/pax/files/ftree.c b/archivers/pax/files/ftree.c
index cbe221e..0ef9c77 100644
--- a/archivers/pax/files/ftree.c
+++ b/archivers/pax/files/ftree.c
@@ -451,7 +451,11 @@ next_file(ARCHD *arcn)
        int             cnt;
        time_t          atime, mtime;
        char            *curlink;
+#ifndef __minix
 #define MFTENT_DUMMY_DEV       UINT_MAX
+#else
+#define MFTENT_DUMMY_DEV SHRT_MAX
+#endif
 
        curlink = NULL;
 #ifndef SMALL
diff --git a/archivers/pax/files/gen_subs.c b/archivers/pax/files/gen_subs.c
index 8dd1a77..db8e3ea 100644
--- a/archivers/pax/files/gen_subs.c
+++ b/archivers/pax/files/gen_subs.c
@@ -167,8 +167,8 @@ ls_list(ARCHD *arcn, time_t now, FILE *fp)
         * print device id's for devices, or sizes for other nodes
         */
        if ((arcn->type == PAX_CHR) || (arcn->type == PAX_BLK))
-               (void)fprintf(fp, "%4lu,%4lu ", (long) MAJOR(sbp->st_rdev),
-                   (long) MINOR(sbp->st_rdev));
+               (void)fprintf(fp, "%4lu,%4lu ", (long) PAX_MAJOR(sbp->st_rdev),
+                   (long) PAX_MINOR(sbp->st_rdev));
        else {
                (void)fprintf(fp, OFFT_FP("9") " ", (OFFT_T)sbp->st_size);
        }
diff --git a/archivers/pax/files/pack_dev.c b/archivers/pax/files/pack_dev.c
index 7b74724..b2b96b2 100644
--- a/archivers/pax/files/pack_dev.c
+++ b/archivers/pax/files/pack_dev.c
@@ -90,7 +90,7 @@ pack_native(int n, u_long numbers[], const char **error)
        portdev_t dev = 0;
 
        if (n == 2) {
-               dev = TODEV(numbers[0], numbers[1]);
+               dev = PAX_TODEV(numbers[0], numbers[1]);
                if (major(dev) != numbers[0])
                        *error = iMajorError;
                else if (minor(dev) != numbers[1])
diff --git a/archivers/pax/files/pax.c b/archivers/pax/files/pax.c
index 93ce072..263cf97 100644
--- a/archivers/pax/files/pax.c
+++ b/archivers/pax/files/pax.c
@@ -405,6 +405,7 @@ gen_init(void)
        struct sigaction n_hand;
        struct sigaction o_hand;
 
+#ifndef __minix
        /*
         * Really needed to handle large archives. We can run out of memory for
         * internal tables really fast when we have a whole lot of files...
@@ -440,7 +441,7 @@ gen_init(void)
                (void)setrlimit(RLIMIT_RSS , &reslimit);
        }
 #endif
-
+#endif /* __minix */
        /*
         * Handle posix locale
         *
diff --git a/archivers/pax/files/pax.h b/archivers/pax/files/pax.h
index 8e8faa1..affb57e 100644
--- a/archivers/pax/files/pax.h
+++ b/archivers/pax/files/pax.h
@@ -247,22 +247,22 @@ typedef struct oplist {
 
 #ifdef HOSTPROG
 # include "pack_dev.h"                 /* explicitly use NetBSD's macros */
-# define MAJOR(x)      major_netbsd(x)
-# define MINOR(x)      minor_netbsd(x)
-# define TODEV(x, y)   makedev_netbsd((x), (y))
+# define PAX_MAJOR(x)  major_netbsd(x)
+# define PAX_MINOR(x)  minor_netbsd(x)
+# define PAX_TODEV(x, y)       makedev_netbsd((x), (y))
 #else
 # ifdef __HAIKU__
 #  define major(x)             ((int)(0x00ff & ((x) >> 8)))
 #  define minor(x)             ((int)(0xffff00ff & (x)))
 #  define makedev(maj,min)     ((0xff00 & ((maj)<<8))|(0xffff00ff & (min)))
 # endif
-# define MAJOR(x)      major(x)
-# define MINOR(x)      minor(x)
+# define PAX_MAJOR(x)  major(x)
+# define PAX_MINOR(x)  minor(x)
 # ifdef __QNXNTO__
 # include <sys/netmgr.h>
-#  define TODEV(x, y)  makedev(ND_LOCAL_NODE, (x), (y))
+#  define PAX_TODEV(x, y)      makedev(ND_LOCAL_NODE, (x), (y))
 # else
-#  define TODEV(x, y)  makedev((x), (y))
+#  define PAX_TODEV(x, y)      makedev((x), (y))
 # endif
 #endif
 
diff --git a/archivers/pax/files/tar.c b/archivers/pax/files/tar.c
index ebfece1..39c93cb 100644
--- a/archivers/pax/files/tar.c
+++ b/archivers/pax/files/tar.c
@@ -941,7 +941,7 @@ ustar_rd(ARCHD *arcn, char *buf)
                }
                devmajor = (dev_t)asc_ul(hd->devmajor,sizeof(hd->devmajor),OCT);
                devminor = (dev_t)asc_ul(hd->devminor,sizeof(hd->devminor),OCT);
-               arcn->sb.st_rdev = TODEV(devmajor, devminor);
+               arcn->sb.st_rdev = PAX_TODEV(devmajor, devminor);
                break;
        case SYMTYPE:
        case LNKTYPE:
@@ -1155,9 +1155,9 @@ ustar_wr(ARCHD *arcn)
                        hd->typeflag = CHRTYPE;
                else
                        hd->typeflag = BLKTYPE;
-               if (ul_oct((u_long)MAJOR(arcn->sb.st_rdev), hd->devmajor,
+               if (ul_oct((u_long)PAX_MAJOR(arcn->sb.st_rdev), hd->devmajor,
                   sizeof(hd->devmajor), 3) ||
-                  ul_oct((u_long)MINOR(arcn->sb.st_rdev), hd->devminor,
+                  ul_oct((u_long)PAX_MINOR(arcn->sb.st_rdev), hd->devminor,
                   sizeof(hd->devminor), 3) ||
                   ul_oct((u_long)0L, hd->size, sizeof(hd->size), 3))
                        return size_err("DEVTYPE", arcn);



Home | Main Index | Thread Index | Old Index