Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp605541pxb; Thu, 5 Nov 2020 08:18:52 -0800 (PST) X-Google-Smtp-Source: ABdhPJzkYh6yhls6iNZqsT3V+fRCr7PCoJSB1Sb9oaFglvNElnoxUJz7rSl00gok9EMLG0qg1X53 X-Received: by 2002:a17:906:50f:: with SMTP id j15mr2831120eja.198.1604593132237; Thu, 05 Nov 2020 08:18:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1604593132; cv=none; d=google.com; s=arc-20160816; b=0Tat6QFJdGFfRGTB/WVzZmHOFxKu1OMthD/d3GTodJ7v/YdSE45faZi1RG3nHTT0J/ xEKq+zotk8DhKPLx7OsFM+axBqOXcadOORIIRogqTBi1E8OGoe2GZNEKB2zkLf6SNoK4 M08JyyEnWe8+sMvi4kotdqaA2V19s/MIVg7Np+SwVAfbclnygp+CkXYdu1QOtouQ2y9Y aa8Q0kU+k0dNcwb5hNz5BNwRTA1JIRfFCIk+iHqgw2hWneEVkDbpGcWvcxlYPgE1s7ao UNnecZMO1uxBNxn9eMXcnmxw52Wz/j9cfGIQcM9VDuV0/IZ9r9KH1BNHNcmzdEjL1W9U VelA== 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=Z5ZRKZvZzkLCJYmtA5ETalH+VAYet8VjkcJtF0arxmY=; b=dJcyNN5s3bpQKP36/CTTXsRhQIFU4NdIn3eLCTXq09AWK/tPBetyr9KGh7gBWx1p6s ev25/LtAxY5LGVxpG+n5cZN0BvIA2atuFaT74qef8wRzxOWfkaEb0PniReXlT/a+hUDQ bNplpAhqHkN0+zvZEjNzldKN4R9T005fJF3BwW0ufZeyXhZukJzNgbCMfc9ZwSJE6THV zk/jKFzMwjehe7twhMKVi4+CeIabbjUxnz8E+Zh//gYCchrJBwzAjeptGflBfyY+BRPy oZMKMecIegd5D/fJ6jQ/6WRGZswZhVtlovpqDEr3CEDFynGoB9bj/V0IOeaQMYe1PvDj 3PDg== 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 bi17si1774683edb.582.2020.11.05.08.18.29; Thu, 05 Nov 2020 08:18:52 -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 S1730808AbgKEQSC (ORCPT + 99 others); Thu, 5 Nov 2020 11:18:02 -0500 Received: from bhuna.collabora.co.uk ([46.235.227.227]:49738 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726214AbgKEQSA (ORCPT ); Thu, 5 Nov 2020 11:18:00 -0500 Received: from xps.home (unknown [IPv6:2a01:e35:2fb5:1510:4a7e:bc14:686e:75db]) (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 1B2881F4612A; Thu, 5 Nov 2020 16:17:59 +0000 (GMT) From: Arnaud Ferraris To: linux-ext4@vger.kernel.org Cc: Gabriel Krisman Bertazi , Arnaud Ferraris Subject: [PATCH 08/11] e2fsck: Detect duplicated casefolded direntries for rehash Date: Thu, 5 Nov 2020 17:16:40 +0100 Message-Id: <20201105161642.87488-9-arnaud.ferraris@collabora.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201105161642.87488-1-arnaud.ferraris@collabora.com> References: <20201105161642.87488-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 c9eba7c0..da00e244 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