From patchwork Thu Feb 8 06:43:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13549387 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.sourceforge.net (lists.sourceforge.net [216.105.38.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7AF7AC4828F for ; Thu, 8 Feb 2024 06:45:35 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-3.v29.lw.sourceforge.com) by sfs-ml-3.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rXyAA-0005oq-6i; Thu, 08 Feb 2024 06:45:34 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-3.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rXyA8-0005ok-67 for linux-f2fs-devel@lists.sourceforge.net; Thu, 08 Feb 2024 06:45:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sourceforge.net; s=x; h=Content-Transfer-Encoding:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type: Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender: Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=mUH8Ldjjxi8it9eaRNAUP8jiOKNg7HpR2OKWq4ySMwo=; b=T0bDAhI9osD4ohGLRkY4HwXrFM iE79VRBjqQN1HXjf1Kzwsmb25esp36G9qnHjXSwEPtVKsUI4Y7bg/poGqeO/I9Y4sJtkdtT1UV7RX lTm5PxG9Z5sG3bIRi+soHu8TqgzwmgqJWIzTYiBDqZ0mymzhbyRTgI/TaEuk4shvCSOA=; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sf.net; s=x ; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-Id: Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=mUH8Ldjjxi8it9eaRNAUP8jiOKNg7HpR2OKWq4ySMwo=; b=X4FveVxk6kxJioiaTNfH3QZ6D7 gpVSncIkNF8fB8rNNcsz7cviZR5th+MjyKcMnTtpJerNrMC/sh+44saS1hLk5qYr9/LYb4VaA8Evx dv1oLcsK2ZTDc3QRy/93nqP+buwsFBr7wlVAQaHxzj0vIg7vjT2Y39kOWkuGIdXjPTQs=; Received: from madrid.collaboradmins.com ([46.235.227.194]) by sfi-mx-2.v28.lw.sourceforge.com with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256) (Exim 4.95) id 1rXyA7-0000u8-6l for linux-f2fs-devel@lists.sourceforge.net; Thu, 08 Feb 2024 06:45:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1707374720; bh=dzKZXblpWESFyKaff5lcUS9bN5Ok7BHsB49SOtV2pf4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YLefnevkX12McBubm6n8iAgtkkqHcuSUHXRwwCg4xv5p+x3/OA76gR/Sy9izDrlwA eQCfcsm/M2L1fey/OZ4V3jbXIFyyHuRd5a5rkxfClZ2HKILxe8Ms5j7bblCr/R00BR lNnsG4ywbanfvoCLURrmjz+TRTnXvJ9OSOGlo/b5pDVftSrhYxeK4txDnikr5viC7f O7vgvvJ5UP1DV+wP+pTtr3LWGZZarcAB6MCUbyS4hiTWA6xHEW6BNGhB/lTdXhJZ+Y YtOkANP22Fnv/0fwTvwP+Vuhej0K8oTTuJYjiQvuid6iXi2vdQ+3M6o8LbSJKxAJk6 lqYeaoM7gfrWQ== Received: from eugen-station.. (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: ehristev) by madrid.collaboradmins.com (Postfix) with ESMTPSA id B8564378045F; Thu, 8 Feb 2024 06:45:15 +0000 (UTC) To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, chao@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net Date: Thu, 8 Feb 2024 08:43:34 +0200 Message-Id: <20240208064334.268216-4-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240208064334.268216-1-eugen.hristev@collabora.com> References: <20240208064334.268216-1-eugen.hristev@collabora.com> MIME-Version: 1.0 X-Headers-End: 1rXyA7-0000u8-6l Subject: [f2fs-dev] [RESEND PATCH v9 3/3] f2fs: Reuse generic_ci_match for ci comparisons X-BeenThere: linux-f2fs-devel@lists.sourceforge.net X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Eugen Hristev via Linux-f2fs-devel From: Eugen Hristev Reply-To: Eugen Hristev Cc: jack@suse.cz, Eric Biggers , linux-kernel@vger.kernel.org, eugen.hristev@collabora.com, linux-fsdevel@vger.kernel.org, kernel@collabora.com, Gabriel Krisman Bertazi Errors-To: linux-f2fs-devel-bounces@lists.sourceforge.net From: Gabriel Krisman Bertazi Now that ci_match is part of libfs, make f2fs reuse it instead of having a different implementation. Reviewed-by: Chao Yu Reviewed-by: Eric Biggers Signed-off-by: Gabriel Krisman Bertazi Signed-off-by: Eugen Hristev --- fs/f2fs/dir.c | 58 ++++----------------------------------------------- 1 file changed, 4 insertions(+), 54 deletions(-) diff --git a/fs/f2fs/dir.c b/fs/f2fs/dir.c index f5b65cf36393..7953322b9b9e 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -185,58 +185,6 @@ static struct f2fs_dir_entry *find_in_block(struct inode *dir, return f2fs_find_target_dentry(&d, fname, max_slots); } -#if IS_ENABLED(CONFIG_UNICODE) -/* - * Test whether a case-insensitive directory entry matches the filename - * being searched for. - * - * Returns 1 for a match, 0 for no match, and -errno on an error. - */ -static int f2fs_match_ci_name(const struct inode *dir, const struct qstr *name, - const u8 *de_name, u32 de_name_len) -{ - const struct super_block *sb = dir->i_sb; - const struct unicode_map *um = sb->s_encoding; - struct fscrypt_str decrypted_name = FSTR_INIT(NULL, de_name_len); - struct qstr entry = QSTR_INIT(de_name, de_name_len); - int res; - - if (IS_ENCRYPTED(dir)) { - const struct fscrypt_str encrypted_name = - FSTR_INIT((u8 *)de_name, de_name_len); - - if (WARN_ON_ONCE(!fscrypt_has_encryption_key(dir))) - return -EINVAL; - - decrypted_name.name = kmalloc(de_name_len, GFP_KERNEL); - if (!decrypted_name.name) - return -ENOMEM; - res = fscrypt_fname_disk_to_usr(dir, 0, 0, &encrypted_name, - &decrypted_name); - if (res < 0) - goto out; - entry.name = decrypted_name.name; - entry.len = decrypted_name.len; - } - - res = utf8_strncasecmp_folded(um, name, &entry); - /* - * In strict mode, ignore invalid names. In non-strict mode, - * fall back to treating them as opaque byte sequences. - */ - if (res < 0 && !sb_has_strict_encoding(sb)) { - res = name->len == entry.len && - memcmp(name->name, entry.name, name->len) == 0; - } else { - /* utf8_strncasecmp_folded returns 0 on match */ - res = (res == 0); - } -out: - kfree(decrypted_name.name); - return res; -} -#endif /* CONFIG_UNICODE */ - static inline int f2fs_match_name(const struct inode *dir, const struct f2fs_filename *fname, const u8 *de_name, u32 de_name_len) @@ -245,8 +193,10 @@ static inline int f2fs_match_name(const struct inode *dir, #if IS_ENABLED(CONFIG_UNICODE) if (fname->cf_name.name) - return f2fs_match_ci_name(dir, &fname->cf_name, - de_name, de_name_len); + return generic_ci_match(dir, fname->usr_fname, + &fname->cf_name, + de_name, de_name_len); + #endif f.usr_fname = fname->usr_fname; f.disk_name = fname->disk_name;