Received: by 2002:a05:6358:489b:b0:bb:da1:e618 with SMTP id x27csp7250593rwn; Tue, 13 Sep 2022 17:04:07 -0700 (PDT) X-Google-Smtp-Source: AA6agR5tm9U2i+Qwz8rNJXN1w0HhpClPfX7wuy6jXGtzM3Ubpd55jdQ+KBwNCAdF1uR+dLi0N6uO X-Received: by 2002:a17:907:a0c6:b0:77d:7ad3:d05f with SMTP id hw6-20020a170907a0c600b0077d7ad3d05fmr8496869ejc.734.1663113847272; Tue, 13 Sep 2022 17:04:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663113847; cv=none; d=google.com; s=arc-20160816; b=DuGSpGQcFrHGM8aCiBnQ558zVIbdCJFmwJKePXpngMGUtE+/gnrn/ovkQ15p/Z3mik b7jVTDmqiWvfV3Kyjtj+hXSFogtpBwNrrDVMpPJf0FgtNKGz8k6QE74a+Yw01NlPD8o6 EdiB+lc5Yd8FFkID+SAYquHMOHxENa6BFTsfdLyGmYl5fmvjOH0QJWhSmUPmtoRO3RMw czeB3caO7fUBGgNmPTmeghgIDh5cVs8OKvjkrB0qXEwPt4CYh56ySXM8/++4bHWRDjEZ VCH6S8zKgT/Hs/zALtM1CJZipDILJWvEAkQNh1anlpb7z8a7luhrv2cLWcdXuC5Y2Uoh VXgQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=IthQB+mtGuM5QYdAz0buDSFRWXH53Zpia5+kSOJXueQ=; b=AODbxqO8ADC+YbUmKckuetW1B5tVavx9v7O3xqPeR83tMKsJ8yyroY+XcJYOEW9OJS kIx8OwPqBh8JstvtJbGSWZHCiSDoffoM2Vhk9zmk06xaLXuRRegcMr3H9R3VPniYlixU BIIkvG13do3OJsjNYmXbs500I+xvgPuJjV0FIw3/zIOLmEOUlp78AEnFJ4xFDFvkPoEC YkIfAFuD8zzpeKu+CBMXSUUZQE9e0GmZWod8c3bTIf+8sqLII97fcArHpTz2gqTXaPZG BnOaWsLuoxyb6v9VFCa7qP/tMLZnukn82+jjqdVX1R9h4vByvYJD1cQ8KuwMO0NRHIwH y/3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=L9oBiu9V; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id du18-20020a17090772d200b007315809ec84si12066017ejc.398.2022.09.13.17.03.42; Tue, 13 Sep 2022 17:04:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=L9oBiu9V; spf=pass (google.com: domain of linux-ext4-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-ext4-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbiIMXmZ (ORCPT + 99 others); Tue, 13 Sep 2022 19:42:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35190 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229607AbiIMXmV (ORCPT ); Tue, 13 Sep 2022 19:42:21 -0400 Received: from madras.collabora.co.uk (madras.collabora.co.uk [46.235.227.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 84BAE3F1FA for ; Tue, 13 Sep 2022 16:42:20 -0700 (PDT) Received: from localhost (modemcable141.102-20-96.mc.videotron.ca [96.20.102.141]) (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: krisman) by madras.collabora.co.uk (Postfix) with ESMTPSA id 2E826660201D; Wed, 14 Sep 2022 00:42:19 +0100 (BST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1663112539; bh=faqmgQTGUmRIw+3ntvGWmd2h/vTEsHbxKjStw+7u9dI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=L9oBiu9VSRpXLsF5E+Ed1qRiI5VHFd7Q0ILfzK7TE1D/BeyubpPhS+7O6/DwpdLX6 9sFUlnJiAB/QJ/3ER0EZ5Qtx2tVlBuzOs8AhMnQOrwHoC3Iu+ZWOdpU7+xAgLuu+XG XZ4tXJzrIySQ6Q8nXKjrjZ6iIh79YdNe6cpwukIYFrGLjzLQ0Eg33aSUB4+yd6KfZ+ X3GYB6X1ZY8WJMriZ94BnphSzkN/y9WR6mH+aM8Sh0A296LAKRFOGyuSH+9Tb+2AzN wiV9L3zn1WaKtA/umjXzAgmnhzq+2vkzJwSNUaf0nN8AuqFioAqdt9aNu6uobyq/Z2 TClDgBeZY5SmQ== From: Gabriel Krisman Bertazi To: tytso@mit.edu, adilger.kernel@dilger.ca, jaegeuk@kernel.org, ebiggers@kernel.org Cc: linux-ext4@vger.kernel.org, linux-f2fs-devel@lists.sourceforge.net, Gabriel Krisman Bertazi , kernel@collabora.com, Chao Yu , Eric Biggers Subject: [PATCH v9 5/8] f2fs: Reuse generic_ci_match for ci comparisons Date: Tue, 13 Sep 2022 19:41:47 -0400 Message-Id: <20220913234150.513075-6-krisman@collabora.com> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20220913234150.513075-1-krisman@collabora.com> References: <20220913234150.513075-1-krisman@collabora.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-ext4@vger.kernel.org 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 --- Changes since v3: - Drop cast (eric) - fix unused variable iff !CONFIG_UNICODE (lkp) --- 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 98db333a1338..bce3727de3c9 100644 --- a/fs/f2fs/dir.c +++ b/fs/f2fs/dir.c @@ -218,58 +218,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) @@ -278,8 +226,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.37.3