Received: by 2002:ab2:6309:0:b0:1fb:d597:ff75 with SMTP id s9csp204554lqt; Thu, 6 Jun 2024 00:36:11 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCX16CNfcryTHve5iJ7LMcyhLw4Lz49qQApnvyOWFNzO0+FBDIJoGY+y0Ozrxh8wC3nr3tTX1TbdHuqjxcaYFAUI8TTqq38iAbKz+kANqw== X-Google-Smtp-Source: AGHT+IG+6pM+m1X2FEdqFBj6lmU7duJHT/1eEd0Bgm8nLzYxQ0jn9uAbpuBrYS7Yn9DCl8tQqcge X-Received: by 2002:a05:6808:2997:b0:3c8:532a:8df3 with SMTP id 5614622812f47-3d2044def99mr4853558b6e.36.1717659371370; Thu, 06 Jun 2024 00:36:11 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1717659371; cv=pass; d=google.com; s=arc-20160816; b=Y/fGljzPTkmHTDJKazH7tgMaNnk9Wf8C2nZU2zDJbkq/3rD067aEQ0OYuALjARzoVG MdEM2Z+mRS5w0FKJIiBQaB2lNSbYJ48KsfoqkTzfW/LFDVvCjqqZXWs7oCOmXUvODdcV kzaxCOCRlZ9Y9CTwj1aHLkqM3Fu6s1bBKKyP8rKHi+x6yF126h4wFk+mda8D+3VSpdd/ MjlAJc7v+Xx/agfJuFsnOq17Xo2NpJFKBMzX7Yd6bffEy4B04FTYwYsmsXLaaHcjfMZd TPAZiC6SW28G6zvNAOBkqYWggfyas0yWhAHLMxKoM8wdZ5/jxKxrvHXOTi2iuMGyQtae PCcQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Wc1JtWOVmrB2CV32gyfScI48NCD5kZJAIHJGSX5uxbc=; fh=JvuDsSGtkczZqWhaRfigYAR3g2CTmyQpNIyLSKcTTXA=; b=LYfM16+ADnmsEO03w+ng7f2JNhr+a0/c1U7lDccOsdfOnxgh+3qgjEKQeHPBKnpwie uYjsX9lGYSOMi0Tb8qnjTUkc10CiT9YZM53FDE3p4j/bB7Hwmtpy6/Jl8t0sq13LCbml WR1jkbblG1Z9lhJvMwGL0kLxnSyvSe+OFwKC6oudYD/i22m1SI/yaSn4acy7ebcFD+Ok BIW3hbxS+33M4AE60wlh4NvBqdDU1ybwGFTNLFmD10l1eG0iouqHwcnM2nh92iCWy/1B CaNRHvVLuKVSCaPI9jtYR6J4gBbbgZ7maeQrQm1SMVhVWbYSd5ne+Os8n+TMjrEz4CjY pV6Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=upegq3a9; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-ext4+bounces-2796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-79533374c93si79269385a.650.2024.06.06.00.36.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Jun 2024 00:36:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-2796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=upegq3a9; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-ext4+bounces-2796-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-ext4+bounces-2796-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0EBD51C248B3 for ; Thu, 6 Jun 2024 07:36:11 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9FD1313E059; Thu, 6 Jun 2024 07:34:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="upegq3a9" X-Original-To: linux-ext4@vger.kernel.org Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FDBD13D8BB; Thu, 6 Jun 2024 07:34:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717659284; cv=none; b=aCBE8oMO2RqzaVMoiAxdELGTykMFizwwX9AjAQMVetpwx9EZyVUWAYR43jD0H1pO5suoQ04tbeeh4G6x1Wmns5n2RwW9WSM93u6lAB6iQy8bNpySVZqZR8DcjIHo7VXPH0fCZfggS3/+719JPOGmuA5hw4oo6k8xammN2aZgJGI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717659284; c=relaxed/simple; bh=RaApyMUGWRaAMpiSoFeoKzdLOeZPjYqhNYx85qIghjE=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=h7EcOHBRZL39qbcvquQENZxYZBblTvtK9zaMG0+LhQi6DPbiNOU2/HKuoGP6C9HGwsTJsyqLk3HWzgcJM743UWXnPlZTHofC8LtRidqYP/l9Dn6fJb9j3tFWhz2z9ZjGY3iVYzF7JMKuFzH4DNcN7P+fFJ8oKNH44pfeK+c2w5c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=upegq3a9; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1717659280; bh=RaApyMUGWRaAMpiSoFeoKzdLOeZPjYqhNYx85qIghjE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=upegq3a9Ol+hPS6YnNLyqu+fprbdFIxAsspMYkRM1xNiPz8TE9jOBXHzHmwhiOEAp UW64oTWymtKWOLMrusRDtM4Gf+rLqRC7c+D6qZaLVkSnrqDiQsltHeHnITp5tq0DP4 mX/nurRCv71/RmS1+kd5o2Hhmav1LVc29LbqXGzcTBau4I+bfXhR956VCb26XjhkdH Vdo7CEnfmouGT/nxKMnYIVfkJJwGrk6btqgLvKAnlyQ1uwR5yyMq4mcGhZr2JDnIMY k+wGj1MlU8B4U8Oj4LVhMY4D3MpPBhBSH5jaqwTFDArAhuXiOgxoVc5IctgiW4rtTm AhL0482d/76/A== 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 C03D437821E0; Thu, 6 Jun 2024 07:34:39 +0000 (UTC) From: Eugen Hristev To: linux-ext4@vger.kernel.org, linux-kernel@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, linux-fsdevel@vger.kernel.org, jaegeuk@kernel.org, adilger.kernel@dilger.ca, tytso@mit.edu Cc: chao@kernel.org, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, ebiggers@google.com, krisman@suse.de, kernel@collabora.com, Gabriel Krisman Bertazi , Eugen Hristev Subject: [PATCH v18 5/7] f2fs: Reuse generic_ci_match for ci comparisons Date: Thu, 6 Jun 2024 10:33:51 +0300 Message-Id: <20240606073353.47130-6-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240606073353.47130-1-eugen.hristev@collabora.com> References: <20240606073353.47130-1-eugen.hristev@collabora.com> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Reviewed-by: Eric Biggers --- 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 bdf980e25adb..cbd7a5e96a37 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; -- 2.34.1