NetBSD Problem Report #45065

From www@NetBSD.org  Wed Jun 15 13:29:08 2011
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [204.152.190.11])
	by www.NetBSD.org (Postfix) with ESMTP id 3BB3363C82A
	for <gnats-bugs@gnats.NetBSD.org>; Wed, 15 Jun 2011 13:29:08 +0000 (UTC)
Message-Id: <20110615132906.D212663B970@www.NetBSD.org>
Date: Wed, 15 Jun 2011 13:29:06 +0000 (UTC)
From: tcort@minix3.org
Reply-To: tcort@minix3.org
To: gnats-bugs@NetBSD.org
Subject: archivers/pax minix support
X-Send-Pr-Version: www-1.0

>Number:         45065
>Category:       pkg
>Synopsis:       archivers/pax minix support
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    joerg
>State:          open
>Class:          change-request
>Submitter-Id:   net
>Arrival-Date:   Wed Jun 15 13:30:00 +0000 2011
>Last-Modified:  Sun Nov 06 19:05:04 +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);

>Release-Note:

>Audit-Trail:
From: Thomas Cort <tcort@minix3.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45065: archivers/pax minix support
Date: Tue, 19 Jul 2011 07:46:46 -0400

 After submitting the original patch, Minix's struct stat was enhanced to
 include the st_blksize member. That eliminates the st_blksize changes from
 the original patch. An update patch follows.

 Patch Summary:

  * Rename TODEV, MAJOR, and MINOR to PAX_TODEV, PAX_MAJOR, and PAX_MINOR
    to avoid a conflict with existing Minix macros.

  * setrlimit() isn't implemented on Minix, so we bypass setrlimit() if
    __minix is defined.

  * Minix has smaller types, so we define MFTENT_DUMMY_DEV to be SHRT_MAX
    instead of UINT_MAX when __minix is defined.

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

Responsible-Changed-From-To: pkg-manager->joerg
Responsible-Changed-By: obache@NetBSD.org
Responsible-Changed-When: Wed, 12 Oct 2011 13:38:00 +0000
Responsible-Changed-Why:
Over to maintainer.


From: Thomas Cort <tcort@netbsd.org>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: pkg/45065: archivers/pax minix support
Date: Sat, 5 Nov 2011 20:42:40 -0400

 I've cleaned up the patch a little by using the feature macros defined by
 autotools (HAVE_SETRLIMIT and HAVE_GETRLIMIT) instead of "__minix". The new
 patch follows...



  Patch Summary:


   * Rename TODEV, MAJOR, and MINOR to PAX_TODEV, PAX_MAJOR, and PAX_MINOR
     to avoid a conflict with existing Minix macros.


   * setrlimit() isn't implemented on Minix, so bypass the getrlimit() /
     setrlimit() pairs if either function is missing.


   * Minix has smaller types, so define MFTENT_DUMMY_DEV to be SHRT_MAX
     instead of UINT_MAX when __minix is defined.




 Index: files/cpio.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/cpio.c,v
 retrieving revision 1.6
 diff -u -p -r1.6 cpio.c
 --- files/cpio.c	8 Mar 2007 17:18:18 -0000	1.6
 +++ files/cpio.c	6 Nov 2011 00:34:47 -0000
 @@ -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;
 Index: files/ftree.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/ftree.c,v
 retrieving revision 1.12
 diff -u -p -r1.12 ftree.c
 --- files/ftree.c	29 Apr 2008 05:46:09 -0000	1.12
 +++ files/ftree.c	6 Nov 2011 00:34:47 -0000
 @@ -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
 Index: files/gen_subs.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/gen_subs.c,v
 retrieving revision 1.8
 diff -u -p -r1.8 gen_subs.c
 --- files/gen_subs.c	8 Mar 2007 17:18:18 -0000	1.8
 +++ files/gen_subs.c	6 Nov 2011 00:34:47 -0000
 @@ -167,8 +167,8 @@ ls_list(ARCHD *arcn, time_t now, FILE *f
  	 * 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);
  	}
 Index: files/pack_dev.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/pack_dev.c,v
 retrieving revision 1.4
 diff -u -p -r1.4 pack_dev.c
 --- files/pack_dev.c	29 Apr 2008 05:46:09 -0000	1.4
 +++ files/pack_dev.c	6 Nov 2011 00:34:47 -0000
 @@ -90,7 +90,7 @@ pack_native(int n, u_long numbers[], con
  	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])
 Index: files/pax.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/pax.c,v
 retrieving revision 1.9
 diff -u -p -r1.9 pax.c
 --- files/pax.c	8 Mar 2007 17:18:18 -0000	1.9
 +++ files/pax.c	6 Nov 2011 00:34:47 -0000
 @@ -405,6 +405,7 @@ gen_init(void)
  	struct sigaction n_hand;
  	struct sigaction o_hand;

 +#if defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT)
  	/*
  	 * 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 /* defined(HAVE_GETRLIMIT) && defined(HAVE_SETRLIMIT) */
  	/*
  	 * Handle posix locale
  	 *
 Index: files/pax.h
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/pax.h,v
 retrieving revision 1.12
 diff -u -p -r1.12 pax.h
 --- files/pax.h	30 Jan 2010 08:46:20 -0000	1.12
 +++ files/pax.h	6 Nov 2011 00:34:47 -0000
 @@ -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

 Index: files/tar.c
 ===================================================================
 RCS file: /cvsroot/pkgsrc/archivers/pax/files/tar.c,v
 retrieving revision 1.11
 diff -u -p -r1.11 tar.c
 --- files/tar.c	8 Mar 2007 17:18:18 -0000	1.11
 +++ files/tar.c	6 Nov 2011 00:34:47 -0000
 @@ -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);

From: Joerg Sonnenberger <joerg@britannica.bec.de>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: pkg/45065: archivers/pax minix support
Date: Sun, 6 Nov 2011 20:02:58 +0100

 On Sun, Nov 06, 2011 at 12:45:01AM +0000, Thomas Cort wrote:
 >    * Rename TODEV, MAJOR, and MINOR to PAX_TODEV, PAX_MAJOR, and PAX_MINOR
 >      to avoid a conflict with existing Minix macros.

 OK

 >    * setrlimit() isn't implemented on Minix, so bypass the getrlimit() /
 >      setrlimit() pairs if either function is missing.

 I think it is better to implement fall backs in libnbcompat for this.

 >    * Minix has smaller types, so define MFTENT_DUMMY_DEV to be SHRT_MAX
 >      instead of UINT_MAX when __minix is defined.

 Why is this needed?

 Joerg

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.