From nobody Fri Nov 17 18:28:31 2023 X-Original-To: dev-commits-ports-main@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 4SX54v56rvz51FFn; Fri, 17 Nov 2023 18:28:31 +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 4SX54v4ccWz4bpM; Fri, 17 Nov 2023 18:28:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700245711; 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=7EgU7B2gZNRrfTnz1V7huKObNy60odKQ5ey961R9eyI=; b=AZ5Bl1nW1RXas6TmrnPjT6B9pJM7fbfBxsPLfpqmde+IRmQN/80RVuwcJi6yLF/kSL9rPD 7ljZCLeN0s1Ct6sHndm76TWbqyUdsPogxAbYbREzUB9NBwI5uRUdeOTtN6Nuf4tBY1IEo+ Y6tF+ZdxYZitTQFM99JsEBqmF6Mhj1tge5eKSzN37zUh2y5xGyApr/W60NLKFvm0uQvSQy HM6APgdZV3yPgT7Ya1tawchUcW0e1pjpaIL+pSkF9pqyjWq2ZLJWRiIyDt4ubak6LZ7Qx1 O3A40lXB4B2nA1coIIGjWmz7J4VT9pkO9rAc1usRUbWBOOqisFTd4o27Rvjojg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700245711; 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=7EgU7B2gZNRrfTnz1V7huKObNy60odKQ5ey961R9eyI=; b=tesU2WO+nnINoMju88EFFhaBxWqe1YoYZrNTTBhmlPB9TjeJ73sAXJClSamLByxKIMlp7t yi0dmR45REQmmONeXROnpXA9PhU3HsN8G4tIkZqiZ+egugbu38rkQUxfMWLoDtYxUlXC7M 0ChPwnjVJkDGO84rmvkFG3sR/F5/4aSTERY6JvNRObJB9TsQ5Jnc64gQUjzCamSX1hd2Ru jA+/2C9FFWq6XMGeNas+Y97/922s/GuX1ZP19p160uSiKdHjXmEwvRWKOAl5PxoapWvWCV kwFVQWTFO3G1rG6UDTAMAXfk0lk1E5mEci1zNQU9Rf+4Vfoh33xBEM8EKzc31w== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700245711; a=rsa-sha256; cv=none; b=ohggJfrR7c7m+CQm4XJBvn58zFy/aeaHyCjnsKZPf0SOowG9V8bOoWkMJQzmAigmTg1nGe DQZX/OYtnV0pc2D2xtzOlkjNKgsNoNsPASsnYqs2csh9eDH2a6GiQmjTS7FEIoVFa5I6fK 6cS5DA08fgDNSa+ebTN9MGhfXF3G8lpsMoO2CQdVtB0ZQPASNSzS6PCYlrc4j1NcdNhhKd mihUmI9vLZz5mze/QdZEBWfb0s3nHBJliAEwNaRSmLkq/d+WBA++VaUwhjE/letDLeJQUn ftmdYFVdUhhUHW87obYqofAtU1DooV1g4Kfa2wHmyFlbyqBSf1h0wP2fCZn3fg== 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 4SX54v3gmcztvp; Fri, 17 Nov 2023 18:28:31 +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 3AHISVAw009877; Fri, 17 Nov 2023 18:28:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AHISVWM009874; Fri, 17 Nov 2023 18:28:31 GMT (envelope-from git) Date: Fri, 17 Nov 2023 18:28:31 GMT Message-Id: <202311171828.3AHISVWM009874@gitrepo.freebsd.org> To: ports-committers@FreeBSD.org, dev-commits-ports-all@FreeBSD.org, dev-commits-ports-main@FreeBSD.org From: Fernando =?utf-8?Q?Apestegu=C3=ADa?= Subject: git: efcf734590ea - main - sysutils/jdupes: Update to 1.27.3_1 List-Id: Commits to the main branch of the FreeBSD ports repository List-Archive: https://lists.freebsd.org/archives/dev-commits-ports-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-ports-main@freebsd.org X-BeenThere: dev-commits-ports-main@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/main X-Git-Reftype: branch X-Git-Commit: efcf734590eaaf1dee0bac5fc758680925501d15 Auto-Submitted: auto-generated The branch main has been updated by fernape: URL: https://cgit.FreeBSD.org/ports/commit/?id=efcf734590eaaf1dee0bac5fc758680925501d15 commit efcf734590eaaf1dee0bac5fc758680925501d15 Author: Thomas Hurst AuthorDate: 2023-11-17 07:30:06 +0000 Commit: Fernando ApesteguĂ­a CommitDate: 2023-11-17 18:28:15 +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) --- 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; + } +