From patchwork Thu Jun 6 07:33:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugen Hristev X-Patchwork-Id: 13687934 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="upegq3a9" 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-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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;