CVS commit: src/bin/pax

2023-07-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Jul 20 20:10:59 UTC 2023

Modified Files:
src/bin/pax: ar_io.c

Log Message:
pax: fix -Wformat for host tool


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/bin/pax/ar_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/ar_io.c
diff -u src/bin/pax/ar_io.c:1.59 src/bin/pax/ar_io.c:1.60
--- src/bin/pax/ar_io.c:1.59	Mon Feb  4 04:36:41 2019
+++ src/bin/pax/ar_io.c	Thu Jul 20 20:10:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ar_io.c,v 1.59 2019/02/04 04:36:41 mrg Exp $	*/
+/*	$NetBSD: ar_io.c,v 1.60 2023/07/20 20:10:59 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_io.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_io.c,v 1.59 2019/02/04 04:36:41 mrg Exp $");
+__RCSID("$NetBSD: ar_io.c,v 1.60 2023/07/20 20:10:59 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -457,7 +457,7 @@ ar_close(void)
 	/* mimic cpio's block count first */
 	if (frmt && strcmp(NM_CPIO, argv0) == 0) {
 		(void)fprintf(listf, OFFT_F " blocks\n",
-		(rdcnt ? rdcnt : wrcnt) / 5120);
+		(OFFT_T)((rdcnt ? rdcnt : wrcnt) / 5120));
 	}
 
 	ar_summary(0);



CVS commit: src/bin/pax

2023-07-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Jul 20 20:10:59 UTC 2023

Modified Files:
src/bin/pax: ar_io.c

Log Message:
pax: fix -Wformat for host tool


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/bin/pax/ar_io.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/pax

2023-07-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Jul 20 20:09:49 UTC 2023

Modified Files:
src/bin/pax: options.c

Log Message:
pax: need  for ffs()

Fixes warning as host tool on NetBSD 9.99


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/bin/pax/options.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/options.c
diff -u src/bin/pax/options.c:1.119 src/bin/pax/options.c:1.120
--- src/bin/pax/options.c:1.119	Fri Apr  3 16:13:32 2020
+++ src/bin/pax/options.c	Thu Jul 20 20:09:49 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $	*/
+/*	$NetBSD: options.c,v 1.120 2023/07/20 20:09:49 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)options.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: options.c,v 1.119 2020/04/03 16:13:32 joerg Exp $");
+__RCSID("$NetBSD: options.c,v 1.120 2023/07/20 20:09:49 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -61,6 +61,7 @@ __RCSID("$NetBSD: options.c,v 1.119 2020
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 



CVS commit: src/bin/pax

2023-07-20 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Thu Jul 20 20:09:49 UTC 2023

Modified Files:
src/bin/pax: options.c

Log Message:
pax: need  for ffs()

Fixes warning as host tool on NetBSD 9.99


To generate a diff of this commit:
cvs rdiff -u -r1.119 -r1.120 src/bin/pax/options.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/pax

2023-05-28 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun May 28 21:42:40 UTC 2023

Modified Files:
src/bin/pax: ar_subs.c buf_subs.c extern.h file_subs.c

Log Message:
pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.
The partial temporary file is removed.  pax still exists non-zero.

Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.

Should fix PR misc/33753.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/bin/pax/ar_subs.c
cvs rdiff -u -r1.30 -r1.31 src/bin/pax/buf_subs.c
cvs rdiff -u -r1.60 -r1.61 src/bin/pax/extern.h
cvs rdiff -u -r1.64 -r1.65 src/bin/pax/file_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/ar_subs.c
diff -u src/bin/pax/ar_subs.c:1.57 src/bin/pax/ar_subs.c:1.58
--- src/bin/pax/ar_subs.c:1.57	Sun Dec  5 02:52:17 2021
+++ src/bin/pax/ar_subs.c	Sun May 28 21:42:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ar_subs.c,v 1.57 2021/12/05 02:52:17 msaitoh Exp $	*/
+/*	$NetBSD: ar_subs.c,v 1.58 2023/05/28 21:42:40 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)ar_subs.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ar_subs.c,v 1.57 2021/12/05 02:52:17 msaitoh Exp $");
+__RCSID("$NetBSD: ar_subs.c,v 1.58 2023/05/28 21:42:40 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -1131,10 +1131,14 @@ copy(void)
 		}
 
 		/*
-		 * copy source file data to the destination file
+		 * copy source file data to the destination file.
+		 * if there was a failure, remove the temporary file
+		 * and leave any existing destination file unmodified.
 		 */
