From patchwork Thu Sep 5 19:02:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792873 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2DDACE7A89 for ; Thu, 5 Sep 2024 19:03:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C1C836B0083; Thu, 5 Sep 2024 15:03:25 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BCCC86B0088; Thu, 5 Sep 2024 15:03:25 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A93FD6B0089; Thu, 5 Sep 2024 15:03:25 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id 8D2F66B0083 for ; Thu, 5 Sep 2024 15:03:25 -0400 (EDT) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id 51018120A16 for ; Thu, 5 Sep 2024 19:03:25 +0000 (UTC) X-FDA: 82531607970.30.79458C1 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf21.hostedemail.com (Postfix) with ESMTP id F16B61C0024 for ; Thu, 5 Sep 2024 19:03:21 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=llqAOrn8; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf21.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562930; a=rsa-sha256; cv=none; b=bGON04erF0Hmzcw2Q2+7KLCkA2J2Cq1RyFG21M5WDh/hJlUsgcj8J1LNJTCz2+X3dL4nz0 3JxbsN55rCTRmHXSZXhN1X/OKOkrDsW9jCB01zfmpzqqwNJ9YlZ5N0d8jnVKgh7LEUUBMX q2gy2OzoCIamvpZ+qZaAocQzf3dIADA= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=llqAOrn8; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf21.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562930; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=h3G2XLqID4r09rjc35sdSginc1+HQQOMXWwkAOpIqMQ=; b=MT3aBod2Ui3I1CJPJ8WuGt8zRwO0CfJXJ8wLYqeTzpg0bPNauuHjRcLgYhm90Nm0wNjJu3 lIUpdewE0bRrjfyuqWNwuupr6bStfgqnrlgs00KvEVCbtF4PyOYLpDJYmwvXsVM4Nzdy9C qD1jadwzM+ALNdvc2Vw8pbGatfFEK1I= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=h3G2XLqID4r09rjc35sdSginc1+HQQOMXWwkAOpIqMQ=; b=llqAOrn8aL/qw69Wg5Ra8y+wWf JLvgMbLeG3fwUBfMqFMmxHUELEAwb/yKdLG0s7cwIM5u4hZ13DlnJ3Ne/o4dwd9YZRgmgi2JzUx0+ mKs2y/95FRbJkp4LA8WSU3G0MbiWhpFC2f6L2xY58X8km4ymyWjgVdTf3u9W/Cq0WqxPpS3GocjmJ 8eCWm9E5alS7ndthRRXK2xtzcPfSC3WqQKLufJAK9sr/4gOlF7irUB142rbeNm/5YK4zMYdHz1kPP C9UA87nr22EpbXDm1BhI1GM4C1oTQZLhwaxqOIlqOMDyLfo3ZL6DtOZeLTSzJfra76MOjXt/5CRiI wQid+hrQ==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlB-00A6Ho-3O; Thu, 05 Sep 2024 21:03:12 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v3 1/9] libfs: Create the helper function generic_ci_validate_strict_name() Date: Thu, 5 Sep 2024 16:02:44 -0300 Message-ID: <20240905190252.461639-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: F16B61C0024 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: f7r5xyhegmws55qgm9e8q3grtwsfoc3k X-HE-Tag: 1725563001-718831 X-HE-Meta: U2FsdGVkX184ejY3wvMIK5YB+XvhZUTWs8HSMyaWB1Kt8QoMx8BPkbUd/Q7Jk2IXBPHKxJoa21bT6dBKyjHP5TN9Z5UXk9jH+ak3IhLGf/A3MNmUBwK22xzbPm/kelLGs0QclAR8OJ4SkbwQXwkKIa0Jr/6w2+0+jZLM9c3iK69abqq2b3s0zufh46wdKMAXfPAQ2IaUoOm6vlmWKLLWyv3i1G7hMiX3ibI3XXpzpGvco1uQe3P2qiq2NzVBStRJSqkm50oAmV2Tf2OCftltBePBcZWok6NwKWjuCsKOXMc9QSuA2iO3Xaa37YPqRcHBB/SLxdNh2DgG1wlAYV3U4Xfi5aem1LqdA3frozo5wWnngpzYqYvvrUhneXUmzw/LDsKI4ddKL1m9fox2AeDT0+5owbhP40Om6WWnReAXgWnUbZL+HNOymEyh+JFczpQemADPPm8uOJjvAbXX3hmqEuRFgTpHvlNTG4brKVpPWEyhbzlw07IfT9TGan4C0tAguAoHPTsJQLJpyLl+7s/aXMNWvndGlO5DaIxr2/nLqmLAFUJUc/0gvn5d0DgLMl4tvK8e+WEJVh1WWBPmb32svBhd9xSLxjD/jJPGIqdyzW1tdg/Xti0J0jkp7pTg//nojKpe8dzpd0d1apDa6ivD9+yX0pwT/L71D1RlGl4eCVeQy3nsCn2FjG+KAnVw0TqQ3PYj/QJwgBQ123jBqE8dTxNMlAYsTzJRrqJypw4PqPffEe8PElEoKHJ+l1uf95mHkQzCnd7rFUzUdK9L9mTzKh1xxdc8S1PzwupHOoFlZ1WkFHGZk0xc2b5uqygbqmgBsWy3hbPqYvIVUxZCM0gyz/6e9ZTtezjJz5scmhgcTNXBrp4skv/Mk1fgqcpx+8ljwLncavGWHvFmxoPVmqWePhjZJdxo3EEryKmQ57DhsAc/C4q3y8PIWlj5ZLQOFuF4/TSsrLKN7RqmFs24yEP mWvO02Zj /3JXw30aps0qEpFG91cp392N/qB05nlAs2GRjALKhixeBUbxUHmuuAIb4TPKTsYpxbSaq6+ugWT5Xh8AtqBQdYjzuoyrRJmWDZ5odZUGzDtSJHxYpS0aBuui7VlZwUvPGEtXnVsceCLLMDbRFtHkj0Ii/PlbDftPwNRzCv2Ym2x/bnWiMH/BoX/V3BunC3pFXNXV2SoVLUnMVCixmlMQS1bFhuTS42LJT8VLjLeDqfJUWwqTevFtGWwoBswbDF84oIDYo1DQeQTEvAxeNGRP3fdrPAqSHvUgSrfvCJzJ+KGc/E95pZreo+SEzUEj5hfNR6xMTkGN6VHJV31sxifVNFjTUP0/2FqCRQYYA37R+JKZrQh+WFHY3PamiU/NvqiJexS4n X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Create a helper function for filesystems do the checks required for casefold directories and strict encoding. Suggested-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida --- Changes from v2: - Moved function to libfs and adpated its name - Wrapped at 72 chars column - Decomposed the big if (...) to be more clear --- fs/libfs.c | 38 ++++++++++++++++++++++++++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 39 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 8aa34870449f..99fb36b48708 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1928,6 +1928,44 @@ int generic_ci_match(const struct inode *parent, return !res; } EXPORT_SYMBOL(generic_ci_match); + +/** + * generic_ci_validate_strict_name - Check if a given name is suitable + * for a directory + * + * This functions checks if the proposed filename is valid for the + * parent directory. That means that only valid UTF-8 filenames will be + * accepted for casefold directories from filesystems created with the + * strict encoding flag. That also means that any name will be + * accepted for directories that doesn't have casefold enabled, or + * aren't being strict with the encoding. + * + * @dir: inode of the directory where the new file will be created + * @name: name of the new file + * + * Return: + * * True if the filename is suitable for this directory. It can be + * true if a given name is not suitable for a strict encoding + * directory, but the directory being used isn't strict + * * False if the filename isn't suitable for this directory. This only + * happens when a directory is casefolded and the filesystem is strict + * about its encoding. + */ +bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name) +{ + if (!IS_CASEFOLDED(dir) || !sb_has_strict_encoding(dir->i_sb)) + return true; + + /* + * A casefold dir must have a encoding set, unless the filesystem + * is corrupted + */ + if (WARN_ON_ONCE(!dir->i_sb->s_encoding)) + return true; + + return utf8_validate(dir->i_sb->s_encoding, name); +} +EXPORT_SYMBOL(generic_ci_validate_strict_name); #endif #ifdef CONFIG_FS_ENCRYPTION diff --git a/include/linux/fs.h b/include/linux/fs.h index fd34b5755c0b..937142950dfe 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3385,6 +3385,7 @@ extern int generic_ci_match(const struct inode *parent, const struct qstr *name, const struct qstr *folded_name, const u8 *de_name, u32 de_name_len); +bool generic_ci_validate_strict_name(struct inode *dir, struct qstr *name); static inline bool sb_has_encoding(const struct super_block *sb) { From patchwork Thu Sep 5 19:02:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792874 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 25210CD5BB8 for ; Thu, 5 Sep 2024 19:03:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 31DCE6B0089; Thu, 5 Sep 2024 15:03:28 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 258826B008A; Thu, 5 Sep 2024 15:03:28 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 035486B008C; Thu, 5 Sep 2024 15:03:27 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id CB3326B0089 for ; Thu, 5 Sep 2024 15:03:27 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7F5A91409DB for ; Thu, 5 Sep 2024 19:03:27 +0000 (UTC) X-FDA: 82531608054.07.BCEB9B0 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf15.hostedemail.com (Postfix) with ESMTP id CEE6FA0002 for ; Thu, 5 Sep 2024 19:03:25 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=k+yEejC8; spf=pass (imf15.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562876; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=kxZabVtRIbsH5N40Gr/wp92cNKF1pfI7iuz0Er/EL18=; b=gTF5K7aEwJ5o5+2BMSh6u23zf5QoKZXkxwmD4t98Sg56wQZylwrruDT8c7VIbsFxaxzw8F JZOB7G+hO9ze2m7XSNMogYW3fwwH7DyMaltgKclz14p32niBiug1ia9w4+mWrCdbNOsyYo q9X2uZAbd+a4+hcCZm3c6q8SPwK853E= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=k+yEejC8; spf=pass (imf15.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562876; a=rsa-sha256; cv=none; b=j1zDZUkhfU6L7c8KRk38K36GsaQoYmNNn33DxfpnGimwZrF7NEa60lCBmydhRJtaAR96jn 2jzHxa2c9Tb8236NGd5RVPWw/pjQiEMrf+0rUYZJoeOWhSjF3mAQYKFUsy7jcQom2fr54q mVy4pA8H2GLOkg47jBksv0lmTGaBGCU= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=kxZabVtRIbsH5N40Gr/wp92cNKF1pfI7iuz0Er/EL18=; b=k+yEejC8Dmzzln9UhjVHcqVDCI U7faXjakSc/T/yJDWuATyjA6gekduJAOI1X9dqJVLke+YO2Cei9IR3XGwRAEXF1dJdJqQMqnJSqj4 IoNo7I8bJ+bp9s7CnWz8r9cyeOKWbx3NxipIJBcCURjTwl0so8rsLAMokS2bfXijHvkhlpGhxcohD XRp2OljVJlDaM+jjAi3iXWk/ZOTML8RaKnJevj+8BuxAxAJA0u+TzHHrUUxANXsbhBe9CHTMXBpiQ GtPqMmi+2k5jXIQ2N+u25g8aOBRov4Va8z+FkguqaHqHipidIdrHf6w+TEC1BV5cjahvsll5aES/2 YbosNfjw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlF-00A6Ho-GC; Thu, 05 Sep 2024 21:03:17 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v3 2/9] ext4: Use generic_ci_validate_strict_name helper Date: Thu, 5 Sep 2024 16:02:45 -0300 Message-ID: <20240905190252.461639-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: CEE6FA0002 X-Stat-Signature: dmudsi6swi1fat3t7pfdms397h6jk9m3 X-Rspam-User: X-HE-Tag: 1725563005-650664 X-HE-Meta: U2FsdGVkX19IqRfpmI5CUOfqR4eXPH64oA/jJ/MA2hufMnrzCFZKKzUnZxw3IibSwwyWHMSzUV2g1xebSbXIPSxhKNh6lJwulnrOUPFITZY4Thix7saAtYCN219V9/OXkKIlR7T0+1Prq0tbKMHv8KES/POes147yD6hAFxQd5w4jpTETonp/ZnTx+ZuKoOTfr3c1dxrXYgh0oa1IcWXcsQtRDyy8+NR43Gdtix2M9YkypMdf7Is+woO6hp6Mhv02KLoBmykhto1kAZbmuFH0d4En9MBDkn1iM1M7AfUBe1Ri+RmlPWhBQmviCgb3Ikb2iCBoUMNPbQ2YHrYcFCgI+TOxI2WUu7eKG1sifMuPIFaeADuQtXILGhyytwF/eSWiYht38ltXhaN3EtPmbLtT55pWnV0/kBCUYQP/AH6veXJMnX5DLkt2oQjdVHN8ehbXXG60vBb35VOHRyQYPGz5OzAIwRhQ4KvV/Uqw0smfGqXdYxU3WJ+kGYoLdpuItvW8mdwvmrBCyA4ayNtZL1d3S8TasxZ0ftwBiwRFG2wZLFnel6W7tDo9z6UrNvXGIBlbaFRJ56cRIOvcX2KuLdCQzCRSY0TFRnJzctTytldSHQpNM8dPDhi/M/b56hMvrIuU8decVWl2JV9pdkdRzYLE1kHn2UfuXfd02PJCskIGkpkAkWmQIisOSHmBECtWKZ4AnLb/6XDMaXd0dpijeTGoHaPEzwbyy3GxnMR2GUB3lApXRtegEH83DssshnAfWQuKTmg2cB9tOpzZgLGjsBb7GK8GNA/6rZucxg9JfTlau4Vo2WoL3fTzdnxvdnLJicqwOCRn4OLN6vA8GYt+vmMGyAWoifOlDr7GmScsZkocbFj6OGc3UrBOzgNafLO2eiriLzx1s/tG8J3qKBY7fnAJm2dcEJ8ctPGcs5aicJYX11QliKW2rWMHUqPjZij1/+hJkxCY1rovXdCbjGnz9N L0nBhBk8 pph4cvaHjw96DT8IBHJg3iA7N/yXdD64bqxqQVHzoOKM/z9MRCng2LTxCretCs4WSASWPB98oWA0KS5Z/YYyLKRVo3DJsEr6jNEM70DK0LWax6jC8I6Ncgn3w03ETq7LBYd0WhfzUOsdqnBqFlvSvJwCb+yOH/aUwsCzc/soUfmvUoFzr3ByOKgG5sYvReP1S6L9pb8GA5fubbgIcc7T7eDCdC/p2GGC95Gk42J8RuzbwJRXVC8cNNJ+YpTt5gs54SV5Z0cW/sgtVVEvyJ0jHqhaFLE7CxjW5yC24Z71A8pMYoHYwmxfudRlzrSDNJWTvEvzuXL9Q7RYPyVkVTmDUjHVZqlIGyroYoQYOsrBImyF+Bh5EoZcwukd2enUDCJqiqihp X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Use the helper function to check the requirements for casefold directories using strict encoding. Suggested-by: Gabriel Krisman Bertazi Signed-off-by: André Almeida Acked-by: Theodore Ts'o --- fs/ext4/namei.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/fs/ext4/namei.c b/fs/ext4/namei.c index 6a95713f9193..beca80e70b0c 100644 --- a/fs/ext4/namei.c +++ b/fs/ext4/namei.c @@ -2394,8 +2394,7 @@ static int ext4_add_entry(handle_t *handle, struct dentry *dentry, return -ENOKEY; #if IS_ENABLED(CONFIG_UNICODE) - if (sb_has_strict_encoding(sb) && IS_CASEFOLDED(dir) && - utf8_validate(sb->s_encoding, &dentry->d_name)) + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) return -EINVAL; #endif From patchwork Thu Sep 5 19:02:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792875 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0AB1FCE7A81 for ; Thu, 5 Sep 2024 19:03:33 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id B5DA86B008A; Thu, 5 Sep 2024 15:03:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id AC76F6B008C; Thu, 5 Sep 2024 15:03:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 8E9546B0092; Thu, 5 Sep 2024 15:03:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 69FAA6B008A for ; Thu, 5 Sep 2024 15:03:31 -0400 (EDT) Received: from smtpin17.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 27587A0A00 for ; Thu, 5 Sep 2024 19:03:31 +0000 (UTC) X-FDA: 82531608222.17.132C813 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf27.hostedemail.com (Postfix) with ESMTP id 7003F4001B for ; Thu, 5 Sep 2024 19:03:29 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TcaijmN4; spf=pass (imf27.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562913; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=tVBWjPD7yJZ2Jv4Hj8dGRTMW1PUSv84Vy9Hq+Ex8cOI=; b=tYV4+B9SlCty9V3/tlqPjbKsngcGT2d3e+nKGCtY6o/TAzjFECfdGSaTmd5F6JmIRcnc8F wOEdK2yKcErgpJe0AB6dbZhA+21k6lv9YvSArvkmaW5InzAwrVdGwcurlB/B6fi9BPnaW+ 2mgvbo6k9NLIct5VyZH1nm5WIiQpE3M= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562913; a=rsa-sha256; cv=none; b=uLBJF/toWAqP7NnWB6Lgg6BdOLzrIvidxYRGUcIsSCxfnmFfn5ds2ZD/ZL5jVwK+OXBqZt n974E3Huo8I2ZbXQu6rY+9kl2GTYLc4mA1Qtcd06Aht3eebD31m/jkAbLCipNPecdY0wFI ox4Hnh5pCue52rBmcbEk2RS0ri3YfHA= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=TcaijmN4; spf=pass (imf27.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=tVBWjPD7yJZ2Jv4Hj8dGRTMW1PUSv84Vy9Hq+Ex8cOI=; b=TcaijmN4jyzvbsdVRqO6qPj+vY OPY5Nf7mWWGvh5fEp3M1mdqp/qR9GBJ12dJNPwHFu4XeYq99FxVYg1TpbZcwlhAUdHcFclOQsqWRD HHCcoITUOXgtdWO+WY4nw+67HVcOpJ2P75SXw/yrbFKwN6xJpKmVTHwKQ4/J13LaQBOF699W3Z8ea N6Sne7+xlLjSgWx9A30JetvaDwJZKcSJ1KlGdQkMyuab2UpQzB9L377G4YTy/sxoNXUvZBQddlIA0 NS06H3r8a9FEIMmAXbYaWkk6fbbnFkEZ41HJX4vodT6lpixEyfuF+KXMg7pXZQ91WxIqyzOkUZOdk zvTcfYNw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlJ-00A6Ho-Lf; Thu, 05 Sep 2024 21:03:21 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 3/9] unicode: Recreate utf8_parse_version() Date: Thu, 5 Sep 2024 16:02:46 -0300 Message-ID: <20240905190252.461639-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 7003F4001B X-Stat-Signature: ts7twnmhexdahq5yjp9no4dq3bca4g5n X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725563009-495396 X-HE-Meta: U2FsdGVkX1+83JCgVY/JMIuL26nHlLRgPYbku7M8fjVIyvu+R3rtEF5Sua2hSVNdwryRK3dMUoaoCyuP50buSTEKzo3a5M0dJPcfddnMHpZaWCJyB/Pvi/hb2yzDTLfT+V8vmzixPGmkuMrZOQMbWo6gS9LrZJtlc1hLwmEaOLSBDIncxfLFh3DzH++VbJCHwvO1kmN8EkN8eepXQwQDJkrBwrKrFPC5PLXspxENBx9EhHKC9Std+LwjghPgVsFK04PwzBmm2/iCaB8zUB9hjVllN1o/wfMZ4T4+Wh1PeUhiPSHWCQtbzT8sToAi9k1YDaO47eXdnB/pHUVL3lLcE9bGJnhGUCENTWYqMkPpHMCsermlRZVyQLjMVhvzsXy7bCHCiCJo0HTzfu/hnVXeLC+mmolr6FVu9v4HKTO/r1JFEedPgyGQWLn8D7TY2w9qsUimrloRJZ4TGcA76+eOqlwOV41lxzm0VvVKgb/sMbhIYg0IiXaVJOkgmDGjWCVnB4UvzqzcQMG1XODyISYzo359snxsZpaQKkuGe6qXBspdoObZWqUD8CVIc0VG7KgihKCnXLxTB6y8CVUgV54Ev+dmtY5Xbf95PqHsvHHZOC5SIgaAqQdslQmRhHNHnG+qTeIWFKDgn6qn9bTUGZt/Q6VzdRCvPAQhwsAtLZiKqjddIc17iP5zSMWX1KvPKpXq3cN7RZNcWI4HWLBOpOBLtTmgbzmhfN6tO7NNRk08vOLHWpHg3CVZMAYTESmZ9sfzdnM6yUebPXQ5jZ6zQOH487Tq81mnSQxR6jQrvvba/pXfxfvPHc9NTUECEqyDc+UwmNakGSi6LfBLCA+cxZbCWtfO6LKd29DPJJ6xgxL+5ZibHItD8ijDVOkhLhfEKpXy4qwqNiorjs2BPI4hrZAOsTfqDIj50nAyZ+ACrjVZqXREmndsocnlmIdWNhdauzwCOoS+RO1bT4+XpqbXi46 L7pvOTzT hjr6K/c4J/k8MsTYKC2sWplQPA+MpybN89obNg6edLjn1aa5LFhIPMrZIcX1dwPydZYx7l4YsMjSFH2eVPfeQgU1i68MwFKN/GBaKuM/lG5X/kqm9s0/WlYLh+rJcoboG3wjIsJbJogDRC+BvVHfNxnA5wgNP5/Ypicyaai6zMNTf5BqC+jdDzcptuhk2MZNpf0po3+eJ3GSZtmyqvaiBErEQQUAy6sOqBjHg6eA6Ok5AGBvJO4aYFLfDyunoohHRDFrUBDbnrbJlyWbxcWuQxvDgfsNPJ0IKkcTsuAxjnRT6zOzaMCKZr5ovQJRYkfrW9ulnz7fNJJRAf5JYPmZnHQ6aQRGi/8qBM8mNiRI7V9HEjnE= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: All filesystems that currently support UTF-8 casefold can fetch the UTF-8 version from the filesystem metadata stored on disk. They can get the data stored and directly match it to a integer, so they can skip the string parsing step, which motivated the removal of this function in the first place. However, for tmpfs, the only way to tell the kernel which UTF-8 version we are about to use is via mount options, using a string. Re-introduce utf8_parse_version() to be used by tmpfs. This version differs from the original by skipping the intermediate step of copying the version string to an auxiliary string before calling match_token(). This versions calls match_token() in the argument string. utf8_parse_version() was created by 9d53690f0d4 ("unicode: implement higher level API for string handling") and later removed by 49bd03cc7e9 ("unicode: pass a UNICODE_AGE() tripple to utf8_load"). Signed-off-by: André Almeida Reviewed-by: Theodore Ts'o --- fs/unicode/utf8-core.c | 29 +++++++++++++++++++++++++++++ include/linux/unicode.h | 3 +++ 2 files changed, 32 insertions(+) diff --git a/fs/unicode/utf8-core.c b/fs/unicode/utf8-core.c index 0400824ef493..2e852075c6d8 100644 --- a/fs/unicode/utf8-core.c +++ b/fs/unicode/utf8-core.c @@ -214,3 +214,32 @@ void utf8_unload(struct unicode_map *um) } EXPORT_SYMBOL(utf8_unload); +/** + * utf8_parse_version - Parse a UTF-8 version number from a string + * + * @version: input string + * @maj: output major version number + * @min: output minor version number + * @rev: output minor revision number + * + * Returns 0 on success, negative code on error + */ +int utf8_parse_version(char *version, unsigned int *maj, + unsigned int *min, unsigned int *rev) +{ + substring_t args[3]; + static const struct match_token token[] = { + {1, "%d.%d.%d"}, + {0, NULL} + }; + + if (match_token(version, token, args) != 1) + return -EINVAL; + + if (match_int(&args[0], maj) || match_int(&args[1], min) || + match_int(&args[2], rev)) + return -EINVAL; + + return 0; +} +EXPORT_SYMBOL(utf8_parse_version); diff --git a/include/linux/unicode.h b/include/linux/unicode.h index 4d39e6e11a95..f73a78655588 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -76,4 +76,7 @@ int utf8_casefold_hash(const struct unicode_map *um, const void *salt, struct unicode_map *utf8_load(unsigned int version); void utf8_unload(struct unicode_map *um); +int utf8_parse_version(char *version, unsigned int *maj, unsigned int *min, + unsigned int *rev); + #endif /* _LINUX_UNICODE_H */ From patchwork Thu Sep 5 19:02:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792876 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A5EDCE7A81 for ; Thu, 5 Sep 2024 19:03:36 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 25DF16B008C; Thu, 5 Sep 2024 15:03:36 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 170926B0092; Thu, 5 Sep 2024 15:03:36 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EDC1B6B0093; Thu, 5 Sep 2024 15:03:35 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0011.hostedemail.com [216.40.44.11]) by kanga.kvack.org (Postfix) with ESMTP id CAC256B008C for ; Thu, 5 Sep 2024 15:03:35 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 88898160947 for ; Thu, 5 Sep 2024 19:03:35 +0000 (UTC) X-FDA: 82531608390.06.FAC5DC7 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf22.hostedemail.com (Postfix) with ESMTP id B1EC2C0012 for ; Thu, 5 Sep 2024 19:03:33 +0000 (UTC) Authentication-Results: imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=hbeKl1QT; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf22.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562905; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=7BUAvvMuRU2tfo2IDkqAEnh0rC165iKKlWi/Zf6qiA4=; b=cNUnVotUEpJyxbaOOg9deDo77KnNouKAQZmHBfRXNPjOUc0WIvP7j6f3vhgTYWpUT1FFWm IDzzu5lh6KPFvq50QamJNVP+6q2Wn6HQxIWpuKOWrUv0Nk1LDgAHsusR4wGqvksPX6U+Ku 8wkL4Lm9haU2xGJc6gNCAGjDGAbNwLA= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562905; a=rsa-sha256; cv=none; b=C7SoIIohxtjTosELwglth3KoaWXrjFWh55HYuMRB6SPZja73JJv0tYu/xK16NYO56KYkK6 r0Ao9TRvGVIleQrmj3KUwfI6nKzTNsI7tFOksHCMKA6axgvAt7kwV2Qv2YiWN44/ryhnMY 0EQPKJxBzUUdkHZ/J7EhMJOpK+nqdUg= ARC-Authentication-Results: i=1; imf22.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=hbeKl1QT; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf22.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=7BUAvvMuRU2tfo2IDkqAEnh0rC165iKKlWi/Zf6qiA4=; b=hbeKl1QTRIQB74KvSycQ2F2ZFI 6EfPYPIhY/kDzNhC98wdLPBaxCUHGO7YQWeSRu206BRnRY4OziReMSFa9WRpaSTikBw7d2jXLjfwr nTprejKDeitM+tSIEZhx2fICW04IwmW+fU43Zj738ANKXAnWQOgAZGu/wevvHpNtkqgvIVwpWgBLZ ZdqWoBif0OlbIyaMHRLkuCGA/93cKu/Is6K/FZyIKHbUW5sbcDVaAzQttKFFePbOWeMf/SGsQubuk g3gaYQ56XbCJ6j0nXmDVsOxjwOAJDtg+1amttVaH0F5VvFc65s2ObC6W5W2m8zfdlLd7ncHFNieAE HSjJ+DLQ==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlN-00A6Ho-RC; Thu, 05 Sep 2024 21:03:25 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 4/9] unicode: Export latest available UTF-8 version number Date: Thu, 5 Sep 2024 16:02:47 -0300 Message-ID: <20240905190252.461639-5-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: B1EC2C0012 X-Stat-Signature: girnxfg5ypgsq7opw5bm9wts7hf4uxfc X-Rspam-User: X-HE-Tag: 1725563013-770208 X-HE-Meta: U2FsdGVkX191a/cd6oExfkIlQW28EgHmgjOOb9H/fve4S99Rjqv3H/OZ0EMf0KvSctrDSdM53UuIfIRcKEGWY1elQLFSTtSS/wS54zzayEluzWCH5JwhXajoi0MxPYbSvv8abLVoxibrwYw8ntrd4FJ8Yqg1euKoW7bjrPeDKuH3dsnlQSUe8slk39PoY5FUSzjH0Hoqiw7rsAQ/q6WGkbtLKNznFTRdcEM9w6CgeY0/o9j99xndP2MQ4dtVKEzLEG6Jy/yz38Lly8IwrvxpHulBcU/TlGxZslhwBEZt1XRf6GTPDW2o1B0h9aswp5g8TLnFxvixKHugbofzsRYBdkSG1lQ7beWRhfR/RYYqETRdeXdI/dbtn4GdYP6v4GEDfXThdi/RzQY6CzvBSFzMU3Voj/crQEI6gA9amMWgfQPr078ujLUhtVWoVctMk5bhf4hsstCk4mUwg9RRYBfuuGka+PfqcFB1Tu7pLMldPeoZ5AVmOefF40TPqy8BaazxW/xIMVAlyzp5sXXjhqImKpyLgFxfD98CXuCoYD0pkAx5wtGxLTbDKT9WcV90HJHlY70ceBXEeLrKn/N/rtXa07N7ZvQehX8CnVo+Z1aE+xaSJirfmhZTpIqPQpnFWyHu9GiW+5VuZelPr3JqCpcHmK2nGilrxxZPdLBvgepVYDB1mJmx9iomTWHedpuidwzqiXUHKgvZ1+ry4sjEhpzLljI6ovkzyhhzZ4hvNi2cjP+XQoyPcDTeBKErp+PP7GaA3WAUZJ7xXZGQXMDDT0L+s7Kypp0gp+IF1zhf6NMpPMbg52P2853X71Egv4c0P3NNWCG3sHvCTmk4dolAw313lt3lGlqdfRhc12rjIKvtmeQMQJQTElpZiGaFtqE/mBKCx1xCKR8r7XM0KBcPuvZmd3LewNZSDbsMJCHSfE6nhfW1UGJdR9/J66gzcZikgYbXSf7dA5m1JRguORkFzN6 6IYXPezf ZOtQzu5hF27zr3OemGEOU7YRHS0Hd1cI/RMxncVWgtw4xNTepptRV9OzZUuBgzsJFo8EJlqz44jtmWUseLr0kp6c/fawIykYTbGZazSrJ3AUXz8S2fClIWyK/imrGtSHiQk7Z7XOVYnqFTooUNtOzhldwy/WtNmDWAUelAI1iKqEXTbFiF1pwblknsH8ysYdR+hGlVAcHxZsiDfsSK5YE8txXHN2MicEIr8mcfl0dxsuoEZbDWwgp6tIuQ7WBdRxNWLk+5M56l7afdrHVATpACjcD9rjfQ2qz37od/Jn3kcCjJ9npdH6qAsw4luzf6da5CsYJCBCwGQXbA/A= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Export latest available UTF-8 version number so filesystems can easily load the newest one. Signed-off-by: André Almeida Acked-by: Gabriel Krisman Bertazi --- If this is the accepted way of doing that, I will also add something to checkpatch to warn that modifications at fs/unicode/utf8data.c likely need to change this define. Other ways to implement this: 1) Having a new arg for utf8_load() struct unicode_map *utf8_load(unsigned int version, bool latest) { um->tables = symbol_request(utf8_data_table); if (latest) { int i = um->tables->utf8agetab_size - 1; version = um->tables->utf8agetab[i] } } 2) Expose utf8agetab[] Having utf8agetab[] at include/linux/unicode.h will make easier to programmatically find out the latest version without the need to do a symbol_request/symbol_put of the whole utf8 table. --- fs/unicode/utf8-selftest.c | 3 --- include/linux/unicode.h | 2 ++ 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/fs/unicode/utf8-selftest.c b/fs/unicode/utf8-selftest.c index 600e15efe9ed..5ddaf27b21a6 100644 --- a/fs/unicode/utf8-selftest.c +++ b/fs/unicode/utf8-selftest.c @@ -17,9 +17,6 @@ static unsigned int failed_tests; static unsigned int total_tests; -/* Tests will be based on this version. */ -#define UTF8_LATEST UNICODE_AGE(12, 1, 0) - #define _test(cond, func, line, fmt, ...) do { \ total_tests++; \ if (!cond) { \ diff --git a/include/linux/unicode.h b/include/linux/unicode.h index f73a78655588..db043ea914fd 100644 --- a/include/linux/unicode.h +++ b/include/linux/unicode.h @@ -16,6 +16,8 @@ struct utf8data_table; ((unsigned int)(MIN) << UNICODE_MIN_SHIFT) | \ ((unsigned int)(REV))) +#define UTF8_LATEST UNICODE_AGE(12, 1, 0) + static inline u8 unicode_major(unsigned int age) { return (age >> UNICODE_MAJ_SHIFT) & 0xff; From patchwork Thu Sep 5 19:02:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792877 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id D624ACE7A81 for ; Thu, 5 Sep 2024 19:03:40 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 6C6C86B0092; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 675DC6B0093; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 4F96B6B0095; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 2DC906B0092 for ; Thu, 5 Sep 2024 15:03:40 -0400 (EDT) Received: from smtpin14.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CDA651C2D4E for ; Thu, 5 Sep 2024 19:03:39 +0000 (UTC) X-FDA: 82531608558.14.810B7AC Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf19.hostedemail.com (Postfix) with ESMTP id 26EB21A000F for ; Thu, 5 Sep 2024 19:03:37 +0000 (UTC) Authentication-Results: imf19.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZJghaA+j; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf19.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562946; a=rsa-sha256; cv=none; b=YfGn3/gCS4NJG2Ex4JezifaBihIfchqxFVfmmHvU6fH9ObXG8CANcLyzQWhyroZ9CV/SJY 84GaLQJNux1f/Da7G324EztXA7SHya5Ttgs9dVti1wwU3hRBni0wbRaK/+jXmIdxINSHVH 5GUSarQYVVbtNIqeoNKEqoOMY28UvVM= ARC-Authentication-Results: i=1; imf19.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ZJghaA+j; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf19.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562946; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=09RjlXQlRYkuU224DyyX5hGaeh4dLRLLtcX5SDFSDN0=; b=HBX3JXWolwjrLlh7L/BceIfRpe9jzP2aBNgSWVQ1VxgMq+coJwIHXHmGDwkn2hdR5nFOuh qDGB/DzYw8fAKEUF0iOgfWuZgM1V1bXnsILZgch3sReI0v3N/zF8h3KTHN/ihgvPrKYpMK 8nrHWwXGnvvA2OgiFwBQEC92ID0jbDw= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=09RjlXQlRYkuU224DyyX5hGaeh4dLRLLtcX5SDFSDN0=; b=ZJghaA+jVI7xvLO2YziWNskShX 87LUA2XkYooq3bZPKGSoYD5tloKq2MclVlntxHJslHNDeKX/iD/K2kgu3XG7t2uqpuHvYQ0ucO82U LliHgq6agb62p0rfBYgMSPxhhwOTW6v/7KOkaSsEmJFamtab29QMCgkORcdXuppFWpcbUr3ki8Faq MblpxRe1NSTRhC6GFxx9xyELWpjdG16psWeoWC4JtoP6doz7bx64aS4/xnZ9/DEz2FHllQXWu0jO1 9WobnQ1AolJBMzYeNRqaF0n5lurCWqveZ7dkrpjdjG93mPG8t6rhDDb+6oDgo6UY8LOENg1igrvzP y+ybT0cw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlS-00A6Ho-0W; Thu, 05 Sep 2024 21:03:29 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 5/9] libfs: Create the helper struct generic_ci_always_del_dentry_ops Date: Thu, 5 Sep 2024 16:02:48 -0300 Message-ID: <20240905190252.461639-6-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 26EB21A000F X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: p3j4718us9j9i3sumy7fcsz57dppy6ww X-HE-Tag: 1725563017-857073 X-HE-Meta: U2FsdGVkX1/+vhI7VW6paccf3uX6WbdO+cwA3RNWiVul4ksrp9ALtsca8tkyodpIGSQYLONp6L8zLBbRRaG7gqqY2CiHofmbHI56kJIWu2kppnw+/E+sZcUbmauPSAOWHFBlFruLRitUoG6FXPQzfO0FtJS0+o7+6oBaLqK1mb1q0qKm+l3aozWa+wcJFUy/Eg4FWgqhP/fzoG3SkhoMQTfKHFu97ZrYSS/aBF++N99IdB/sxV6mWCULLcbI9Q0J09eyRlAI2clQZ1O+lKR1CpsK2SR04lYkAN4bFDQbJP6LmfhNcbXbmB94OCi92L1sqAKQ5ccsQqnCvrIkaHjH+reVyDvv/smF7kAYnPNxvpivlZA6wGkQ3Z6r8dTiAZpSSheI4246l7FQo7beyBnjQVLAfr9tNvIjT5doSEH+xHZpi3KVg3LvC1iag6/O17/aRP1qPnkk9LsXVvm3U16RCnHZ50JpqSp3Be0fvsZs3GKUBoR3S4CsnwubsM5m6H1NIXGb+9hfdbtZqF/WdeWe/PBSAiKhGGEBQQMZVwzdsbAa8Brr+TrpXEGBm4PP7lH/XXLxNvoQBsXVmQ3H7b9JXAfjz4gVZ2XfD5T2lI6ZuWeUI6eqniitpVDL3eAWXu6dHUvrq2oz141v1uK1B+sHogpyf9D0JyspEEgqf+XjwMWX7pZf4Kvmvcu5pnHZUt2nsIzQG3btTwh7Z4vrEkFt/rngn3r3W8iQ8F16W7IEgjxTnyN/SofVQBJBq4WiXWy2yCrqxHj6/3qfNfk1nxIpoppRMmQfCk9YYJq6HDhqVasStpMHP3EmNZb2Vf2aiqjsJ3tGf0Dp/zhU7pskMxLWIEfY9BFvbHZ5CJYru9GlTsmij1tFXBW4Mcpvmc28rULy67Qw1rKaNidUklf+dF8HhEWO4Skw42GHMgwGXqg1/KDwxS65QdP5qIATnvENwxqfEhYF958byzUhz4QblX4 SrfRiuod YDW4N+YoCRndaZoKObf1xDUDTNSjA6/nVi66P/XdqjWrw22tOW3j+MObcdOZ3WdZm+/AKzD6SfXcJb5/e8G5vPMlfb+Hi4qxGj/lzO2CEmEh2cDD3RAaZAg+k6NFqjDes+yPxWyExyqRDlbIaotoutDVE4E2x3qTlQIKM7/dUQHVGoFioYRaqzYsbC0RlXF8zrWnfV8XMQc1X/GCvpc45lK5AdDLDc7B67Aboh7aVdQOG61M/I/QxWtJBQ+5Ko1oBoH52RyZTW1Ww0A/1vM+xO/+bYNOIVXy7AcM65HA4dOLl4m5z/400d1jEqK05OC/IEigkT5d4RNYbVhJwhhTjk6DflnbR2Df7XCmPX+MxWRIZXcdzd1gIXY9SsJHEs21qhhzu X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Create a helper to assign dentry_operations with the generic case insensitive functions plus setting .d_delete as always_delete_dentry. This is useful to in-memory casefold filesystems like tmpfs. Signed-off-by: André Almeida --- v3: New patch --- fs/libfs.c | 15 +++++++++++++++ include/linux/fs.h | 1 + 2 files changed, 16 insertions(+) diff --git a/fs/libfs.c b/fs/libfs.c index 99fb36b48708..58b39640b686 100644 --- a/fs/libfs.c +++ b/fs/libfs.c @@ -1855,6 +1855,21 @@ static const struct dentry_operations generic_ci_dentry_ops = { #endif }; +/* + * Same as generic_ci_dentry_ops, but also set d_delete. Useful for in-memory + * casefold filesystems. + */ +const struct dentry_operations generic_ci_always_del_dentry_ops = { + .d_hash = generic_ci_d_hash, + .d_compare = generic_ci_d_compare, +#ifdef CONFIG_FS_ENCRYPTION + .d_revalidate = fscrypt_d_revalidate, +#endif + .d_delete = always_delete_dentry, +}; +EXPORT_SYMBOL(generic_ci_always_del_dentry_ops); + + /** * generic_ci_match() - Match a name (case-insensitively) with a dirent. * This is a filesystem helper for comparison with directory entries. diff --git a/include/linux/fs.h b/include/linux/fs.h index 937142950dfe..254a1dcf987b 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3337,6 +3337,7 @@ extern int always_delete_dentry(const struct dentry *); extern struct inode *alloc_anon_inode(struct super_block *); extern int simple_nosetlease(struct file *, int, struct file_lease **, void **); extern const struct dentry_operations simple_dentry_operations; +extern const struct dentry_operations generic_ci_always_del_dentry_ops; extern struct dentry *simple_lookup(struct inode *, struct dentry *, unsigned int flags); extern ssize_t generic_read_dir(struct file *, char __user *, size_t, loff_t *); From patchwork Thu Sep 5 19:02:49 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792878 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20D5BCD5BB8 for ; Thu, 5 Sep 2024 19:03:45 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id A96B36B0095; Thu, 5 Sep 2024 15:03:44 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id A488A6B0096; Thu, 5 Sep 2024 15:03:44 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 89C136B0098; Thu, 5 Sep 2024 15:03:44 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 6B70C6B0095 for ; Thu, 5 Sep 2024 15:03:44 -0400 (EDT) Received: from smtpin07.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id CB7E81C4D70 for ; Thu, 5 Sep 2024 19:03:43 +0000 (UTC) X-FDA: 82531608726.07.E80BA9B Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf08.hostedemail.com (Postfix) with ESMTP id E927D16003A for ; Thu, 5 Sep 2024 19:03:41 +0000 (UTC) Authentication-Results: imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=Gwu+S2WV; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725563022; a=rsa-sha256; cv=none; b=unET+nd6xZo7Gx1BGw1ns+6fCXW4iMZBi+ZAbYNd0B20vg6zqFx16eiNTUNZncut4r4yfL 5lfMnNfA03Sw3KdKr0R9zBJQm0V5t2c6Kht0CyMaDQrCwqUyVeLkClAPs1gWZ4+aiHxN5r A3xPIuN/MF6rvTQi4lzKGHAfDepoPNI= ARC-Authentication-Results: i=1; imf08.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=Gwu+S2WV; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf08.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725563022; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=VmzlgsaYZjrrC3mQ36z6wkF/DubU3LiA5Bepzx0864k=; b=I2gp3ocqFLVPlVpxbeVjSHwSYKCUh4HZvdfWX2s0pUBmFUcuLUZuwNX3sp2j+2EnR8NyGW RB9TJj4INQSjMIZNAX9bY5MleZ0dhi8ImyP2aEtemECP1ZqHnFLVOGWfKlq2UV2gRA+PEB bBH7qszMcvlfkTq4qPocjqP43e+M+gM= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=VmzlgsaYZjrrC3mQ36z6wkF/DubU3LiA5Bepzx0864k=; b=Gwu+S2WVVmZsGxvWLl052l/1q2 ltwU0NqVeVAHvuF2fa+ccjSMlRW1/+fl/1eN/6Uhmtl2GytsBpiHQtvU+Oow+lRmw65qbc37/GLKI EpfNSdteKTgZS9kAcMhehkpSuoXX9gcHHBNXH0pxrFmsdQbyf2ZHXfKfhqINt/lQTFvVmiXHH0im1 mI7rw2jvvohjfLB2GOI8sGUNPd08QRa1z7/FtLFANYvOrN4/29SG5zO8iyDvzVYhkoJ8l2Fj8qZEX ig8krXC81tItgy+rPSU/ButQMUqhAvqdhIW6l+kaVSFoNMv1PQvhQ2S5wntStcW/+6g6fzYWRczK3 0fHuQOpg==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHlW-00A6Ho-6D; Thu, 05 Sep 2024 21:03:34 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 6/9] tmpfs: Add casefold lookup support Date: Thu, 5 Sep 2024 16:02:49 -0300 Message-ID: <20240905190252.461639-7-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: x6kijrz8cxxsjcshp7jjg111s6rba7kf X-Rspamd-Queue-Id: E927D16003A X-Rspamd-Server: rspam02 X-HE-Tag: 1725563021-138509 X-HE-Meta: U2FsdGVkX1+KjTs2PYVBdIJxT6AG9ynIUhnNp1hlsrnbLqisITSE57alc7V4GV/rnhOpEuuONICLCI814ZuSbq8zg33wTajPyctPVFNRZbXMzwVnt3Yl7YJRDIwifZdSiMp+S43LuNaKc4fzO5SWXFxQvexKGTW32fgTmyJA4SkswAnjAVSO2b974CXsAZ7JmNGbajK8tl1mW0SDgpnT845Araz/5gx9RsLP1vJmyeVa5XIdLJ9oh/mGeiP4KFmO408O72v0YlCMgfjAG8rkhl2qGodPQ6wgKVTajtYQf6Zpf7L/qxL+0MKdIjPSTpsuZdNUgJf7cJz6wmXl9/4EUJn0WNPmsNeke34BmgzHEY01VWoiwEQCeyJZLXoKo9dwSVSuaCytik5za8v4z9cdfCDX8BlNqVN7gbFlf5IneyyDGVWkM0QWmlIObflrB/bejJJchAlplRO/Iq8gyRL9nQY0yrnuwH5hyDYvpyGjea6ENhrrBr8H2OWOqR62tr4lrI2Z9gdIq042++4hQA98meKtRCWDvRX+iTZq4TXrO75E13hDskiCAv/NCzl0+1nfrGhSgDjoL1umWi/ZcFIhSNPZkDS1jcSa9yJQMexMX+VUOmPMpPsbqpFhob1PdDRFvPL5gPlKbZ+aRngxEO5n3poSzsJaGh7GHYzyauzHj2fD2hxydxEHik324P6J7h6woYgq15PgnjacuE4JuAHi+K5CLclmXnmLKifPBA/cSxus438t3kOhecIQjXWlgk1fkg0w/0tDwd2GMuI3cYuAUGgFC152IK3s94reZjipC6qmrwiY6/Y32JaiO0GcwCa7aPZrqT/DftT+LDYfKDEpQepYyJatqPlnh07yxmXDyKkxtZxu54GLcLu7YyIxThwy5Ad3sIt1TNV78lwoKv2rNFTvY7paAkllqohGIIweuMD53PCiLC5iryvLvNEGw9NH+u4UF3uTC8DSGjavzKG IxNu58zp mBJSvA/aDrfIRJJArXwezR4b0fYdbpVKdOQsIKBxM10ZNxJcUOjqGc309wWcPFmtEhBhly6DwENyMSQNTs1w/kqUdxANq3eY61QtdB6Mz2bsQgMPJ8OvmE42xYAbyDl7+SMHLx/Rv5nG5iL1zIUntb34YYzkMlXMQAI3VKH1bfvaCpHvVN+MEHzgyLQ+iTsHHpJWR+YudrcoEuIwfTFfCAlDTWLL3azzwp/umc0HQrik5ur2R4497AMYDwpEAe8hgThNLHQxKa9kFys3jw2JzeDhtB7nmtg3jZ9tJ49BWfgZ2ryxaYl03q+mSjR2KsjOQYUQ6+EtlMK5wEKw= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable casefold lookup in tmpfs, based on the encoding defined by userspace. That means that instead of comparing byte per byte a file name, it compares to a case-insensitive equivalent of the Unicode string. * Dcache handling There's a special need when dealing with case-insensitive dentries. First of all, we currently invalidated every negative casefold dentries. That happens because currently VFS code has no proper support to deal with that, giving that it could incorrectly reuse a previous filename for a new file that has a casefold match. For instance, this could happen: $ mkdir DIR $ rm -r DIR $ mkdir dir $ ls DIR/ And would be perceived as inconsistency from userspace point of view, because even that we match files in a case-insensitive manner, we still honor whatever is the initial filename. Along with that, tmpfs stores only the first equivalent name dentry used in the dcache, preventing duplications of dentries in the dcache. The d_compare() version for casefold files uses a normalized string, so the filename under lookup will be compared to another normalized string for the existing file, achieving a casefolded lookup. * Enabling casefold via mount options Most filesystems have their data stored in disk, so casefold option need to be enabled when building a filesystem on a device (via mkfs). However, as tmpfs is a RAM backed filesystem, there's no disk information and thus no mkfs to store information about casefold. For tmpfs, create casefold options for mounting. Userspace can then enable casefold support for a mount point using: $ mount -t tmpfs -o casefold=utf8-12.1.0 fs_name mount_dir/ Userspace must set what Unicode standard is aiming to. The available options depends on what the kernel Unicode subsystem supports. And for strict encoding: $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_encoding fs_name mount_dir/ Strict encoding means that tmpfs will refuse to create invalid UTF-8 sequences. When this option is not enabled, any invalid sequence will be treated as an opaque byte sequence, ignoring the encoding thus not being able to be looked up in a case-insensitive way. Signed-off-by: André Almeida --- Changes from v2: - shmem_lookup() now sets d_ops - reworked shmem_parse_opt_casefold() - if `mount -o casefold` has no param, load latest UTF-8 version - using (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir) when possible --- mm/shmem.c | 142 +++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 138 insertions(+), 4 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 5a77acf6ac6a..6b61fc5dc0b1 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -40,6 +40,8 @@ #include #include #include +#include +#include #include "swap.h" static struct vfsmount *shm_mnt __ro_after_init; @@ -123,6 +125,8 @@ struct shmem_options { bool noswap; unsigned short quota_types; struct shmem_quota_limits qlimits; + struct unicode_map *encoding; + bool strict_encoding; #define SHMEM_SEEN_BLOCKS 1 #define SHMEM_SEEN_INODES 2 #define SHMEM_SEEN_HUGE 4 @@ -3427,6 +3431,10 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, if (IS_ERR(inode)) return PTR_ERR(inode); + if (IS_ENABLED(CONFIG_UNICODE)) + if (!generic_ci_validate_strict_name(dir, &dentry->d_name)) + return -EINVAL; + error = simple_acl_create(dir, inode); if (error) goto out_iput; @@ -3442,7 +3450,12 @@ shmem_mknod(struct mnt_idmap *idmap, struct inode *dir, dir->i_size += BOGO_DIRENT_SIZE; inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); inode_inc_iversion(dir); - d_instantiate(dentry, inode); + + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); + dget(dentry); /* Extra count - pin the dentry in core */ return error; @@ -3533,7 +3546,10 @@ static int shmem_link(struct dentry *old_dentry, struct inode *dir, inc_nlink(inode); ihold(inode); /* New dentry reference */ dget(dentry); /* Extra pinning count for the created dentry */ - d_instantiate(dentry, inode); + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); out: return ret; } @@ -3553,6 +3569,14 @@ static int shmem_unlink(struct inode *dir, struct dentry *dentry) inode_inc_iversion(dir); drop_nlink(inode); dput(dentry); /* Undo the count from "create" - does all the work */ + + /* + * For now, VFS can't deal with case-insensitive negative dentries, so + * we invalidate them + */ + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_invalidate(dentry); + return 0; } @@ -3697,7 +3721,10 @@ static int shmem_symlink(struct mnt_idmap *idmap, struct inode *dir, dir->i_size += BOGO_DIRENT_SIZE; inode_set_mtime_to_ts(dir, inode_set_ctime_current(dir)); inode_inc_iversion(dir); - d_instantiate(dentry, inode); + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + d_add(dentry, inode); + else + d_instantiate(dentry, inode); dget(dentry); return 0; @@ -4050,6 +4077,9 @@ enum shmem_param { Opt_usrquota_inode_hardlimit, Opt_grpquota_block_hardlimit, Opt_grpquota_inode_hardlimit, + Opt_casefold_version, + Opt_casefold, + Opt_strict_encoding, }; static const struct constant_table shmem_param_enums_huge[] = { @@ -4081,9 +4111,62 @@ const struct fs_parameter_spec shmem_fs_parameters[] = { fsparam_string("grpquota_block_hardlimit", Opt_grpquota_block_hardlimit), fsparam_string("grpquota_inode_hardlimit", Opt_grpquota_inode_hardlimit), #endif + fsparam_string("casefold", Opt_casefold_version), + fsparam_flag ("casefold", Opt_casefold), + fsparam_flag ("strict_encoding", Opt_strict_encoding), {} }; +#if IS_ENABLED(CONFIG_UNICODE) +static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *param, + bool latest_version) +{ + struct shmem_options *ctx = fc->fs_private; + unsigned int maj = 0, min = 0, rev = 0, version = 0; + struct unicode_map *encoding; + char *version_str = param->string + 5; + int ret; + + if (latest_version) { + version = UTF8_LATEST; + } else { + if (strncmp(param->string, "utf8-", 5)) + return invalfc(fc, "Only UTF-8 encodings are supported " + "in the format: utf8-"); + + ret = utf8_parse_version(version_str, &maj, &min, &rev); + if (ret) + return invalfc(fc, "Invalid UTF-8 version: %s", version_str); + + version = UNICODE_AGE(maj, min, rev); + } + + encoding = utf8_load(version); + + if (IS_ERR(encoding)) { + if (latest_version) + return invalfc(fc, "Failed loading latest UTF-8 version"); + else + return invalfc(fc, "Failed loading UTF-8 version: %s", version_str); + } + + if (latest_version) + pr_info("tmpfs: Using the latest UTF-8 version available"); + else + pr_info("tmpfs: Using encoding provided by mount options: %s\n", param->string); + + ctx->encoding = encoding; + + return 0; +} +#else +static int shmem_parse_opt_casefold(struct fs_context *fc, struct fs_parameter *param, + bool latest_version) +{ + return invalfc(fc, "tmpfs: No kernel support for casefold filesystems\n"); +} +#endif + static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) { struct shmem_options *ctx = fc->fs_private; @@ -4242,6 +4325,13 @@ static int shmem_parse_one(struct fs_context *fc, struct fs_parameter *param) "Group quota inode hardlimit too large."); ctx->qlimits.grpquota_ihardlimit = size; break; + case Opt_casefold_version: + return shmem_parse_opt_casefold(fc, param, false); + case Opt_casefold: + return shmem_parse_opt_casefold(fc, param, true); + case Opt_strict_encoding: + ctx->strict_encoding = true; + break; } return 0; @@ -4471,6 +4561,11 @@ static void shmem_put_super(struct super_block *sb) { struct shmem_sb_info *sbinfo = SHMEM_SB(sb); +#if IS_ENABLED(CONFIG_UNICODE) + if (sb->s_encoding) + utf8_unload(sb->s_encoding); +#endif + #ifdef CONFIG_TMPFS_QUOTA shmem_disable_quotas(sb); #endif @@ -4515,6 +4610,16 @@ static int shmem_fill_super(struct super_block *sb, struct fs_context *fc) } sb->s_export_op = &shmem_export_ops; sb->s_flags |= SB_NOSEC | SB_I_VERSION; + +#if IS_ENABLED(CONFIG_UNICODE) + if (ctx->encoding) { + sb->s_encoding = ctx->encoding; + generic_set_sb_d_ops(sb); + if (ctx->strict_encoding) + sb->s_encoding_flags = SB_ENC_STRICT_MODE_FL; + } +#endif + #else sb->s_flags |= SB_NOUSER; #endif @@ -4704,11 +4809,38 @@ static const struct inode_operations shmem_inode_operations = { #endif }; +static struct dentry *shmem_lookup(struct inode *dir, struct dentry *dentry, unsigned int flags) +{ + const struct dentry_operations *d_ops = &simple_dentry_operations; + +#if IS_ENABLED(CONFIG_UNICODE) + if (dentry->d_sb->s_encoding) + d_ops = &generic_ci_always_del_dentry_ops; +#endif + + if (dentry->d_name.len > NAME_MAX) + return ERR_PTR(-ENAMETOOLONG); + + if (!dentry->d_sb->s_d_op) + d_set_d_op(dentry, d_ops); + + /* + * For now, VFS can't deal with case-insensitive negative dentries, so + * we prevent them from being created + */ + if (IS_ENABLED(CONFIG_UNICODE) && IS_CASEFOLDED(dir)) + return NULL; + + d_add(dentry, NULL); + + return NULL; +} + static const struct inode_operations shmem_dir_inode_operations = { #ifdef CONFIG_TMPFS .getattr = shmem_getattr, .create = shmem_create, - .lookup = simple_lookup, + .lookup = shmem_lookup, .link = shmem_link, .unlink = shmem_unlink, .symlink = shmem_symlink, @@ -4791,6 +4923,8 @@ int shmem_init_fs_context(struct fs_context *fc) ctx->uid = current_fsuid(); ctx->gid = current_fsgid(); + ctx->encoding = NULL; + fc->fs_private = ctx; fc->ops = &shmem_fs_context_ops; return 0; From patchwork Thu Sep 5 19:02:50 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792879 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47758CE7A81 for ; Thu, 5 Sep 2024 19:03:49 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D7C956B0098; Thu, 5 Sep 2024 15:03:48 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D2D3A6B0099; Thu, 5 Sep 2024 15:03:48 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id BA7326B009A; Thu, 5 Sep 2024 15:03:48 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 9862A6B0098 for ; Thu, 5 Sep 2024 15:03:48 -0400 (EDT) Received: from smtpin18.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 9A80EA0A50 for ; Thu, 5 Sep 2024 19:03:47 +0000 (UTC) X-FDA: 82531608894.18.5452D0A Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf05.hostedemail.com (Postfix) with ESMTP id E375C100010 for ; Thu, 5 Sep 2024 19:03:45 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="qRDe7y/i"; spf=pass (imf05.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562929; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=4vz8LJ8AGqtE46pXkxH06G/62SH6tsoXVW4UBJQz500=; b=USEFW9539DW/qOKU3MfEJpYCuhmceOKKkqjsJWA+4Yw/9FDOzStxKOyiDM44/MvAF3UOTR YkGRzrnhY7aZ401YD7Vb8rguBYuzRSJ/73XxvEN8ZhGTD9/fDR/WH+x76mVTmZU58LMX2a MIz66+oZpQY+MRXUm/7V+/3q6ZGpipU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562929; a=rsa-sha256; cv=none; b=lzhDntZ5zV+MWJEbR+xsyS09W/h3nbmq9wbiYfkO72e+I4PX6Yv8yC5vSCNIojw90NE06l vCj9n3KwUh0wX9pyHojPHTsqkbL3VzOTNiuoMsPWIzl55H1Jbft9yr0Pa5fZZzRQy6fspH dI6EPXLP9oPDqIes3r/mksWZN5Dg2zI= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b="qRDe7y/i"; spf=pass (imf05.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com; dmarc=pass (policy=none) header.from=igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=4vz8LJ8AGqtE46pXkxH06G/62SH6tsoXVW4UBJQz500=; b=qRDe7y/i3zJwIWrkmkWIlGSNG5 S8C/1KxCMXfvhhaAOkFX3VUMNClSZ9JflAyBEbAWNSt9LmkJunrXCJ38rnWCAI3AkrbzWvxFUbSmB dHaJKveIWlR4idWLWfU0B9NTBUxH4379FDaEvV3v7uNz0wht/K27+ttfz58v1GqRiMoerG5SLowVh 2Wlb+UhmxHeg+a0y9R4Nl1yT88f2AMWWVvksy2TJIWcOGGJoACJFsCmryE2FYHLXXx3FCuhhgCmVu KwLcBzQYqqKsXEV0Iuq84EY4KvQCcptkJ3q51oL+h/r4r4PaXqN95AQ9xJTeNPd/cAMDFK1FuCN4t 5nN+1DJw==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHla-00A6Ho-Is; Thu, 05 Sep 2024 21:03:38 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 7/9] tmpfs: Add flag FS_CASEFOLD_FL support for tmpfs dirs Date: Thu, 5 Sep 2024 16:02:50 -0300 Message-ID: <20240905190252.461639-8-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: E375C100010 X-Stat-Signature: 1hs1mmb6s5ot8y1p6sfdyefr9cwcbie7 X-Rspamd-Server: rspam09 X-Rspam-User: X-HE-Tag: 1725563025-920541 X-HE-Meta: U2FsdGVkX1+BCrW6XQNk1IARTI4xqqgqwqHBlCevW8kKqqpzlqiNIJqtcfsJErLWrf65NKZ0k122FEWxdTMkhKaaRgiuWgI66LgXo/FLeT/gp6/kI49mF0KSE5nt/DIJxjiLhnC7jtKrxcwJrk/5PCMSYd9HbsPBk/ooXqOfxBRppLyprFZEFxCJuLxDR2tCWwDh8g6TIn0AiwvzH+fcFqX3K7CfFE2XGiXUm4Y40zJH7YNZig00EXAZ+qv3QR4IvCSn/bmrkAUNv4RtVotAs9zQ7QEhy6RvZw3p5228pfyoH8fhrciTJ+T2OAzhQu0ioDEnHYFtLhQN7lIZOSquejBMUZ+dGaOYiBPOcQuiuHzbgRt6UXAXLLI4NWfm1mguNxOf72JOaX//0SQ5OeMNcL9kmRz08JBTINhMsCHcUGpjW5U8WqWnGDH67mo2JFr4Xh/4tv3wT+arz+YiWlzoYxp8dwQCOXeEMS4BdZSo86GKCWq9qHk+A5RyIOXoWenKG8dXz8xGTpYUrCTk2r4BeAHL7R5ZO4W4ARXfMXobFklltsVLCWTqDzWm1l1DAkWMTBsZbOFJ9InuqDO0u0jd8bzgDIF9J7Dvc1I9tAYkKoIqpAL12I0o87bscj2h6SqVbGBHGdU4aiSVzLGk3krUsb9cR5cmZn0gE+LdVz3ucmgHdcYEc5Xu+uVVQOBVPDCnJ/w00MPSQQbG9hC/nZkDmxzQwFh/CWRXoPbw75w+LzibTfp480SB1fqVf4IWxjXJ8WWkpUWfnxiCBF+G2e6eG4hZR/nfI0cj9BnMMcQAn4Hznf7Y+8xyg5Ay/43MWfwKCdqXiGcfWOkq3AT1q3PIeHtkNf6mtZ069oszFpx7YP3EuPa+FLhxRGy4U9SZf/5nPfzxfyOVrUblEt6PsBkxQqCDGNyHsvTlAxfhCUi8r0Zj7aXIEZwWdq1vmAfCqxDOr56Sy5gcwmoMyEljj// 0buObCZf ahZzLwwXyO4Csq/KY17iiOSWv/HiNpBOR+JU7d72NUg2+Sq+fVMc+EsYYgp7GYoWeNh7ootE/sZmsBxW69kjiR0+C4ZPqr+53zDSADG9XqVS9aEERzMvWfHBbJt9BnwgZsOxtruSu7C7D4uOQDlwhkgiUwDjMtta6NjuAsVMVV+srmV/KXJiaDZzVNFYE/kG0OoBZ0KValy/KRT6J0XYgPqzxMyZwfFjcjkE56v0fA0S3IcsvWrYkNRkRMy5E78vui0+uyB8F2xLL/X0gjYcT5Kwn+5wBgDw9iooEb2e7xPGERJVzkjvDN8m6MBQG1a5kVvVOPBmRprN+7gDJQqiuS95gaA2zKRf+zhMHoI0uPG7O3gFNvHXwNISC5PDxHMQKc16z X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Enable setting flag FS_CASEFOLD_FL for tmpfs directories, when tmpfs is mounted with casefold support. A special check is need for this flag, since it can't be set for non-empty directories. Signed-off-by: André Almeida --- Changes from v2: - Fixed bug when adding a non-casefold flag in a non-empty dir --- include/linux/shmem_fs.h | 6 ++-- mm/shmem.c | 70 ++++++++++++++++++++++++++++++++++++---- 2 files changed, 67 insertions(+), 9 deletions(-) diff --git a/include/linux/shmem_fs.h b/include/linux/shmem_fs.h index 1d06b1e5408a..8367ca2b99d9 100644 --- a/include/linux/shmem_fs.h +++ b/include/linux/shmem_fs.h @@ -42,10 +42,10 @@ struct shmem_inode_info { struct inode vfs_inode; }; -#define SHMEM_FL_USER_VISIBLE FS_FL_USER_VISIBLE +#define SHMEM_FL_USER_VISIBLE (FS_FL_USER_VISIBLE | FS_CASEFOLD_FL) #define SHMEM_FL_USER_MODIFIABLE \ - (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL) -#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL) + (FS_IMMUTABLE_FL | FS_APPEND_FL | FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) +#define SHMEM_FL_INHERITED (FS_NODUMP_FL | FS_NOATIME_FL | FS_CASEFOLD_FL) struct shmem_quota_limits { qsize_t usrquota_bhardlimit; /* Default user quota block hard limit */ diff --git a/mm/shmem.c b/mm/shmem.c index 6b61fc5dc0b1..d38977fb2097 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -2613,13 +2613,62 @@ static int shmem_file_open(struct inode *inode, struct file *file) #ifdef CONFIG_TMPFS_XATTR static int shmem_initxattrs(struct inode *, const struct xattr *, void *); +#if IS_ENABLED(CONFIG_UNICODE) +/* + * shmem_inode_casefold_flags - Deal with casefold file attribute flag + * + * The casefold file attribute needs some special checks. I can just be added to + * an empty dir, and can't be removed from a non-empty dir. + */ +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + unsigned int old = inode->i_flags; + struct super_block *sb = inode->i_sb; + + if (fsflags & FS_CASEFOLD_FL) { + if (!(old & S_CASEFOLD)) { + if (!sb->s_encoding) + return -EOPNOTSUPP; + + if (!S_ISDIR(inode->i_mode)) + return -ENOTDIR; + + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + *i_flags = *i_flags | S_CASEFOLD; + } else if (old & S_CASEFOLD) { + if (dentry && !simple_empty(dentry)) + return -ENOTEMPTY; + } + + return 0; +} +#else +static int shmem_inode_casefold_flags(struct inode *inode, unsigned int fsflags, + struct dentry *dentry, unsigned int *i_flags) +{ + if (fsflags & FS_CASEFOLD_FL) + return -EOPNOTSUPP; + + return 0; +} +#endif + /* * chattr's fsflags are unrelated to extended attributes, * but tmpfs has chosen to enable them under the same config option. */ -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static int shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { unsigned int i_flags = 0; + int ret; + + ret = shmem_inode_casefold_flags(inode, fsflags, dentry, &i_flags); + if (ret) + return ret; if (fsflags & FS_NOATIME_FL) i_flags |= S_NOATIME; @@ -2630,10 +2679,12 @@ static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) /* * But FS_NODUMP_FL does not require any action in i_flags. */ - inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE); + inode_set_flags(inode, i_flags, S_NOATIME | S_APPEND | S_IMMUTABLE | S_CASEFOLD); + + return 0; } #else -static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags) +static void shmem_set_inode_flags(struct inode *inode, unsigned int fsflags, struct dentry *dentry) { } #define shmem_initxattrs NULL @@ -2680,7 +2731,7 @@ static struct inode *__shmem_get_inode(struct mnt_idmap *idmap, info->fsflags = (dir == NULL) ? 0 : SHMEM_I(dir)->fsflags & SHMEM_FL_INHERITED; if (info->fsflags) - shmem_set_inode_flags(inode, info->fsflags); + shmem_set_inode_flags(inode, info->fsflags, NULL); INIT_LIST_HEAD(&info->shrinklist); INIT_LIST_HEAD(&info->swaplist); simple_xattrs_init(&info->xattrs); @@ -3789,16 +3840,23 @@ static int shmem_fileattr_set(struct mnt_idmap *idmap, { struct inode *inode = d_inode(dentry); struct shmem_inode_info *info = SHMEM_I(inode); + int ret, flags; if (fileattr_has_fsx(fa)) return -EOPNOTSUPP; if (fa->flags & ~SHMEM_FL_USER_MODIFIABLE) return -EOPNOTSUPP; - info->fsflags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | + flags = (info->fsflags & ~SHMEM_FL_USER_MODIFIABLE) | (fa->flags & SHMEM_FL_USER_MODIFIABLE); - shmem_set_inode_flags(inode, info->fsflags); + ret = shmem_set_inode_flags(inode, flags, dentry); + + if (ret) + return ret; + + info->fsflags = flags; + inode_set_ctime_current(inode); inode_inc_iversion(inode); return 0; From patchwork Thu Sep 5 19:02:51 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792880 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4D3D7CE7A89 for ; Thu, 5 Sep 2024 19:03:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D55C26B009A; Thu, 5 Sep 2024 15:03:51 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id D07716B009B; Thu, 5 Sep 2024 15:03:51 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B59F46B009C; Thu, 5 Sep 2024 15:03:51 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 93C8C6B009A for ; Thu, 5 Sep 2024 15:03:51 -0400 (EDT) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 422FE1609C6 for ; Thu, 5 Sep 2024 19:03:51 +0000 (UTC) X-FDA: 82531609062.12.AEBA751 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf30.hostedemail.com (Postfix) with ESMTP id 78BD380023 for ; Thu, 5 Sep 2024 19:03:49 +0000 (UTC) Authentication-Results: imf30.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=cMdmt17L; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf30.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562957; a=rsa-sha256; cv=none; b=6j9CgLw4q2R9IhvQXOTE+Mxxq34XHiu268wXzLMHlAB7XtLz13Au2X8Ao1jepx5hBX8m1I esPGTVogajqq20+ySCqU137zINmMy5zM7+WfFS8k8ng7Eo+qRlAjgOzyZVABa93mPESBcI 3ChpUB8lNbomragnwfpWmvRY0DJuH1I= ARC-Authentication-Results: i=1; imf30.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=cMdmt17L; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf30.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562957; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=KEsDgLMnBuzjf05DHVHytHkrG5fKkqN0J3GYigoTn6k=; b=Sb38cT1+dl9uBgUTPZ0Tf176WgVH0KQNktx0SKftltFicnt+vfnuf8XWvu2FNw2ljfYWPf JQt/4uJfxA4ys/4Xn+QlqygP1Hkc3lQHBhpnqYe1h79IyZlW6SX66ax6zLO72QnExxrR3e uZE6SvLc+KIM+fNlsvyk++hwvAliSC0= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=KEsDgLMnBuzjf05DHVHytHkrG5fKkqN0J3GYigoTn6k=; b=cMdmt17LxH6fIF2Ney+7Mz3URy yoTm3Z2zgH2eTdXtPjbR95NIg+/65TVK+up5hFhZk733HaUhGytIm+PmrIJ1ncgRoi9Fa084/9rFw j3nAj42fwCiSE055xv0oPPp0njfSppyno+UlAJy2ml3e4/aU4j9csmwDu/LfYKqrOTh6vwmdLch8H OzIYIupdckTH0rafY7vSmeNSQ5tbU13eeBol+Hc1tL6hzQnKczgzP5jzsAXfSMy9JpvmO5zmJRU/1 plfBBtyQUTA4Ciwlz+QQ/wuPK8oZ3j4Yl7mqpTqWGrrOrXYaC4xEU7ikVPFoFTlItGFjIVWjqvEVP 0Zf6alNQ==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHle-00A6Ho-OV; Thu, 05 Sep 2024 21:03:42 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 8/9] tmpfs: Expose filesystem features via sysfs Date: Thu, 5 Sep 2024 16:02:51 -0300 Message-ID: <20240905190252.461639-9-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: 78BD380023 X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: oj19wqm78ro6ekp3obydypen3swez874 X-HE-Tag: 1725563029-356288 X-HE-Meta: U2FsdGVkX1+FZOjI0Hy++VRBH+1xm6toZCGUAc2iTgjkoLgmVALbWfNXkA9m+s49GPvB3doMUTttJ/qrtVJr69LvqH/q5f7wuYdGe3Av7mKmaqDc67wf6z1/dWfoWYsldQeFOouiVxyD8j6COZGTfc9wa33ZNPlyilSvNUxYXBwcbxTPCLK1hPfhu4KymXGFVbApgYxBRmG95N170agrf/aowqYde+3zYvjEj4GNSKwGuioZIkuPUsZtWRSzLZ/h9fIRfhuFR73ebil4EhIq4/HtYPiXUbJWO0/A3LGemHzPL9JdEwdLQGV1qyqoCBSWKQr45M4xAT0SQYXxH3PyzNHAdfxaS5aObudZ4yOpfVmkwz0y5lxW349jMiosT17govEEM8b89eqlyGRtfN7W3w7q6cpfmdig6nGXhjjQjopav8QhJddlS4TJ1bwnEp2NYahPa6aaJF0c+kSkCO/V8N3OpD5ENtYoB+6nJ45Cx2eIsRv1x99NxPLFbk/04X5M2d2o4zRv7/6zJXv095rzT+nAVTDVbHUYy1CeVIwHZWniLmznOgMD5a2gXsc+AEgJP1rfFALDBLZdr3B5VmXJUhTpSd3DWcE/f8GzwzgKoYrZnn7M768cFkFIcDb91dMofaeWjAGR6ou2Uo1TEYje6PMnEimVwkPE2ghyePOES6tSv7aO1lTaxRNRQWajFkQnyA7BQSTlfk8ERhzqo5Qxah0cbIBw/7SobV3Ve2afs20xbGiWHtU1wxy7le6uf+Bbdk+OUy+02pjvkN8Rz1+mp/Nd5LgRlxnQnX6dG9kZA8OkzONNwGth7iv263g5KnaHk/w9/pdrktlymbdR/NTxHxvaLEk6lI7Ouc6YF3/PNqlvPdnxRKjo9PV0VoCm22iYvsHWhmyZVmtbeE2SVJ4OoyHFSafFN0MNwZCp1PtcVTF/W+CPChvR5ugmqg8qFtaXmthCbBGfqiGlUu1kgQp 52aBzkjv 9JHp4QylkfivHsoTS2QoTBKeqgCoAe1kqs6a6uiSKQVN49S0DVgkTuQ4BtUMi2e56vQHbaIIscYzQNv9g7Ou26p0f1Qzzb1X7uR8c4Got7XJoHdo5rSfLnhDENDql3sgS4/Uq+dpIVTzAf14CMPV+NgQlRrryT52p0XcsHUAfQbPHJYPRNEPRWtsIxpH7tq3WjXp/fIpK2cDaiVscXHwhrEjyH0U8fzpvHfVfF1KmK29IJdlVAg4wJr7hyZED/d/ACDZh/7GaO39za1I5eO9bBarfpvQh7UhC0tZ5e848bLB4xqR3/juWTWFP3w== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Expose filesystem features through sysfs, so userspace can query if tmpfs support casefold. This follows the same setup as defined by ext4 and f2fs to expose casefold support to userspace. Signed-off-by: André Almeida --- mm/shmem.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index d38977fb2097..5da90bdde4a5 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5424,3 +5424,40 @@ struct page *shmem_read_mapping_page_gfp(struct address_space *mapping, return page; } EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); + +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) +#if IS_ENABLED(CONFIG_UNICODE) +static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +#endif + +static struct attribute *tmpfs_attributes[] = { +#if IS_ENABLED(CONFIG_UNICODE) + &dev_attr_casefold.attr.attr, +#endif + NULL +}; + +static const struct attribute_group tmpfs_attribute_group = { + .attrs = tmpfs_attributes, + .name = "features" +}; + +static struct kobject *tmpfs_kobj; + +static int __init tmpfs_sysfs_init(void) +{ + int ret; + + tmpfs_kobj = kobject_create_and_add("tmpfs", fs_kobj); + if (!tmpfs_kobj) + return -ENOMEM; + + ret = sysfs_create_group(tmpfs_kobj, &tmpfs_attribute_group); + if (ret) + kobject_put(tmpfs_kobj); + + return ret; +} + +fs_initcall(tmpfs_sysfs_init); +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ From patchwork Thu Sep 5 19:02:52 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Andr=C3=A9_Almeida?= X-Patchwork-Id: 13792881 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 843E4CE7A81 for ; Thu, 5 Sep 2024 19:03:57 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 20C3B6B009B; Thu, 5 Sep 2024 15:03:57 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 1BBE76B009C; Thu, 5 Sep 2024 15:03:57 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 036296B009D; Thu, 5 Sep 2024 15:03:56 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id D7EB06B009B for ; Thu, 5 Sep 2024 15:03:56 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 9383E140994 for ; Thu, 5 Sep 2024 19:03:56 +0000 (UTC) X-FDA: 82531609272.04.9D29602 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf14.hostedemail.com (Postfix) with ESMTP id DCAF010001A for ; Thu, 5 Sep 2024 19:03:53 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=WdLwE6Cn; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf14.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1725562925; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=/LWMOwEq5GUDt5NImZXWEjsD4awT5R9j9E8cdrJ7p4o=; b=WaBMU+DoYYtsivaZu1IQ9dmNbrfQ6NMF5OnfgxFJlqZ0WseZWgR8ZjVfyCkyPmOiECNO0N mvRHguicY1eS0XFuWPuRXfgLZM0LMvSqf9EpA6S6QxMmotXCl8mNJbDXDIhqyQ98ZiRoxY REpUrcZPrr8lMyiL4FvkUfp6PA4o8ig= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1725562925; a=rsa-sha256; cv=none; b=OTWiHOB3vjRcrCtyz5wysIBMOHe7nJ/ahLsoW+V9qjlTofTS9pNx9bdusyIXismmK3hfbn VBjzoslKMf7ImHPph83+8FJVR8qXmLtuyvZjkzPJryTnzakuXgvloluQ4ARMqoKRTGTcsN g9Sx7kGJW0kEa6QlTVRU/skd/ANP3M8= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=WdLwE6Cn; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf14.hostedemail.com: domain of andrealmeid@igalia.com designates 178.60.130.6 as permitted sender) smtp.mailfrom=andrealmeid@igalia.com DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-ID:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=/LWMOwEq5GUDt5NImZXWEjsD4awT5R9j9E8cdrJ7p4o=; b=WdLwE6CnNPUk/lsHJztjMUkO1P +tQrfJtNZbR2466KvpkhAb47I8QsJqk19D2JRASXbyOu98VInDhMDWQ59T+6tthxgIv2DV3PMZTGn 50S5rIaMFmmD6YrSxYF9uBN3+dJR/kHGxDWPFEGZLeyurkyEkWiEhU6HHQCvIjdoJZpC+/LAVS0iC iboVw7Uax+cEX+It6g/ziPM2e1sK+892Agovno4V+gWDpsL+DSvSchSEQdh0DFyXwj8xpAQ7jyobH fA61Fh/M1s2fyuoI72AvqlyV4W1Nw0byJx1aChWO4PtaufxCZptDFlTeEFBcjrfTpUhMqmpDsPsSf KPxrkOAg==; Received: from [177.172.122.98] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1smHli-00A6Ho-U0; Thu, 05 Sep 2024 21:03:46 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Daniel Rosenberg , smcv@collabora.com, Christoph Hellwig , Theodore Ts'o , =?utf-8?q?An?= =?utf-8?q?dr=C3=A9_Almeida?= Subject: [PATCH v3 9/9] docs: tmpfs: Add casefold options Date: Thu, 5 Sep 2024 16:02:52 -0300 Message-ID: <20240905190252.461639-10-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240905190252.461639-1-andrealmeid@igalia.com> References: <20240905190252.461639-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: DCAF010001A X-Stat-Signature: 9wkbzswzdgyeduypxqyrsun6dbzgdje8 X-Rspam-User: X-HE-Tag: 1725563033-293334 X-HE-Meta: U2FsdGVkX18yhVG6NxlBIR/0Oc/knfLxcYDGtaPJtmI6KljYA/lF5JGPzEclwOonGjcxQOYjuqafqprIxSSwl2DRz/iVaD80EQPXAUtyUqGDeM6hxo2bxziCuCQARIp8tVlWBzqBIbh0oLpnToR0ZNwqYIGjpbbWBiot6L5xQXyWQ72/cOtbNYswfjsF7T5H3nYDoOjk4BpXehYv7qm9oMOaa/uSpyzdflo4KTsczBR0PbBqOyujMpN7pOAy5FWpIMFvnwMzxzopgTuyBpy9Ol4s9KjM/jZjMiASXC5DguUYknjP+DsdindfxGDAEwNhjUNcZDf7joIJ9ZecpM2GZ50MjWM3uv6lTP8KIaKx0IUJdFo7V9Icla0ywba/baTX2C6IM3nxknTO+jlycdOL6n6T2REtz5ANvlgvMTFWyqLX8QUiqO2t7IEc2WDGK/zMSkNuTjwd0suGjRArv95oS+RVBj7xNaZ4plphOgEq/BYWm+ucZwrgTfzuQgaxqL7bgMC7w7a8Z9ILEeKAe8AaA5KivmHS8UW6dw/KPJOoJQrhRFMFxhU3UHOpuushua0HuBMjKuzWwhKbD4wVAE2ILc4mB6VtjyOG/SfmlwG77CZpoRKOGKOaX9KOx5LZuApU2PPRRmV8p8Ekrf9A4D5xHMGiceBQHC/RQqCMRumP/H0Lmn91NKkwU9F6DpgZcyP5zbYroz0tRAdbUAO6BrQyzqGvystQdx6kXwxi9tA8E2CrHhwyJnQZdUUdWWT0o2hucN3Jz3df3Rm/P3Ofb0e8cT8v31BsKAXNdQao6zrxhYWoeVjipSHAInPnttXDkftmzXOHIlzJWYHobjBegcU1NscXIJ2BLh/dvuAn/EOKU8NSE8Xes1i+E+nxfJzE2ubamLqaP9Mswi7j5enArMwg82Mxd8bbmSkVbcTi4iCjInQHAX2n9H1VSbib0+Kpy8Qb2l/5tKTP8Xx8CRMaRaW M3e2s3g9 oW1QQ4LrkdBqsIyHrubTu9o7RA9bjU/C28PuMhdRwX94mLqKDEDr7P3MwjRUAf/LZgMW6ujIARDLNnQZM8rBeETByL+o98/JcuueYke48TnQZeekXvWuwQfkvaXGkfVn7MfZcVZRBONXx7xKqdMXpoXBIcbx7v7SfuIRwQ8Td6MSTXRfVMjXWamxi8WdR+6LuTCTXB0HFNvSZ2PzHtmWOs/gywDMlkfNPxX1Y/31bJbf5A5f5YH9FQdyqDqTlVkCV1MDOJk2ZCNBvYCd+CgtIJiC+ai3lNzyMa15QoAfZLFdmtGOZgjlHGkF++rsaZw3dHq/xXBK8fp58Nd8= X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: Document mounting options for casefold support in tmpfs. Signed-off-by: André Almeida --- Documentation/filesystems/tmpfs.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/Documentation/filesystems/tmpfs.rst b/Documentation/filesystems/tmpfs.rst index 56a26c843dbe..636afd3eaf48 100644 --- a/Documentation/filesystems/tmpfs.rst +++ b/Documentation/filesystems/tmpfs.rst @@ -241,6 +241,27 @@ So 'mount -t tmpfs -o size=10G,nr_inodes=10k,mode=700 tmpfs /mytmpfs' will give you tmpfs instance on /mytmpfs which can allocate 10GB RAM/SWAP in 10240 inodes and it is only accessible by root. +tmpfs has the following mounting options for case-insensitive lookups support: + +================= ============================================================== +casefold Enable casefold support at this mount point using the given + argument as the encoding standard. Currently only UTF-8 + encodings are supported. If no argument is used, it will load + the latest UTF-8 encoding available. +strict_encoding Enable strict encoding at this mount point (disabled by + default). In this mode, the filesystem refuses to create file + and directory with names containing invalid UTF-8 characters. +================= ============================================================== + +Note that this option doesn't enable casefold by default; one needs to set +casefold flag per directory, setting the +F attribute in an empty directory. New +directories within a casefolded one will inherit the flag. + +Example:: + + $ mount -t tmpfs -o casefold=utf8-12.1.0,strict_enconding fs_name /mytmpfs + $ mount -t tmpfs -o casefold fs_name /mytmpfs + :Author: Christoph Rohland , 1.12.01 @@ -250,3 +271,5 @@ RAM/SWAP in 10240 inodes and it is only accessible by root. KOSAKI Motohiro, 16 Mar 2010 :Updated: Chris Down, 13 July 2020 +:Updated: + André Almeida, 23 Aug 2024