From: Arnaud Ferraris <arnaud.ferraris@collabora.com>
To: linux-ext4@vger.kernel.org
Cc: Daniel Rosenberg <drosen@google.com>,
Gabriel Krisman Bertazi <krisman@collabora.com>,
Arnaud Ferraris <arnaud.ferraris@collabora.com>
Subject: [PATCH v2 09/12] e2fsck: Detect duplicated casefolded direntries for rehash
Date: Fri, 27 Nov 2020 18:01:13 +0100 [thread overview]
Message-ID: <20201127170116.197901-10-arnaud.ferraris@collabora.com> (raw)
In-Reply-To: <20201127170116.197901-1-arnaud.ferraris@collabora.com>
From: Gabriel Krisman Bertazi <krisman@collabora.com>
On pass2, support casefolded directories when looking for duplicated
entries.
Signed-off-by: Gabriel Krisman Bertazi <krisman@collabora.com>
Signed-off-by: Arnaud Ferraris <arnaud.ferraris@collabora.com>
---
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
next prev parent reply other threads:[~2020-11-27 17:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-27 17:01 [PATCH v2 00/12] e2fsprogs: improve case-insensitive fs support Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 01/12] tune2fs: Allow enabling casefold feature after fs creation Arnaud Ferraris
2020-12-07 17:17 ` Gabriel Krisman Bertazi
2020-11-27 17:01 ` [PATCH v2 02/12] tune2fs: Fix casefold+encrypt error message Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 03/12] ext2fs: Add method to validate casefolded strings Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 04/12] ext2fs: Implement faster CI comparison of strings Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 05/12] e2fsck: add new problem for casefolded name check Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 06/12] e2fsck: Fix entries with invalid encoded characters Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 07/12] e2fsck: Support casefold directories when rehashing Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 08/12] dict: Support comparison with context Arnaud Ferraris
2020-11-27 17:01 ` Arnaud Ferraris [this message]
2020-11-27 17:01 ` [PATCH v2 10/12] e2fsck: Add option to force encoded filename verification Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 11/12] e2fsck.8.in: Document check_encoding extended option Arnaud Ferraris
2020-11-27 17:01 ` [PATCH v2 12/12] tests: f_bad_fname: Test fixes of invalid filenames and duplicates Arnaud Ferraris
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201127170116.197901-10-arnaud.ferraris@collabora.com \
--to=arnaud.ferraris@collabora.com \
--cc=drosen@google.com \
--cc=krisman@collabora.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).