From patchwork Mon Oct 21 16:37:24 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: 13844445 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 28194D15DBA for ; Mon, 21 Oct 2024 16:38:20 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9DC9B6B008C; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 964546B009B; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7B9346B009C; Mon, 21 Oct 2024 12:38:19 -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 5724A6B008C for ; Mon, 21 Oct 2024 12:38:19 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id E65ACA1AF6 for ; Mon, 21 Oct 2024 16:37:50 +0000 (UTC) X-FDA: 82698166572.06.928FC27 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf23.hostedemail.com (Postfix) with ESMTP id C5391140012 for ; Mon, 21 Oct 2024 16:38:07 +0000 (UTC) Authentication-Results: imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ng3tGDT4; spf=pass (imf23.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=1729528547; 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=SbTvLQbuG7yeLrygZxqm3PkbVldfcIwV1lI2HDmaGB0=; b=uDpuajjT//TlJMb8dCxmLOcMe7Qn0FNnXZKJpDqllLp5ICU9Lm6K/152kWQFcakBdYIUtB HEW4hezS5kpdy3uwF0UCoT/DXgEg97AJUIAP+MqEh1grO4nfKyem94Ja6IhOAA24Ae+5vn JM574Uq0vj1gwykrU5U3Ooya9iqUcKo= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729528547; a=rsa-sha256; cv=none; b=HzETHdmCusL90Zlb3cdJZXauKKMvzPwCkxCEECZnermglSnyhdv3+3PGBtNtvIkLvGcU3G thMzD1ys8gYE9874bC1pvmRy8j72VmNLTQh3sDQZX5hOwZuW7mMuexb8Rx/QgDJV4w8sae Y0rzKxxocfcn90cuGMxBJ9Nim0RnEGY= ARC-Authentication-Results: i=1; imf23.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ng3tGDT4; spf=pass (imf23.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=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: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=SbTvLQbuG7yeLrygZxqm3PkbVldfcIwV1lI2HDmaGB0=; b=ng3tGDT4cx9xfXAgnjbczk8AVt 8VDuXwyw4Nz7jqIThpbDd5tui0FNOI/+nvnS1lw9Jov8iFzGRpkVK+PaeceBs8GE1eh9uKxeGT7Iu nGGX3uWpKbFTnYT7zWcK+X+DpbOjFg+O3xObm6DP+quVe3X0RP/k6QyJY0yUTp3dITyGt6X2VQT54 p9LSsgj7k2hB3qISbYBFcNhnA445dYuOKRzcNN0ZFJ59n/3bek/jxYUdIq8RwX3+mCvPpcIvYsG3Z 1bOrLwofFZXvPLWeOjsweF7w0AuOLQKuwSzlKH83sNHYtRCI9lwN2F4Zro3Zb10FMJ5u0PM/ARfY1 lGRkU2Hg==; Received: from [191.204.195.205] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t2vQ7-00DECf-5L; Mon, 21 Oct 2024 18:38:15 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:24 -0300 Subject: [PATCH v8 8/9] tmpfs: Expose filesystem features via sysfs MIME-Version: 1.0 Message-Id: <20241021-tonyk-tmpfs-v8-8-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeid?= =?utf-8?q?a?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: C5391140012 X-Stat-Signature: msrx8fjm93g6rktytmxgmnyunghh34xs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9URwxi4H4BjKoj4+XgJz3HV6jXGLk9vvsFUHFP/VQ3I6iu5Boe8uyksNZ5Ntd/zA6ikMgTbcufaIMd676LVKkYmPB0Pe97I5DzE/FNjeCL+yvX5FhYdWAWKtLByLReOpFuimmqamPwe7UdPWQ31Qfvbla4WpQESmDMgZu+zZOsrEHLiDW3TEZrBS6xy7Fp8za66d9lHx+qvw8fIvCR9rSs29oXcA+KWDUrBnB+910W6MTgwUw3bmgbR+7suQebxM+g9AnBKHXlSIpM6YjJhpb2RlP5zrMoflERCXjgjpBNou3zUGH9smE6x9LalCxt0BFiSEdtiBF+QJV5pBfbnn9nqx1CyaCC+jjo0y8UbaNv8WmXC3 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 Reviewed-by: Gabriel Krisman Bertazi --- mm/shmem.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/mm/shmem.c b/mm/shmem.c index ea01628e443423d82d44277e085b867ab9bf4b28..0739143d1419c732359d3a3c3457c3acb90c5b22 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5546,3 +5546,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 */