Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp303959lqs; Tue, 5 Mar 2024 02:30:51 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVXQsBGg2y9RpCoSyY734BKi6URQ09wUlx62Xa7L9N6hOFhWrcs688oDpUaWjraq59HW1TPhs8gox0PQAEN8yOHukQVHiNyyVk8B8sotg== X-Google-Smtp-Source: AGHT+IG2LLtK9JetZVW5m1iKG57iKaSo0Elc0Tz0C57jd9TcdgnZpeFszfZHuNlQ2Lhpwhsk9qJO X-Received: by 2002:a17:906:230e:b0:a44:2f23:1bdc with SMTP id l14-20020a170906230e00b00a442f231bdcmr8684377eja.26.1709634651689; Tue, 05 Mar 2024 02:30:51 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709634651; cv=pass; d=google.com; s=arc-20160816; b=qXhGIFv03UvNxn0avhlizi0bukAbn/eITPl7CuIzrXMDNTH83fckuB8f+ZZmD77BBY V2wFLazzxcu1pslgsYZXvLTkBoJ4ohIaopTWIrXIQ2iBQAAnVBdnl5BhE/UC4Giv7IrX wYusKTGaCclKYy7KSTPORwmsG88KQvuPfJTnzPXLMNjz07V4iqaje0s21sS1PZRBQ32H qvSAA6h5OhOnNOgh4cxwfaJEVz6HlH6varsE7HfqMXB/yt9s0S35CQu1dEDmsJaM1vmr DjBoocJ3wT8JASQWUOkeViGkta0xqmKborQZpY1d98WoN40ZJuWL7sxBmZ5UF74ZYMtr ox8w== 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=v+0dzV0sy23S3JlVG0gaFdQm3HwsAT2DecxYwU9I4a0=; fh=zf0NNkRrVzzNLxoWnmq9qpFBuYVKEQmjRPQIjT6JsCY=; b=Q/Cy5kWdY8TmEB6kyBOckGd+TG2lUcc9x7EavwSuoXb98QKUlH2diVCZrfsgPUaRmY RKD1cqYJTIuBVEgiK7dm6JhsSVIAaDZ/iDF1YkHCa+ngcZJqjGtOfW7o9GMOVSnlR5Xd Z64RHfU9g+BfnrQBgkgwwqkEPiMEYT4JwH9Toda17dhwnzLsvuEoQwAkzS9HJqyO6owx dV/0GbWeFmmzoI7TNEtv40eGwq4cttSNkj37aVjPSFqB3W35LT+n4d/8aqhl9FX2xHxA bEmystFgGAp+aEkzNq0llsB9MMH4vdvuZ0zqu21YRJJHBWLxu2AY3Ca5Gc+Jd7jfrx+x DCbg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SoOfuMyU; 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-1513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1513-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ld12-20020a170906f94c00b00a4306e4019dsi4726411ejb.446.2024.03.05.02.30.51 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:30:51 -0800 (PST) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=SoOfuMyU; 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-1513-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1513-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 6CA5F1F23702 for ; Tue, 5 Mar 2024 10:30:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B65AB6D1D2; Tue, 5 Mar 2024 10:16:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="SoOfuMyU" 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 B8EB667C51; Tue, 5 Mar 2024 10:16:43 +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=1709633805; cv=none; b=PrS4G8U9BYsq8wv2HNHNV9cYPyoVyYomrtsu3QomDa4ffvFv1GCHBdjadRLIEX7fUHEvQtDxUGunoQeydH2kpZyibuYnCynN/I7fz8YCKI7Ybn+0QyYMMYZ87Aloq8MMrbPRm8Kd6mb6riN+DBU5di0lzK3W3VXcL+QughZ1Hq4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709633805; c=relaxed/simple; bh=uq+NUoWh1WGcEsURkrmiWF3wZDvt1htibp16SICzIEo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=BGaMW3nXuj4AlvsaMJBSltpY/UyfAISLKL+v86Ol9Wu5S0DMiz46FLIkBg0CCORYZX/aJQg9tYspuD+hbQBf0wgYsxKcBYUOICd1dZFqI9pwwt1lYpN4ae15oe0mCyYC9hVA3TgskDQFR0wVsN8Zi+MUJD/jtWNN6BWaJ8xEAQY= 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=SoOfuMyU; 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=1709633802; bh=uq+NUoWh1WGcEsURkrmiWF3wZDvt1htibp16SICzIEo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SoOfuMyUTcGfXWHcFfmJCBGZ18SV/jtrSJEZlWit70byV2lIo1VcMzdLs177J425s IgrHTXfWXaAUXsNnTTdVt/HfoulhAj7bvdrMBz/C3St7VveU/VIEIPU+fxlMQfQ7k2 GWQFIfz6Sy9UwT5/9x9J5TbkkKImMplb227hfQSlfikn1DjxHZLcPTyd/QTatBMBVc xZv4M2cWEV3OyUaenDgwiX08Rv6po2qlEnRtKJhAAYubnFM62HYhCGyvdfzlmQMlrw WOyLDk6mnyLabEz/loOLCvJg9UqHxjjT+Z3ozep7N+1Ez3yhh8HMbKiQoYaqSrklVx e8FPTTza3GXGQ== Received: from eugen-station.domain.com (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 D538A37820C6; Tue, 5 Mar 2024 10:16:38 +0000 (UTC) From: Eugen Hristev 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 Cc: linux-kernel@vger.kernel.org, kernel@collabora.com, eugen.hristev@collabora.com, viro@zeniv.linux.org.uk, brauner@kernel.org, jack@suse.cz, krisman@suse.de, Gabriel Krisman Bertazi Subject: [PATCH v13 5/9] f2fs: Reuse generic_ci_match for ci comparisons Date: Tue, 5 Mar 2024 12:16:04 +0200 Message-Id: <20240305101608.67943-6-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240305101608.67943-1-eugen.hristev@collabora.com> References: <20240305101608.67943-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 --- 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 266279b82afc..0601b4c8bacc 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -183,58 +183,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) @@ -243,8 +191,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