Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp1031061ybb; Wed, 25 Mar 2020 14:19:04 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtUNDQ9Ny0Ke3psuVcLk0WDBAoRHbSWT3Y/8+mejTXnO568loeWZPgK8Exu3V9sptdOXDw8 X-Received: by 2002:aca:d987:: with SMTP id q129mr3775200oig.64.1585171144699; Wed, 25 Mar 2020 14:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1585171144; cv=none; d=google.com; s=arc-20160816; b=zv19OBqQNXBqGgWgBw97kNelF5V/mMRnQ1LvBagRR/aC+GdZhdNAYoOIp9xH+PFCXQ tO+c45JxqByfGL8o7ROP/P5y3xTyhUGju9TOG74tjtAPxeLVBbkseZ20RKdg/o6R6Vch 5LcNfjQivYCnbBXf6cVsY37lrb9/Lw9CLXU0VnQP9nzWpGDRues8LPO056PWyFjNfPnQ tr3m6ikHTMmuOteE+XdPG/eIx51mT0X1vrUedvNoN745A9VT4enytwRKvCn/RfgtwqM8 9U5sxCKD59J/REBR2VFWQpqFkt03+MNb2dug5f3wRWFZkQd0di7ODCKYuG64hXtM8OQS NclQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=+W++m9EuxBG1t8FCbgMO4Cq8DOHNMvq/6tIyDZw93n0=; b=l7r17f8EJRX5jOyCMNWV5Ybag7Hp+17swq4G17b/pkQpjWQTAFHZoO5bUMnfdKIylo bCWOW7kLEja2ziSEmZegVFPtMnTcU2S7GbT9yaLYpVDKLr/YP+8YL1Sl/CUMWgLcfJgn 0CDf6IMHbuD0eatLPaJ82kLhxrn05/PLiV10Eys5S/+Zzh725lHiQlWeKNYSOIJCBBtR jFHoghjtNQjWlGHlX3rkd4B0dH4guYntH6DG7XHrZlopRBZY0xcsFBq7zSI8g4N7b9H6 /qhqW8Au0hGZQU0VP/stizO8q/zK4HsQzf3lhus18Rc/rchAwsDeywhnZr28Vy7jzNvB NvHA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id e11si108867oib.152.2020.03.25.14.18.53; Wed, 25 Mar 2020 14:19:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-ext4-owner@vger.kernel.org designates 209.132.180.67 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 S1727395AbgCYVSt (ORCPT + 99 others); Wed, 25 Mar 2020 17:18:49 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:39586 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727351AbgCYVSt (ORCPT ); Wed, 25 Mar 2020 17:18:49 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: krisman) with ESMTPSA id 154D928666B From: Gabriel Krisman Bertazi To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org, Gabriel Krisman Bertazi Subject: [PATCH e2fsprogs 08/11] e2fsck: Detect duplicated casefolded direntries for rehash Date: Wed, 25 Mar 2020 17:18:08 -0400 Message-Id: <20200325211812.2971787-9-krisman@collabora.com> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200325211812.2971787-1-krisman@collabora.com> References: <20200325211812.2971787-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-ext4-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org On pass2, support casefolded directories when looking for duplicated entries. Signed-off-by: Gabriel Krisman Bertazi --- e2fsck/pass2.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/e2fsck/pass2.c b/e2fsck/pass2.c index bc2c5b90bc97..3b9a2ac78b00 100644 --- a/e2fsck/pass2.c +++ b/e2fsck/pass2.c @@ -343,6 +343,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. @@ -1254,7 +1268,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.25.0