Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1524973pxu; Fri, 27 Nov 2020 09:06:14 -0800 (PST) X-Google-Smtp-Source: ABdhPJxf4Ag/P6d+p5kQX6V8R4sPlhyTjPLF0jEtdlp8qTPBDrXZthGW7U7GH7uxNW6OBoCqo+1D X-Received: by 2002:a17:906:2850:: with SMTP id s16mr8675017ejc.276.1606496774393; Fri, 27 Nov 2020 09:06:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606496774; cv=none; d=google.com; s=arc-20160816; b=g5scNjOCwgt9n1/h5QiGEbyCJkD9qQpynXxdMNGNCKuKeJZkbpmQ8ihu4+ez0BdVS9 Q/Ks5roza2O6C23btTT6Z+2twgl6AbCdZ1crEquwu3IktDuZPk+i3zir/dTzNcgeYHXJ Ow7a58e3BFwGuAsmCE2vrobi+0caP4qffj+n4WOUfEMvQ+63vngeupcLWSJr6TStmgr7 v8Zb/yp074c8UUpfNTmjkP7BTLopfkShqAGayMnHC/Rx2+o9THZWX4L14jtPSxlE7VYC hCqq4xfslttn+5R1UvqdFAf5esjS48DKUA6AWLItMf27bUi6Q5FlM8r7NOSlAIwGZBZO wNYA== 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=Wl6zDbRLgEnA0iSM4rjl8gKSy7qA7I1GiNfFHe3oZd8=; b=jq4rkMyEGl46084oTuh8cJS+fXAYPWmc4+cgJlsr+thDl4446CoJ55pvqtGBysmglV /B8Lb8Q43ulh8f+l4WCoIIxy7VtiPGkZ5mF6U1P4Kix0QEhnQfzggBo9EiVzjp3mI0iX MtBxUZmy8cNKv0RDQYHnJkQzjGn/jHLeEjgX9YKmFC/wXlLG8aEGb+AfCOp8aNTxx7tc TCw3r5VJOtNCW3FJ7+WGDSUWWyVluhzM1MzCRcFoba602U0xNL/KYMflDiKjySAUPTiL 3X2OPo95u8yAv4sbMWlsefC6qVkL0Pkb9WQF3PWxU06XNbEbyP7KOMnYylajRwoH66AB pCWQ== 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 go40si5150166ejc.141.2020.11.27.09.05.48; Fri, 27 Nov 2020 09:06:14 -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 S1732088AbgK0RBk (ORCPT + 99 others); Fri, 27 Nov 2020 12:01:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732114AbgK0RBj (ORCPT ); Fri, 27 Nov 2020 12:01:39 -0500 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95217C0613D1 for ; Fri, 27 Nov 2020 09:01:39 -0800 (PST) Received: from xps.home (unknown [IPv6:2a01:e35:2fb5:1510:5a64:74b8:f3be:d972]) (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 1629A1F40ED0; Fri, 27 Nov 2020 17:01:38 +0000 (GMT) From: Arnaud Ferraris To: linux-ext4@vger.kernel.org Cc: Daniel Rosenberg , Gabriel Krisman Bertazi , Arnaud Ferraris Subject: [PATCH v2 09/12] e2fsck: Detect duplicated casefolded direntries for rehash Date: Fri, 27 Nov 2020 18:01:13 +0100 Message-Id: <20201127170116.197901-10-arnaud.ferraris@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201127170116.197901-1-arnaud.ferraris@collabora.com> References: <20201127170116.197901-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 b62bfcb1..b6514de8 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.28.0