From nobody Fri Nov 17 18:29:49 2023 X-Original-To: dev-commits-ports-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4SX56P63CDz51FBZ; Fri, 17 Nov 2023 18:29:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4SX56P5JrTz4bvG; Fri, 17 Nov 2023 18:29:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700245789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A0ZyQ8jKQnOzp5j1Qt7Z0W+VplpgzFa7mcaOlA0m6Vo=; b=lgMG+NCABClD4v0w8GHjOU/O/eNyBCFdTXhFpqVOD7/my+xDBJuZr5VMk4SDogF4rB/ctv +MLkx+fxlu+sDSe9lKgSJRgvwZsuxzzIpr/Gm/+G86upiIM+GSzKyjHyJk+GE4PkRsuSY1 WUOJm+XBXTNBtrVM338gO/LCOWoYRM8y85phs/7etpukC6JYaE/QX+Q7KmFWvGlnR5lkei eIrj5vPxPOO39P5dKbXnYG+3wwpySGVw5tNqc6aeP6t30AQQ/dbOq+cK8CLcL9bJ3uFR25 HRvlAyW2RRze5BZR+Q6cf9LiJEnJOym7k6qos5PT9UFYrENj/J1AiI3Tymc9BQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700245789; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=A0ZyQ8jKQnOzp5j1Qt7Z0W+VplpgzFa7mcaOlA0m6Vo=; b=covVU0mjY1XL/XpUqvRnqCDH3I/NhEYQVS5Wa3Kdw2BLIJQf4AglJc7aTl3FqBm0BW0dUX kV3qZdJlYLXK9UGgOajX3l+I6hW5n0rc681yoPt535DKVcugv6N6jIR9/1az0dxv0en3+I yr8T55ah7blVfqoUcEqdifGIp/Jtwh2BHxpnY/IeRIerkMojit7Nq6zi5/3+H2R02v4s1F S7+KO0WtwRI35Fr6rBgdGncbLeLCUDj1yaXkYCMuKPC0JSFlc4sQ9ZYoAYA0S7ydNK8nSP y0chMfgtNtkuBCkitExNaxaYpcKECbm2/xgT38q9uk1btmP2ru3+mi6R+2Hz8g== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700245789; a=rsa-sha256; cv=none; b=oGEsTgek/8kbL/kj79LPVKnUwHZ8eyTYs+iak5wLc0PrlPz3gg42YB8d6k61ffxWm1643S 6iD2kjh/3mMtSBgQXUeAivuugdByEZ0x7t7xxZa1gZ0E7vNAe/DKbyxo5jdi5QIdDu+dAj isU5PqBgMhTIZdGO8DWzseS4kzrd6FcGJjtkqcWn3P4t90YOCF2RPutS+pxFLrbjvushxi xxDAXiYzQd8sBIxWA1vI8cRQnptLZoWQKNCkYnVxfeJsmFHMI0ViZ0bZAvHed2jegWzC9W uyHqObzvOyeZjlUpMC1IqbbOcBnn0PmkQ3uKoz40RRsb8629GFxd2oZLAR8MqQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4SX56P45vQztTW; Fri, 17 Nov 2023 18:29:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AHITn1u010185; Fri, 17 Nov 2023 18:29:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AHITnnh010181; Fri, 17 Nov 2023 18:29:49 GMT (envelope-from git) Date: Fri, 17 Nov 2023 18:29:49 GMT Message-Id: <202311171829.3AHITnnh010181@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-branches@FreeBSD.org From: Fernando =?utf-8?Q?Apestegu=C3=ADa?= Subject: git: 91b52f2c0fd0 - 2023Q4 - sysutils/jdupes: Update to 1.27.3_1 List-Id: Commits to the quarterly branches of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-branches@freebsd.org X-BeenThere: dev-commits-ports-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: fernape X-Git-Repository: ports X-Git-Refname: refs/heads/2023Q4 X-Git-Reftype: branch X-Git-Commit: 91b52f2c0fd09ef333fe1a2ac1f0ce5f27d9b741 Auto-Submitted: auto-generated The branch 2023Q4 has been updated by fernape: URL: https://cgit.FreeBSD.org/ports/commit/?id=91b52f2c0fd09ef333fe1a2ac1f0ce5f27d9b741 commit 91b52f2c0fd09ef333fe1a2ac1f0ce5f27d9b741 Author: Thomas Hurst AuthorDate: 2023-11-17 07:30:06 +0000 Commit: Fernando ApesteguĂ­a CommitDate: 2023-11-17 18:29:23 +0000 sysutils/jdupes: Update to 1.27.3_1 ChangeLog: https://www.jdupes.com/2023/11/10/news-fix-for-v1-27-3-libjodycode-4-work/ Apply a fix for the jdupes hash database feature to avoid potential database loss, resulting from disk-full situations and other write failures. PR: 275128 Reported by: tom@hur.st (maintainer) MFH: 2023Q4 (bugfix) (cherry picked from commit efcf734590eaaf1dee0bac5fc758680925501d15) --- sysutils/jdupes/Makefile | 1 + sysutils/jdupes/files/patch-hashdb.c | 114 +++++++++++++++++++++++++++++++++++ 2 files changed, 115 insertions(+) diff --git a/sysutils/jdupes/Makefile b/sysutils/jdupes/Makefile index ebb0aed66e32..c2eedc8de39d 100644 --- a/sysutils/jdupes/Makefile +++ b/sysutils/jdupes/Makefile @@ -1,6 +1,7 @@ PORTNAME= jdupes DISTVERSIONPREFIX= v DISTVERSION= 1.27.3 +PORTREVISION= 1 CATEGORIES= sysutils MAINTAINER= tom@hur.st diff --git a/sysutils/jdupes/files/patch-hashdb.c b/sysutils/jdupes/files/patch-hashdb.c new file mode 100644 index 000000000000..bc631af357c2 --- /dev/null +++ b/sysutils/jdupes/files/patch-hashdb.c @@ -0,0 +1,114 @@ +--- hashdb.c.orig 2023-08-27 01:12:34 UTC ++++ hashdb.c +@@ -31,6 +31,7 @@ static hashdb_t *hashdb[HT_SIZE]; + static int hashdb_init = 0; + static int hashdb_algo = 0; + static int hashdb_dirty = 0; ++static int new_hashdb = 0; + + /* Pivot direction for rebalance */ + enum pivot { PIVOT_LEFT, PIVOT_RIGHT }; +@@ -68,20 +69,35 @@ int save_hash_database(const char * const restrict dbn + { + FILE *db = NULL; + uint64_t cnt = 0; ++ char *dbtemp; + + if (dbname == NULL) goto error_hashdb_null; + LOUD(fprintf(stderr, "save_hash_database('%s')\n", dbname);) + /* Don't save the hash database if it wasn't changed */ + if (hashdb_dirty == 0 && destroy == 0) return 0; + if (hashdb_dirty == 1) { ++ + errno = 0; +- db = fopen(dbname, "w+b"); ++ dbtemp = malloc(strlen(dbname) + 5); ++ if (dbtemp == NULL) goto error_hashdb_alloc; ++ strcpy(dbtemp, dbname); ++ strcat(dbtemp, ".tmp"); ++ /* Try to remove any existing temporary database, ignoring errors */ ++ remove(dbtemp); ++ db = fopen(dbtemp, "rb"); + if (db == NULL) goto error_hashdb_open; + } + +- if (write_hashdb_entry(db, NULL, &cnt, destroy) != 0) goto error_hashdb_write; + if (hashdb_dirty == 1) { ++ if (write_hashdb_entry(db, NULL, &cnt, destroy) != 0) goto error_hashdb_write; + fclose(db); ++ if (new_hashdb == 0) { ++ errno = 0; ++ if (remove(dbname) != 0) { ++ if (errno != ENOENT) goto error_hashdb_remove; ++ } ++ } ++ if (rename(dbtemp, dbname) != 0) goto error_hashdb_rename; + LOUD(if (hashdb_dirty == 1) fprintf(stderr, "Wrote %" PRIu64 " items to hash databse '%s'\n", cnt, dbname);) + hashdb_dirty = 0; + } +@@ -92,12 +108,22 @@ error_hashdb_null: + fprintf(stderr, "error: internal failure: NULL pointer for hashdb\n"); + return -1; + error_hashdb_open: +- fprintf(stderr, "error: cannot open hashdb '%s' for writing: %s\n", dbname, strerror(errno)); ++ fprintf(stderr, "error: cannot open temp hashdb '%s' for writing: %s\n", dbtemp, strerror(errno)); + return -2; + error_hashdb_write: +- fprintf(stderr, "error: writing failed to hashdb '%s': %s\n", dbname, strerror(errno)); ++ fprintf(stderr, "error: write failed to temp hashdb '%s': %s\n", dbtemp, strerror(errno)); + fclose(db); + return -3; ++error_hashdb_alloc: ++ fprintf(stderr, "error: cannot allocate memory for temporary hashdb name\n"); ++ return -4; ++error_hashdb_remove: ++ fprintf(stderr, "error: cannot delete old hashdb '%s': %s\n", dbname, strerror(errno)); ++ remove(dbtemp); ++ return -5; ++error_hashdb_rename: ++ fprintf(stderr, "error: cannot rename temporary hashdb '%s' to '%s'; leaving it alone: %s\n", dbtemp, dbname, strerror(errno)); ++ return -6; + } + + +@@ -435,31 +461,40 @@ int64_t load_hash_database(char *dbname) + entry->hashcount = hashcount; + } + ++ fclose(db); + return linenum - 1; + + warn_hashdb_open: + fprintf(stderr, "Creating a new hash database '%s'\n", dbname); ++ fclose(db); ++ new_hashdb = 1; + return 0; + error_hashdb_read: + fprintf(stderr, "error reading hash database '%s': %s\n", dbname, strerror(errno)); ++ fclose(db); + return -1; + error_hashdb_header: + fprintf(stderr, "error in header of hash database '%s'\n", dbname); ++ fclose(db); + return -2; + error_hashdb_version: + fprintf(stderr, "error: bad db version %u in hash database '%s'\n", db_ver, dbname); ++ fclose(db); + return -3; + error_hashdb_line: + fprintf(stderr, "\nerror: bad line %" PRId64 " in hash database '%s':\n\n%s\n\n", linenum, dbname, line); ++ fclose(db); + return -4; + error_hashdb_add: + fprintf(stderr, "error: internal failure allocating a hashdb entry\n"); ++ fclose(db); + return -5; + error_hashdb_null: + fprintf(stderr, "error: internal failure: NULL pointer for hashdb\n"); + return -6; + warn_hashdb_algo: + fprintf(stderr, "warning: hashdb uses a different hash algorithm than selected; not loading\n"); ++ fclose(db); + return -7; + } +