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+s49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XcsHUAfQbPHJYPRNEPRWtsIxpH7tq3WjXp/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 */