From nobody Thu Nov 28 08:41:24 2024 Received: from fanzine2.igalia.com (fanzine.igalia.com [178.60.130.6]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58AFD1CC14C; Wed, 2 Oct 2024 23:45:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=178.60.130.6 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727912747; cv=none; b=VRZ1otsMZnyTYllkCuyccUYP1VqD7vDvMOCUM3t0GPIgR4sxHIljPGqYVBu/Fz+JaD9l6PM7/g9uD6pKrDJbmkjh3Tti6md3krhGGM3jzydoW3RdsAeULT9Qb/nQFp/NS6gw9jYBntTAtkDjJx4/OgNuOBoUVkaiVaQDoCssX0g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727912747; c=relaxed/simple; bh=Q5OxMdiU6Bu3fjUb9MsjJWYA7YZ1HuV4bsGRFebf78M=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=c0rwWX6z4JYNBlGul3MBwQdnzSnt7/v/S+Wo8d0IG/NGSuEc/mSv9a8VHMgKSneYcO4JMG+LnmzJ4gz/fM6EwR2wvcVYgMMJO/JXf21ZZ3sPglJEPzm81M22OQJCs/svDDrmmazvlNJEISqlqqpIDn56u2yorYFTETLONvA4lqM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com; spf=pass smtp.mailfrom=igalia.com; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b=YUXfIqOm; arc=none smtp.client-ip=178.60.130.6 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=igalia.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=igalia.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=igalia.com header.i=@igalia.com header.b="YUXfIqOm" 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=IRPMd0h51YpQUBbAAX/wcuH0ZmexRZTVdCGmfxXJDJ4=; b=YUXfIqOmAm+ugm/XutADfo8KPq 852FMkqLH0SDzwTuLviY9XWwuciBiWB4uZfTdN24lUwGI3iZLz9ztLI4yr4ZiyMOkqajRybBp4+6Y ZVNOj6EVyZdjf3mfra9zlRHjbxVuwh3/Z7v79gNubJXqRoQVGVoJi+XcDsmWWGpHG+/pqElH1cuGD jlrxW7RXb3rlOqzNOGq7INMOtQuN2U3xQ1Qpt7V/+XV7ntd24CXQJgXdwHF2fo2xTS1t0RNn6ugun BmWFAlzoQECJH/X4J4E+FfadeI5VAdDMnKrk+E24N09A1HfCdwjjM2faNC5hDeOKzLCKd6vGLTVVO pnqUI3LQ==; Received: from [187.57.199.212] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1sw92H-0045tc-Rv; Thu, 03 Oct 2024 01:45:38 +0200 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= 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?Andr=C3=A9=20Almeida?= , Gabriel Krisman Bertazi Subject: [PATCH v5 09/10] tmpfs: Expose filesystem features via sysfs Date: Wed, 2 Oct 2024 20:44:43 -0300 Message-ID: <20241002234444.398367-10-andrealmeid@igalia.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: <20241002234444.398367-1-andrealmeid@igalia.com> References: <20241002234444.398367-1-andrealmeid@igalia.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=C3=A9 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 f07b446b3c98..007123019d1c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5543,3 +5543,40 @@ struct page *shmem_read_mapping_page_gfp(struct addr= ess_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[] =3D { +#if IS_ENABLED(CONFIG_UNICODE) + &dev_attr_casefold.attr.attr, +#endif + NULL +}; + +static const struct attribute_group tmpfs_attribute_group =3D { + .attrs =3D tmpfs_attributes, + .name =3D "features" +}; + +static struct kobject *tmpfs_kobj; + +static int __init tmpfs_sysfs_init(void) +{ + int ret; + + tmpfs_kobj =3D kobject_create_and_add("tmpfs", fs_kobj); + if (!tmpfs_kobj) + return -ENOMEM; + + ret =3D 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 */ --=20 2.46.0