-		cp_file(arcn, fdsrc, fddest);
-		file_close(arcn, fddest);
+		if (cp_file(arcn, fdsrc, fddest) < 0)
+			file_cleanup(arcn, fddest);
+		else
+			file_close(arcn, fddest);
 		rdfile_close(arcn, );
 
 		if (vflag && vfpart) {

Index: src/bin/pax/buf_subs.c
diff -u src/bin/pax/buf_subs.c:1.30 src/bin/pax/buf_subs.c:1.31
--- src/bin/pax/buf_subs.c:1.30	Sat May 28 10:36:21 2022
+++ src/bin/pax/buf_subs.c	Sun May 28 21:42:40 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: buf_subs.c,v 1.30 2022/05/28 10:36:21 andvar Exp $	*/
+/*	$NetBSD: buf_subs.c,v 1.31 2023/05/28 21:42:40 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -42,7 +42,7 @@
 #if 0
 static char sccsid[] = "@(#)buf_subs.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: buf_subs.c,v 1.30 2022/05/28 10:36:21 andvar Exp $");
+__RCSID("$NetBSD: buf_subs.c,v 1.31 2023/05/28 21:42:40 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -745,8 +745,11 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *l
 	 * written. just closing with the file offset moved forward may not put
 	 * a hole at the end of the file.
 	 */
-	if (ofd >= 0 && isem && (arcn->sb.st_size > 0L))
-		file_flush(ofd, fnm, isem);
+	if (ofd >= 0 && isem && (arcn->sb.st_size > 0L)) {
+		if (file_flush(ofd, fnm, isem) < 0) {
+			/* write flush errors are not an error here */;
+		}
+	}
 
 	/*
 	 * if we failed from archive read, we do not want to skip
@@ -758,9 +761,11 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *l
 	 * some formats record a crc on file data. If so, then we compare the
 	 * calculated crc to the crc stored in the archive
 	 */
-	if (docrc && (size == 0L) && (arcn->crc != crc))
+	if (docrc && (size == 0L) && (arcn->crc != crc)) {
 		tty_warn(1,"Actual crc does not match expected crc %s",
 		arcn->name);
+		/* crc warning is not an error */
+	}
 	return 0;
 }
 
