Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp2159637lqz; Tue, 2 Apr 2024 08:50:33 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVi/CTdDUzzHbpgzbHhMz6thJBagzzhKG4c3vAQJUk3bKiPNeEjY+gnN9wm/ps5d03amIu86TCDM69Rxc+n7apQhfsYk7AEnukPZ704xg== X-Google-Smtp-Source: AGHT+IEwKpK0N5jI5dpJWkTdbAWrW6SvaCOHT/v/WWH2MljUnrMCyhFkK0m2Fz2WDY++71KitcYu X-Received: by 2002:a17:90a:d718:b0:2a0:b6f:371b with SMTP id y24-20020a17090ad71800b002a00b6f371bmr8930137pju.24.1712073032953; Tue, 02 Apr 2024 08:50:32 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712073032; cv=pass; d=google.com; s=arc-20160816; b=lyEm3L/wOJ+nqOnXGHhZmaR49dTHgWphhuqouTqW8D/L8wyX8n8KHYS8yYk5J5ski5 PAQ4//k3eArWBkIC0y8URFsH0LHQKbh+Td6sWl6imP/Ow8D2CBnDPfpP+ee6/1Wi1uPU cfe2X40eQzNQNxOugF8r4kSNCnzROAHfUzT5s6j2PLpefCGg2Q82N1TNEOtMcNkNpzTQ clmvyaq8Vi/+KxMChFUh9fs9gXvTPblJ7Mx54WVmQ2rypZJ8gXfli5VG2mBcQFusrmFb FVdlCovnHW7cFL88aA9DlP6yUImeA14N3Ppl3SKib3wBP1W+0UWKD9tf9K08VcY+n9i9 jiRg== 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=v6ftTbHgM12Ej1CbNqOgSSzmFGHNiHfAt1+ZNwLLF+c=; fh=zf0NNkRrVzzNLxoWnmq9qpFBuYVKEQmjRPQIjT6JsCY=; b=xrwpiihvtqdyNMUZKE4quLn0O2w6ObqXIy6tZI3uAWSACBuHt3GyMyakgTETdcfNpi UCPmH6nuk2UD7KWq6oJFGANsdYdX7qJ59b6xBRBwFca6PM7hfrAIMieeY83X6QaP9ocv juzz4lNbUIYHTFpw443nhw7KNlIBKYt3qrgUTqR7phgGezRmUntxELgmullPsJMRAJqB u0GhdAm1bPKGjVW7hZZLCNgRNastCrql2WCjnHA5nZdPoCPRDf+Bbws6Dn4mm7crwZZZ LmQPAV/axffgHWEGdko73iHitcn+PRhSio7gbY5cBb9zoYzecW0FIXzGNUtVCUtxoldc YM5Q==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=0HtEHEh2; 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-1830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1830-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id ie18-20020a17090b401200b0029f6cdabc68si11382990pjb.84.2024.04.02.08.50.32 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 08:50:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-ext4+bounces-1830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=0HtEHEh2; 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-1830-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-ext4+bounces-1830-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 9AF1828D17B for ; Tue, 2 Apr 2024 15:50:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4FC5C136669; Tue, 2 Apr 2024 15:48:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="0HtEHEh2" 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 EE8071350DA; Tue, 2 Apr 2024 15:48:55 +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=1712072937; cv=none; b=ClW3BRGteC9DPEG6G5KLuAOuJkb2v0gE781IrWwpzMxIwLmcCQVQ0Ufw5wBxIxFUEfn13UYIcpIzkXVYnmnyQO8lkVO+iYa7Vjcf13qEaBxlAAWm/tDFlom8l3zW+mQQd2aZEdsfzJ14v/inIIzvHDloxa6cvjD5KpKh43MMXkk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712072937; c=relaxed/simple; bh=aRA2g6rcldGcm0eggJ+qgCaUO+InE396o0stDobGMYQ=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=V+VZdqDvCrM22eIQcOvEfOzGDNMykTVx4BDxfkXqfXoLS34/9mTnIFfNf7cOHVN/7z29q3y4A1aMP+csaPQHrEgt3fsLT7qz00vbcikRYQMPZJsK3+qi+i0J3KIAkCVJR2jW5471YN7TFEMe6tgZYCJsyYxm6Cy+I20avYWQ+3M= 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=0HtEHEh2; 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=1712072934; bh=aRA2g6rcldGcm0eggJ+qgCaUO+InE396o0stDobGMYQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=0HtEHEh2LR1L9DM73x3tqIb7Au5sPOcfokP5b64dXKxo5yl8RrHVlc6u5I4lW7Hjb 9EL1C5E5ehXcKa81hZl4JYADNGrmAwS7m/z+Xtkf0x/u6ig8fzKhjwzuKOmrf86/UM zygR/A/XXsOsOkkrJHR+cxTm9Ne9XL6W6feL9MkK2tlTzqH51j55tTmMaoxYzBWMNx /i1gLsJr4ZAgbwxf4m2yDHYcINZNMcH+dCJbHV5fcDXD40MMA8mpqU9QOILo6BNfZk 9yzjP5vjtSOIT7MA3lfhwtmLk6XDUyGqQURzOCfQOlLBA1c9oUBk1FSVCBWkSp8RdJ 7zC9Ogq+QvkbQ== 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 86AF837820F8; Tue, 2 Apr 2024 15:48:53 +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 v15 5/9] f2fs: Reuse generic_ci_match for ci comparisons Date: Tue, 2 Apr 2024 18:48:38 +0300 Message-Id: <20240402154842.508032-6-eugen.hristev@collabora.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240402154842.508032-1-eugen.hristev@collabora.com> References: <20240402154842.508032-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 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; -- 2.34.1