Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp4863790pxu; Thu, 10 Dec 2020 07:17:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJyDUNFRNxAzJQVXnYVO1KCs5PIsop4x5d6S8Bparnw0vo97D58WC6XRuAOnxMzEMi0eYwV9 X-Received: by 2002:a05:6402:b9a:: with SMTP id cf26mr7143483edb.372.1607613452499; Thu, 10 Dec 2020 07:17:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607613452; cv=none; d=google.com; s=arc-20160816; b=ij5lV4E446dlB3YyNx/HkBeZ6nS+Js8E7a5xQdEjjeJtPw5LYJ52nAiwJ3gK3xbSbp 1ocLrzCG1B7dOscENKP8IK+p5YkkT31banl/czd+ZQB92Ba9K7JJLqL/1gYEkly/Jjaq tneFYgE3VKndczzb4pAaVnzV74yI06kPQKhbt3YSdP5HAiYQTS6WZ47o/7iaQUxxS16R RKlcWajvk5tsAoKekbY2CpFCarlj4ro5yDP6Bm6LXZwNVqyDWgtTi9xK3UXyzKxxlE+v /JY7cwAzZvTMHq9hisK8Uxdy6TUdtj8mk6CLOCbnnYU5X/58TD7N3p35i8sxV3Y6sdjf l71g== 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=YI8r72UbfhWpkJnXV1utb5XEjrDejJCJUwjyGMN39FE=; b=b/yumRytkeiZZwPwS6hqTgQvO92rbOZlhNMdaTgxy0qN4eVkF/8sfa3WCLZ8B6T5D0 LYbfIDiuTu4DCbm0kUj717g40O1YPwtOm9FbuMprarBv9XIHzTgeyUq9v4C8zJQuZAg8 peoL4bQZiHDzK8C6OiRQK0fpwX0HxOd01EU7r+8foKfK5JV4S2rmNbqszJY+rR7sZ8y5 3hZW/eQxjrOxWSY2t64vaOXlwKP4WjbyyNIJ364Z3nPv3Bh5H24UjLrsvjesJwm26EUM YINKZcZQppqgG5Nbtp+wZGaYIhVHct3rY//N7lYCLG5WOpPW3F9YClr5aLX9xNKDYl8p DwQw== 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 s7si2844361edx.227.2020.12.10.07.17.08; Thu, 10 Dec 2020 07:17:32 -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 S2388922AbgLJPFU (ORCPT + 99 others); Thu, 10 Dec 2020 10:05:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389066AbgLJPFS (ORCPT ); Thu, 10 Dec 2020 10:05:18 -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 C88F3C06138C for ; Thu, 10 Dec 2020 07:04:05 -0800 (PST) Received: from xps.home (unknown [IPv6:2a01:e35:2fb5:1510:1626:c942:e0f1:c77c]) (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 631511F458FD; Thu, 10 Dec 2020 15:04:04 +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 RESEND v2 09/12] e2fsck: Detect duplicated casefolded direntries for rehash Date: Thu, 10 Dec 2020 16:03:50 +0100 Message-Id: <20201210150353.91843-10-arnaud.ferraris@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201210150353.91843-1-arnaud.ferraris@collabora.com> References: <20201210150353.91843-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.29.2