git: 81004ee18aa4 - stable/14 - install: drop obsolete file size limit for -C

Dag-Erling Smørgrav <[email protected]>
Newsgroups gmane.os.freebsd.devel.cvs.src
Message-ID <6a68779e.1d504.3da7d141__39057.3242957302$1785231335$gmane$org@gitrepo.freebsd.org>
The branch stable/14 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=81004ee18aa4a2fa31b9834f9e80a9fe7cf10b95

commit 81004ee18aa4a2fa31b9834f9e80a9fe7cf10b95
Author:     Aleksandr Rybalko <[email protected]>
AuthorDate: 2026-06-08 14:32:05 +0000
Commit:     Dag-Erling Smørgrav <[email protected]>
CommitDate: 2026-07-28 09:31:16 +0000

    install: drop obsolete file size limit for -C
    
    Removes the file size limit for -C comparisons. The limit was
    meant to prevent oversized mmap allocations, which is no longer
    relevant as mmap is no longer used here (removed by
    a0439a1b820fa0e742c00d095f5f5c06f5f19432, review D44809).
    Credit to bdrewery.
    See: https://reviews.freebsd.org/D57230
    
    Reviewed by:    bdrewery, glebius, ziaee
    Approved by:    glebius (mentor)
    Obtained from:  Fudo Security
    MFC after:      2 weeks
    Sponsored by:   Fudo Security
    Differential Revision:  https://reviews.freebsd.org/D57503
    
    (cherry picked from commit 9d10b4d2c9e86d8f6ff1b654f468381a4a4cad6d)
---
 usr.bin/xinstall/Makefile   |   2 +-
 usr.bin/xinstall/install.1  |  13 +-----
 usr.bin/xinstall/xinstall.c | 103 +++++++++++++++++++-------------------------
 3 files changed, 47 insertions(+), 71 deletions(-)

diff --git a/usr.bin/xinstall/Makefile b/usr.bin/xinstall/Makefile
index 588a2baca5c4..9e91b8b210a0 100644
--- a/usr.bin/xinstall/Makefile
+++ b/usr.bin/xinstall/Makefile
@@ -13,7 +13,7 @@ MAN=		install.1
 CFLAGS+=	-I${SRCTOP}/contrib/mtree
 CFLAGS+=	-I${SRCTOP}/lib/libnetbsd
 
-LIBADD=		md util
+LIBADD=		md
 CFLAGS+=	-DWITH_MD5 -DWITH_RIPEMD160
 
 .ifdef BOOTSTRAPPING
diff --git a/usr.bin/xinstall/install.1 b/usr.bin/xinstall/install.1
index 7c7b6f1b2651..193892c4a2b9 100644
--- a/usr.bin/xinstall/install.1
+++ b/usr.bin/xinstall/install.1
@@ -35,7 +35,7 @@
 .Nd install binaries
 .Sh SYNOPSIS
 .Nm
-.Op Fl bCcpSsUvz
+.Op Fl bCcpSsUv
 .Op Fl B Ar suffix
 .Op Fl D Ar destdir
 .Op Fl f Ar flags
@@ -47,10 +47,9 @@
 .Op Fl N Ar dbdir
 .Op Fl o Ar owner
 .Op Fl T Ar tags
-.Op Fl z Ar size
 .Ar file1 file2
 .Nm
-.Op Fl bCcpSsUvz
+.Op Fl bCcpSsUv
 .Op Fl B Ar suffix
 .Op Fl D Ar destdir
 .Op Fl f Ar flags
@@ -62,7 +61,6 @@
 .Op Fl N Ar dbdir
 .Op Fl o Ar owner
 .Op Fl T Ar tags
-.Op Fl z Ar size
 .Ar file1 ... fileN directory
 .Nm
 .Fl d
@@ -268,13 +266,6 @@ Cause
 .Nm
 to be verbose,
 showing files as they are installed or backed up.
-.It Fl z Ar maxsize
-Limit the comparison feature of
-.Fl C
-to files no larger than
-.Ar maxsize .
-Files exceeding this limit bypass the comparison step and are directly overwritten.
-The default maximum size is 128MiB.
 .El
 .Pp
 By default,
diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c
index 562632c523e8..a5173603d6ff 100644
--- a/usr.bin/xinstall/xinstall.c
+++ b/usr.bin/xinstall/xinstall.c
@@ -70,7 +70,6 @@ static char sccsid[] = "@(#)xinstall.c	8.1 (Berkeley) 7/21/93";
 #include <string.h>
 #include <sysexits.h>
 #include <unistd.h>
-#include <util.h>
 #include <vis.h>
 
 #include "mtree.h"
@@ -101,8 +100,6 @@ static char sccsid[] = "@(#)xinstall.c	8.1 (Berkeley) 7/21/93";
 #define HAVE_STRUCT_STAT_ST_FLAGS 0
 #endif
 
-#define MAX_CMP_SIZE	(128 * 1024 * 1024)
-
 #define	LN_ABSOLUTE	0x01
 #define	LN_RELATIVE	0x02
 #define	LN_HARD		0x04
@@ -151,7 +148,6 @@ static FILE *metafp;
 static const char *group, *owner;
 static const char *suffix = BACKUP_SUFFIX;
 static char *destdir, *digest, *fflags, *metafile, *tags;
-static size_t max_compare_size = MAX_CMP_SIZE;
 
 static int	compare(int, const char *, size_t, int, const char *, size_t,
 		    char **);
