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: 13792870 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 453241AE026; Thu, 5 Sep 2024 19:03:50 +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=1725563031; cv=none; b=F08tlKHnjPCsMpbHno/4XrDOwL1I3oU/FcpI2liWu26PvG+iDRtpSHkW3FTkrWWfFqlMrFs+CsGEthsHHgfJUB4MzqcGnFA5hEWA7KHzxGCDnstf6SE3s4iew6tub3NGlMdc6VBzP/J5nilXwrGG7X5bLL2s6TUsTXJhLVEceKM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1725563031; c=relaxed/simple; bh=hgYua/lefeXh9Gchs8o23DaNH5W4Qs3bm/egkRFy4bA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=VnJDV08j2DQv59w4XMM+hYYCeBKr9lDbgKajgQmjaPQq+G0xiPQxiYMfdOIsD8vi8Us7f5EUz8O5U4QFNwvEJJ4jZ5IAGySHJBqhe40swGhGXn8tRXxeg6ppmVrddQpeQU2wOicyNjjfj5ZKabsvRuhTb7Z5VzoUzuFaYqBd5Os= 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=cMdmt17L; 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="cMdmt17L" 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> Precedence: bulk X-Mailing-List: linux-fsdevel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 */