From patchwork Wed Mar 20 08:46:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13597531 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 3ED0AC54E67 for ; Wed, 20 Mar 2024 08:47:00 +0000 (UTC) Received: from [127.0.0.1] (helo=sfs-ml-1.v29.lw.sourceforge.com) by sfs-ml-1.v29.lw.sourceforge.com with esmtp (Exim 4.95) (envelope-from ) id 1rmrb9-0005SW-JG; Wed, 20 Mar 2024 08:46:59 +0000 Received: from [172.30.20.202] (helo=mx.sourceforge.net) by sfs-ml-1.v29.lw.sourceforge.com with esmtps (TLS1.2) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.95) (envelope-from ) id 1rmrb6-0005Rg-Uw for linux-f2fs-devel@lists.sourceforge.net; Wed, 20 Mar 2024 08:46:57 +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=v6ftTbHgM12Ej1CbNqOgSSzmFGHNiHfAt1+ZNwLLF+c=; b=L4fNawgl2SvfvdNoIe+rxRHdWF xfnxHIjQiSFnMHoPHT0HDNJUVqYzFKzLLfsg9LYe9T68/EJnecFYuN3B3KPqUiuCxNgHKk+VifnaG 2vovD0k1fkJu5ee+VQCOYwpEw5V9mjpkyTg6iJCm+oqRlMvyHoTtZ4YI/vRhJpUEameI=; 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=v6ftTbHgM12Ej1CbNqOgSSzmFGHNiHfAt1+ZNwLLF+c=; b=EcVXQ2cTW4tWdOpBPuuWko60Jq ABz0wFTZU7KwNYazhKjikByFClBzcMVH/1l5Ozwzsa6urwXfq9xvK+XmmhePL7vcCHN3JVdnN/wJ/ SFPAAs4PKzJmJGW2xs6mgaSL+6Q890RaGztjWfut1E2LzXh5NcXLpqiwFYNL02xyeauo=; 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 1rmray-0007dy-R2 for linux-f2fs-devel@lists.sourceforge.net; Wed, 20 Mar 2024 08:46:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1710924405; bh=aRA2g6rcldGcm0eggJ+qgCaUO+InE396o0stDobGMYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=k+LLYn/3MpX7d9pDJViQCEbDLW/2QCcV1fn32DUGD7HoeDENZKW+jpXLkXjIo9wmt tuD7VPv85Ya5lP78jxBVdpa1/MBf9SYIh0SPhgzP71NkDPVIXb3gMOtcgHYJGmaNRW 6zqGDVhsRrzkxYwpVNemaGYCbM4pas8pJSrxrHsTx1icvpjg/hKWeHYGPS0GYzE2Se S9qWqDa0VXvXXFYGDZkT/I9H4xmI4O74QvNlvfylOKbqYGZhvlFZGuBMjP1kemoJGG GCq5viYvwAF+lz6tdcpdcgPUb6n7FxwoAaVnHKVtJips1oaImv9LOk8FurWuixPtj/ NHxh/NrW8rRJA== 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 8CBDF3782111; Wed, 20 Mar 2024 08:46:42 +0000 (UTC) To: tytso@mit.edu, adilger.kernel@dilger.ca, linux-ext4@vger.kernel.org, jaegeuk@kernel.org, chao@kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org Date: Wed, 20 Mar 2024 10:46:18 +0200 Message-Id: <20240320084622.46643-6-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240320084622.46643-1-eugen.hristev@collabora.com> References: <20240320084622.46643-1-eugen.hristev@collabora.com> MIME-Version: 1.0 X-Headers-End: 1rmray-0007dy-R2 Subject: [f2fs-dev] [PATCH v14 5/9] 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: krisman@suse.de, brauner@kernel.org, jack@suse.cz, linux-kernel@vger.kernel.org, eugen.hristev@collabora.com, viro@zeniv.linux.org.uk, 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. 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 3b454f355f15..88b0045d0c4f 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;