@@ -769,9 +774,11 @@ rd_wrfile(ARCHD *arcn, int ofd, off_t *l
  *	copy the contents of one file to another. used during -rw phase of pax
  *	just as in rd_wrfile() we use a special write function to write the
  *	destination file so we can properly copy files with holes.
+ * Return:
+ *	0 if ok, -1 if any error.
  */
 
-void
+int
 cp_file(ARCHD *arcn, int fd1, int fd2)
 {
 	int cnt;
@@ -783,6 +790,7 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
 	int rem;
 	int sz = MINFBSZ;
 	struct stat sb, origsb;
+	int rv = 0;
 
 	/*
 	 * check for holes in the source file. If none, we will use regular
@@ -797,8 +805,10 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
 	 * if Mflag is set, use the actual mtime instead.
 	 */
 	origsb = arcn->sb;
-	if (Mflag && (fstat(fd1, ) < 0))
+	if (Mflag && (fstat(fd1, ) < 0)) {
 		syswarn(1, errno, "Failed stat on %s", arcn->org_name);
+		rv = -1;
+	}
 
 	/*
 	 * pass the blocksize of the file being written to the write routine,
@@ -830,17 +840,22 @@ cp_file(ARCHD *arcn, int fd1, int fd2)
 	/*
 	 * check to make sure the copy is valid.
 	 */
-	if (res < 0)
+	if (res < 0) {
 		syswarn(1, errno, "Failed write during copy of %s to %s",
 			arcn->org_name, arcn->name);
-	else if (cpcnt != 

CVS commit: src/bin/pax

2023-05-28 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun May 28 21:42:40 UTC 2023

Modified Files:
src/bin/pax: ar_subs.c buf_subs.c extern.h file_subs.c

Log Message:
pax: don't overwrite destination if -r -w copy fails

Add more error handling to pax -r -w so that any failure
during the copy to the temporary file (including a failed flush)
prevents any existing destination file from being replaced
with the partial (including possibly empty) temporary file.
The partial temporary file is removed.  pax still exists non-zero.

Thanks to Michael van Elst (mlelstv@) for the analysis
of the problem in the PR.

Should fix PR misc/33753.


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/bin/pax/ar_subs.c
cvs rdiff -u -r1.30 -r1.31 src/bin/pax/buf_subs.c
cvs rdiff -u -r1.60 -r1.61 src/bin/pax/extern.h
cvs rdiff -u -r1.64 -r1.65 src/bin/pax/file_subs.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/pax

2023-05-28 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun May 28 17:01:46 UTC 2023

Modified Files:
src/bin/pax: ftree.c

Log Message:
pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/pax/ftree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/ftree.c
diff -u src/bin/pax/ftree.c:1.42 src/bin/pax/ftree.c:1.43
--- src/bin/pax/ftree.c:1.42	Thu Sep 27 00:44:59 2012
+++ src/bin/pax/ftree.c	Sun May 28 17:01:46 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: ftree.c,v 1.42 2012/09/27 00:44:59 christos Exp $	*/
+/*	$NetBSD: ftree.c,v 1.43 2023/05/28 17:01:46 lukem Exp $	*/
 
 /*-
  * Copyright (c) 1992 Keith Muller.
@@ -71,7 +71,7 @@
 #if 0
 static char sccsid[] = "@(#)ftree.c	8.2 (Berkeley) 4/18/94";
 #else
-__RCSID("$NetBSD: ftree.c,v 1.42 2012/09/27 00:44:59 christos Exp $");
+__RCSID("$NetBSD: ftree.c,v 1.43 2023/05/28 17:01:46 lukem Exp $");
 #endif
 #endif /* not lint */
 
@@ -194,7 +194,7 @@ ftree_start(void)
 	}
 
 	if (ftree_arg() < 0)
-		return -1;
+		return 0;
 	if (tflag && (atdir_start() < 0))
 		return -1;
 	return 0;



CVS commit: src/bin/pax

2023-05-28 Thread Luke Mewburn
Module Name:src
Committed By:   lukem
Date:   Sun May 28 17:01:46 UTC 2023

Modified Files:
src/bin/pax: ftree.c

Log Message:
pax: exit 0 if stdin filelist is used and empty

If copying a list of files from stdin, exit zero instead of non-zero
if there are no files supplied.

AFAICT, POSIX doesn't require a non-zero an error in this situation,
since there are no files to not match.

Fix from PR bin/41736 by Lloyd Parkes.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 src/bin/pax/ftree.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/pax

2021-11-05 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Nov  6 01:19:19 UTC 2021

Modified Files:
src/bin/pax: pax.1

Log Message:
pax.1: minor grammar fixes


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/bin/pax/pax.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/pax.1
diff -u src/bin/pax/pax.1:1.71 src/bin/pax/pax.1:1.72
--- src/bin/pax/pax.1:1.71	Tue Mar 19 00:36:14 2019
+++ src/bin/pax/pax.1	Sat Nov  6 01:19:19 2021
@@ -1,4 +1,4 @@
-.\"$NetBSD: pax.1,v 1.71 2019/03/19 00:36:14 gutteridge Exp $
+.\"$NetBSD: pax.1,v 1.72 2021/11/06 01:19:19 gutteridge Exp $
 .\"
 .\" Copyright (c) 1992 Keith Muller.
 .\" Copyright (c) 1992, 1993
@@ -489,7 +489,7 @@ Multiple characteristics can be concaten
 and multiple
 .Fl p
 options can be specified.
-The meaning of the specification characters are as follows:
+The meanings of the specification characters are as follows:
 .Bl -tag -width 2n
 .It Cm a
 Do not preserve file access times.
@@ -571,7 +571,7 @@ operands according to the substitution e
 using the syntax of the
 .Xr ed 1
 utility regular expressions.
-The format of these regular expressions are:
+The format of these regular expressions is:
 .Dl /old/new/[gps]
 As in
 .Xr ed 1 ,



CVS commit: src/bin/pax

2021-11-05 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Sat Nov  6 01:19:19 UTC 2021

Modified Files:
src/bin/pax: pax.1

Log Message:
pax.1: minor grammar fixes


To generate a diff of this commit:
cvs rdiff -u -r1.71 -r1.72 src/bin/pax/pax.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.



CVS commit: src/bin/pax

2019-08-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Aug 15 21:05:16 UTC 2019

Modified Files:
src/bin/pax: Makefile

Log Message:
Install manual pages for tar and cpio only if ${MKBSDTAR} == "no"
PR bin/54468


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/bin/pax/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/pax/Makefile
diff -u src/bin/pax/Makefile:1.39 src/bin/pax/Makefile:1.40
--- src/bin/pax/Makefile:1.39	Fri Apr 23 19:41:02 2010
+++ src/bin/pax/Makefile	Thu Aug 15 21:05:16 2019
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.39 2010/04/23 19:41:02 joerg Exp $
+#	$NetBSD: Makefile,v 1.40 2019/08/15 21:05:16 uwe Exp $
 #   @(#)Makefile	8.1 (Berkeley) 5/31/93
 
 .include 
@@ -23,7 +23,7 @@ LDADD+= -lutil
 .endif
 .endif
 
-MAN=	pax.1 tar.1 cpio.1
+MAN=	pax.1
 
 .if defined(HOSTPROG)
 CPPFLAGS+=	-DHOSTPROG
@@ -35,9 +35,11 @@ CPPFLAGS+=	-DHAVE_SYS_MTIO_H
 .if ${MKBSDTAR} == "no"
 LINKS+=	${BINDIR}/pax ${BINDIR}/tar
 SYMLINKS+=${BINDIR}/tar /usr/bin/tar
+MAN+=tar.1
 
 LINKS+=	${BINDIR}/pax ${BINDIR}/cpio
 SYMLINKS+=${BINDIR}/cpio /usr/bin/cpio
+MAN+=cpio.1
 .endif
 .endif	# }	! HOSTPROG
 



CVS commit: src/bin/pax

2019-08-15 Thread Valeriy E. Ushakov
Module Name:src
Committed By:   uwe
Date:   Thu Aug 15 21:05:16 UTC 2019

Modified Files:
src/bin/pax: Makefile

Log Message:
Install manual pages for tar and cpio only if ${MKBSDTAR} == "no"
PR bin/54468


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/bin/pax/Makefile

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.