From patchwork Wed Sep 11 14:45:01 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: 13800725 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 67182EE49BD for ; Wed, 11 Sep 2024 14:45:59 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E9249940059; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id E4180940053; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id D09BD940059; Wed, 11 Sep 2024 10:45:58 -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 B0EC1940053 for ; Wed, 11 Sep 2024 10:45:58 -0400 (EDT) Received: from smtpin27.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 59BA91A1324 for ; Wed, 11 Sep 2024 14:45:58 +0000 (UTC) X-FDA: 82552731996.27.B5F2067 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) by imf04.hostedemail.com (Postfix) with ESMTP id A96384000E for ; Wed, 11 Sep 2024 14:45:56 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ViLjtovm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf04.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=1726065880; a=rsa-sha256; cv=none; b=JaE+4COBX+yRuJJ9hnIjgWb8rc2lmK80A3vs4DA1wQ7Mw6fzQOkvj4685FAXtIBaNRItUG K9xDUgtkrwwOv2+wBWHusJ3uNom7BEiPyg/Mh1y15737L8M8FquGCJJmbiJNHQwet+gC2W 8S2DKhvZX2jpWNCFv4ud7AyYrTLAMkQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=igalia.com header.s=20170329 header.b=ViLjtovm; dmarc=pass (policy=none) header.from=igalia.com; spf=pass (imf04.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=1726065880; 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=pK8srYuw9wrv3ZwJYkO0PSANkqjQtOsAR4zsFhEgnYA=; b=EwP4R4Zgo6dXAbMzzMggfLuHVflu9PfQuB+U2LvQphCr8htIZC+7eL6GzVT7wbZs/YJ4Dq tHFTdPAc7USaem7i/10xmCnSsqlfN2w3EpFvJnegdQrrl9VwWKBeV241/qFcSRh6LYEUSV 5P4YHw9RlXi+IsfJ/tQhvydFIN6mIjY= 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=pK8srYuw9wrv3ZwJYkO0PSANkqjQtOsAR4zsFhEgnYA=; b=ViLjtovm9+jx46z9NAxTCgvkry 83+J+2uzaaR+6xtpgGNpGwxlNqYrbscclmySVeWUNc4M5x0NRA9qyA3DeINjEBW6m0KO3tqeFh1i9 WVU+dRvo8ovMdPLU+s07ZLsiMEvkNgpR2DVKPAwbjco4llsIwnDSbT+IAW7LNf7sn/JRDex/60WoS t9QbIB8RcRheSXc21NUKmn5X2NUGj2746kiav+LMMSeb5OWIpr5kXyTG9rnVDMOTMC9VnwYgdExG+ GNBUguE2FMSA4DwzRxkh0QSnSeH36bJdhW6Y0TkedAwpFRhEQymVXoLOoRVglEoMMJnJjyC4EeR8n NBePUPYA==; 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 1soObN-00CTwi-Jj; Wed, 11 Sep 2024 16:45:50 +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 v4 09/10] tmpfs: Expose filesystem features via sysfs Date: Wed, 11 Sep 2024 11:45:01 -0300 Message-ID: <20240911144502.115260-10-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20240911144502.115260-1-andrealmeid@igalia.com> References: <20240911144502.115260-1-andrealmeid@igalia.com> MIME-Version: 1.0 X-Rspamd-Queue-Id: A96384000E X-Rspam-User: X-Rspamd-Server: rspam05 X-Stat-Signature: j9iwztotsjsg8jwmctshm5p91nazjg63 X-HE-Tag: 1726065956-47197 X-HE-Meta: U2FsdGVkX1+lF7nM2idEM0eaXPrXx/KIZYlIvNIbJNmjnupXQ2PXIA0uchIq2At4h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4O42uNsszL+CxihsC+JHHyqOg2AiU5DBSFslu+4KBJnxkO7keIes1CprbepJHIPoJb6hbjLlDUN8jj228PaWrxNU3AAapyqA071t7dlEz89zs0W9752AtNE08ghLXqJ1d7SaOZuILb9MNbKm1KTslt1/I6QlhQGakQjG30SfyaqAj8Kp+D381icW7pE4= 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 fc0e0cd46146..7e7e2461a314 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5401,3 +5401,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 */