From patchwork Mon Sep 2 22:55:09 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: 13787805 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 1234BC54FC6 for ; Mon, 2 Sep 2024 23:20:32 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 9D13D8D011C; Mon, 2 Sep 2024 19:20:31 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 9817B8D00E7; Mon, 2 Sep 2024 19:20:31 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 84A3C8D011C; Mon, 2 Sep 2024 19:20:31 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 67C0A8D00E7 for ; Mon, 2 Sep 2024 19:20:31 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 188B2140473 for ; Mon, 2 Sep 2024 23:20:31 +0000 (UTC) X-FDA: 82521369462.27.7BFC526 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf02.hostedemail.com (Postfix) with ESMTP id 5EC4080006 for ; Mon, 2 Sep 2024 23:20:29 +0000 (UTC) Authentication-Results: imf02.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=p9Uj+HQO; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf02.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=1725319153; a=rsa-sha256; cv=none; b=Ap4w3owdLWT+lSr6Bn7r2fE/Xe6uvWbX94edl9iuaxERiO4ge14QJCedZS7UKfSEbrCSIw U04VqVv/UkrrAW3QRmddjLK2xueh0xFTGfGwze5lZ/V3V80aOjissyaWBUIKHBWrX+8Jsw eRkiguuG7PDqW/n+eiwwRb54U8DLJqk= ARC-Authentication-Results: i=1; imf02.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=p9Uj+HQO; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf02.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=1725319153; 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=3R/tp+CDqyBtPlv516oP8Fp25VoAZ0ob6jRSgnVwtV0=; b=DntJdz4BaoHNxB8RB9vBOgGqveRRBuCwX1R4xtpf5iuYHHWvHfdz11ztUjFOqwzhg+aqr5 y8VIkrSxNfEas08NilttbEQ6/adN0l8xddkZwMEwtmWiB+fUibBmpnTX9TKh4/8USGviHS DlCCMmcNgXqhOiNNhmUTDB6dzE75qic= 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=3R/tp+CDqyBtPlv516oP8Fp25VoAZ0ob6jRSgnVwtV0=; b=p9Uj+HQO7xB0nBgaoWBjepov4N hHfY4s4Au6B3vEil6NOrGBzm5GroC1P0mp5WyxlUIc372IGKu7pI0vyl/sC7ES4VZnj4YxPwFtB2t KxF1C7a7cgdwihU4cE3z4dUwucE1+ci/hnTZEd4SBpjHVHmd87vT9sNYe6eBQ0/eB/Myqxsvi3zfH /xHeHyMcNs3ZOPh1MLSYgq0s3NxfGLun+OoFVvpzLD0iwGiefDz85zXF1Ay7zRSfW8GnkXO81R6ol 1RMf1Q/2mm8NWh/ACClOonMPxgS33SKmuNuqkWtMz87RuBxl+UcdzK4tv99AFJl7Ivb+ccefu8ytu A0axMLqQ==; 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 1slFxc-008VrL-6R; Tue, 03 Sep 2024 00:55:48 +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 , =?utf-8?q?Andr=C3=A9_Almeida?= Subject: [PATCH v2 7/8] tmpfs: Expose filesystem features via sysfs Date: Mon, 2 Sep 2024 19:55:09 -0300 Message-ID: <20240902225511.757831-8-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240902225511.757831-1-andrealmeid@igalia.com> References: <20240902225511.757831-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: 5EC4080006 X-Stat-Signature: 4guozosij4at5j5itqe78u84w1jogd6w X-Rspam-User: X-HE-Tag: 1725319229-362281 X-HE-Meta: U2FsdGVkX1+W6hsL+S4PaWd6IIYEgVmC+Tp41lSkaOhcwIZ02clAZWzz2PO9YD8FZid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4MEfz2xCnS7FEM2y9pKZ+9jDRdWrHTZllM9OrbYhF6sGvydhWkI2nQoebc9uRVNh3aJbj3wVars1SPBK8MI+QWCFQM4SL4kfKihau8OWz23VQTL6nPS2xA9wCOCV3rvZbKDLE095zMSHCWbpDoZrhIiw== 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 9a0fc7636629..fdaae7543d1a 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5365,3 +5365,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 */