Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1425774pxu; Thu, 17 Dec 2020 09:37:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJwsh+aJQmU0IOma8VtrLV2n8G5ieXlt9qDu/47zzei+HH5NM8RXhyqOVHNtQQ7VxJU6KqgY X-Received: by 2002:a17:906:1b46:: with SMTP id p6mr125946ejg.68.1608226666918; Thu, 17 Dec 2020 09:37:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1608226666; cv=none; d=google.com; s=arc-20160816; b=pjtMhgHGsWNaM0Yyz7S6NuCB6qrMwraGLaecsg3ObLcZr+B5vk/jIncmpVrJcJMcYY X/xNIKNyCP4R584NUD5Ca1s4AHxHTT0A3+TixEkyF3dkyAwHEyFLk/dg0fT0//44VZCy XXsk3B++jRW5CCbyAZdx6O+G6gPwvVqnaxTLOV7NFpYK81o7uFF7EiM1sEvl68ySFrnU jlUv7Hsu7b0JjpywlzhM3shBNaQIERZQ1HysXHDCwDo7cSKNNqx7Lb8hmkIEU2f3ehzw VaKbq99rA48KtYWkXduVULEF/rhVFbfHfEjMhrtsqJtTSZBi5kWVbOLMejDAai0rCMTO f3uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=ex16wUfSo1jiKOy+DPea/kA2rVtWHR254AKBgG4Wq7g=; b=Id5Onh0kLH4AYS70Zw6ZA8SDydCMvTMsnSjbWsGbNJm9vKtB+2a/1pP2qrJRqWOUkk cJlT8lyRfJNCuKlzT3EaaUMc/nEbSY3HWTlysxmWL69WD7DIX7cL0o8R0btUPJBCflTs 42RS94PD+gSlfjmSzYomAmYYhGwQbx3zyeJb2iMRXhTb2wbqDYeIQEIvWoq6xxpJPPF1 zgjs4ilPz1pmRcm+nIUpx0Hfn2O1zfg6mPSsejY1bepisR5AET8YKIhx2VERovaZ2LdY HtLNxnURR8UgnfzdHvlk2wKbCS5wdwLgre0H2lmMgR+QYq+hUsR0UIJnxRYcFEW1pCoY 5vug== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id qq23si2780043ejb.232.2020.12.17.09.37.23; Thu, 17 Dec 2020 09:37:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726548AbgLQRgi (ORCPT + 99 others); Thu, 17 Dec 2020 12:36:38 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:54790 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728487AbgLQRgg (ORCPT ); Thu, 17 Dec 2020 12:36:36 -0500 Received: from xps.home (unknown [IPv6:2a01:e35:2fb5:1510:779a:3a80:1322:d34a]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: aferraris) by bhuna.collabora.co.uk (Postfix) with ESMTPSA id 379CF1F45D18; Thu, 17 Dec 2020 17:35:54 +0000 (GMT) From: Arnaud Ferraris To: linux-ext4@vger.kernel.org Cc: drosen@google.com, krisman@collabora.com, ebiggers@kernel.org, tytso@mit.edu, Arnaud Ferraris Subject: [PATCH v3 09/12] e2fsck: Detect duplicated casefolded direntries for rehash Date: Thu, 17 Dec 2020 18:35:41 +0100 Message-Id: <20201217173544.52953-10-arnaud.ferraris@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201217173544.52953-1-arnaud.ferraris@collabora.com> References: <20201217173544.52953-1-arnaud.ferraris@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org From: Gabriel Krisman Bertazi On pass2, support casefolded directories when looking for duplicated entries. Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Arnaud Ferraris --- e2fsck/pass2.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index 153e05f0..f23a3a9c 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -344,6 +344,20 @@ static int dict_de_cmp(const void *cmp_ctx, const void *a, const void *b) return memcmp(de_a->name, de_b->name, a_len); } +static int dict_de_cf_cmp(const void *cmp_ctx, const void *a, const void *b) +{ + const struct ext2fs_nls_table *tbl = cmp_ctx; + const struct ext2_dir_entry *de_a, *de_b; + int a_len, b_len; + + de_a = (const struct ext2_dir_entry *) a; + a_len = ext2fs_dirent_name_len(de_a); + de_b = (const struct ext2_dir_entry *) b; + b_len = ext2fs_dirent_name_len(de_b); + + return ext2fs_casefold_cmp(tbl, de_a->name, a_len, de_b->name, b_len); +} + /* * This is special sort function that makes sure that directory blocks * with a dirblock of zero are sorted to the beginning of the list. @@ -1255,7 +1269,13 @@ skip_checksum: dir_encpolicy_id = find_encryption_policy(ctx, ino); - dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp); + if (cf_dir) { + dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cf_cmp); + dict_set_cmp_context(&de_dict, (void *)ctx->fs->encoding); + } else { + dict_init(&de_dict, DICTCOUNT_T_MAX, dict_de_cmp); + } + prev = 0; do { dgrp_t group; -- 2.29.2