@@ -183,13 +179,12 @@ main(int argc, char *argv[])
 	u_int iflags;
 	char *p;
 	const char *to_name;
-	uint64_t num;
 
 	fset = 0;
 	iflags = 0;
 	set = NULL;
 	group = owner = NULL;
-	while ((ch = getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uvz:")) !=
+	while ((ch = getopt(argc, argv, "B:bCcD:df:g:h:l:M:m:N:o:pSsT:Uv")) !=
 	     -1)
 		switch((char)ch) {
 		case 'B':
@@ -286,13 +281,6 @@ main(int argc, char *argv[])
 		case 'v':
 			verbose = 1;
 			break;
-		case 'z':
-			if (expand_number(optarg, &num) != 0 || num == 0) {
-				errx(EX_USAGE, "invalid max compare filesize:"
-				    " %s", optarg);
-			}
-			max_compare_size = num;
-			break;
 		case '?':
 		default:
 			usage();
@@ -1106,8 +1094,11 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
 	int to_fd, const char *to_name __unused, size_t to_len,
 	char **dresp)
 {
-	int rv;
+	static char *buf, *buf1, *buf2;
+	static size_t bufsize;
 	int do_digest;
+	int n1, n2;
+	int rv;
 	DIGEST_CTX ctx;
 
 	if (from_len != to_len)
@@ -1115,53 +1106,47 @@ compare(int from_fd, const char *from_name __unused, size_t from_len,
 
 	do_digest = (digesttype != DIGEST_NONE && dresp != NULL &&
 	    *dresp == NULL);
-	if (from_len <= max_compare_size) {
-		static char *buf, *buf1, *buf2;
-		static size_t bufsize;
-		int n1, n2;
 
-		if (do_digest)
-			digest_init(&ctx);
+	if (do_digest)
+		digest_init(&ctx);
 
-		if (buf == NULL) {
-			/*
-			 * Note that buf and bufsize are static. If
-			 * malloc() fails, it will fail at the start
-			 * and not copy only some files.
-			 */
-			if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
-				bufsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
+	if (buf == NULL) {
+		/*
+		 * Note that buf and bufsize are static. If
+		 * malloc() fails, it will fail at the start
+		 * and not copy only some files.
+		 */
+		if (sysconf(_SC_PHYS_PAGES) > PHYSPAGES_THRESHOLD)
+			bufsize = MIN(BUFSIZE_MAX, MAXPHYS * 8);
+		else
+			bufsize = BUFSIZE_SMALL;
+		buf = malloc(bufsize * 2);
+		if (buf == NULL)
+			err(1, "Not enough memory");
+		buf1 = buf;
+		buf2 = buf + bufsize;
+	}
+
+	rv = 0;
+	lseek(from_fd, 0, SEEK_SET);
+	lseek(to_fd, 0, SEEK_SET);
+	while (rv == 0) {
+		n1 = read(from_fd, buf1, bufsize);
+		if (n1 == 0)
+			break;		/* EOF */
+		else if (n1 > 0) {
+			n2 = read(to_fd, buf2, n1);
+			if (n2 == n1)
+				rv = memcmp(buf1, buf2, n1);
 			else
-				bufsize = BUFSIZE_SMALL;
-			buf = malloc(bufsize * 2);
-			if (buf == NULL)
-				err(1, "Not enough memory");
-			buf1 = buf;
-			buf2 = buf + bufsize;
-		}
-		rv = 0;
-		lseek(from_fd, 0, SEEK_SET);
-		lseek(to_fd, 0, SEEK_SET);
-		while (rv == 0) {
-			n1 = read(from_fd, buf1, bufsize);
-			if (n1 == 0)
-				break;		/* EOF */
-			else if (n1 > 0) {
-				n2 = read(to_fd, buf2, n1);
-				if (n2 == n1)
-					rv = memcmp(buf1, buf2, n1);
-				else
-					rv = 1;	/* out of sync */
-			} else
-				rv = 1;		/* read failure */
-			if (do_digest)
-				digest_update(&ctx, buf1, n1);
-		}
-		lseek(from_fd, 0, SEEK_SET);
-		lseek(to_fd, 0, SEEK_SET);
-	} else {
-		rv = 1;	/* don't bother in this case */
+				rv = 1;	/* out of sync */
+		} else
+			rv = 1;		/* read failure */
+		if (do_digest)
+			digest_update(&ctx, buf1, n1);
 	}
+	lseek(from_fd, 0, SEEK_SET);
+	lseek(to_fd, 0, SEEK_SET);
 
 	if (do_digest) {
 		if (rv == 0)
@@ -1507,11 +1492,11 @@ usage(void)
 {
 	(void)fprintf(stderr,
 "usage: install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]\n"
-"               [-M log] [-D dest] [-h hash] [-T tags] [-z maxcmpsize]\n"
+"               [-M log] [-D dest] [-h hash] [-T tags]\n"
 "               [-B suffix] [-l linkflags] [-N dbdir]\n"
 "               file1 file2\n"
 "       install [-bCcpSsUv] [-f flags] [-g group] [-m mode] [-o owner]\n"
-"               [-M log] [-D dest] [-h hash] [-T tags] [-z maxcmpsize]\n"
+"               [-M log] [-D dest] [-h hash] [-T tags]\n"
 "               [-B suffix] [-l linkflags] [-N dbdir]\n"
 "               file1 ... fileN directory\n"
 "       install -dU [-vU] [-g group] [-m mode] [-N dbdir] [-o owner]\n"
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.