From nobody Sun Nov 24 20:33:27 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 E79CF1C2456; Fri, 1 Nov 2024 16:43:28 +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=1730479410; cv=none; b=WpVvnJFs0j95y6lbPen7UcuP4XPaG4d6heRm4XrvsOnyXJuIhFr4wBR+PlO0RsgwsGWlHbi5ZGfV2s8qQmhhUHLu/AMXnlC4kKkdsjZloZb+Rno3bEmKSQqsWB4W7zgj0/hx1HStU918T7xyuPi6JbV6Nc9yjjz/76kwizRM0ns= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730479410; c=relaxed/simple; bh=emJCuip6O+uYAJz+KzUytVj8TFsHxkL2bexsE8nkMbU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OZf2mB8Q8K+u1PCTT1Xd+SWKpo81av2WimEzTNQltUjTsHmL3tKyv47oe7oNAabVBWWNuNXQJJKVRblYKUzH4pyQau9wzv3cQbN5MKu45bCU9OVzvHW0/Dv6vqvtornQO7ThI56Go+lRDa7zHWLwubFFCqzl3plmOjJGRXb8v68= 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=dNs6y88V; 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="dNs6y88V" 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=8swRcMqa/BS2pXAGjnNhVyXxuHalIiMIO71jJmsFBEs=; b=dNs6y88V3Dp060LB2jwGQ42+XE aWYX1YU5LJCoxMADvt2/KdnVdLavBZNQQILvGyY94ejMp9bE6JQgXj7LU1esE8v/j6PcIjfFN2IFD TwYEhaPWyK7KZxPgqiR/taMupeNQSJ0sexhpttnS9M6pTBg/g6Z0rTevV9Xz5lMZ6Zo6EYqZP5kSl Y+MzYdD9Aq+ZPn/JVDu6c1VXbwFipB3kStIeax1qQiIWirUy3SPlI+Drz30PxLWsPvm2lKHKequgv GSb+WpsNI0LbdZSh2uDbTI4MfCWs9+yfMiEgDdQewanxooCxFLUhIFHuK9v6DygPiodpdldb+rz+m dLB8XqYw==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6uk2-000V2F-QD; Fri, 01 Nov 2024 17:43:19 +0100 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 1/3] libfs: Fix kernel-doc warning in generic_ci_validate_strict_name Date: Fri, 1 Nov 2024 13:42:49 -0300 Message-ID: <20241101164251.327884-2-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-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 Fix the indentation of the return values from generic_ci_validate_strict_name() to properly render the comment and to address a `make htmldocs` warning: Documentation/filesystems/api-summary:14: include/linux/fs.h:3504: WARNING: Bullet list ends without a blank line; unexpected unindent. Fixes: 0e152beb5aa1 ("libfs: Create the helper function generic_ci_validate= _strict_name()") Reported-by: Stephen Rothwell Closes: https://lore.kernel.org/lkml/20241030162435.05425f60@canb.auug.org.= au/ Signed-off-by: Andr=C3=A9 Almeida --- include/linux/fs.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/include/linux/fs.h b/include/linux/fs.h index 3b279f60e48f..b562a161e2ee 100644 --- a/include/linux/fs.h +++ b/include/linux/fs.h @@ -3499,12 +3499,12 @@ int generic_ci_d_compare(const struct dentry *dentr= y, unsigned int len, * @name: name of the new file * * Return: - * * True if the filename is suitable for this directory. It can be - * true if a given name is not suitable for a strict encoding - * directory, but the directory being used isn't strict + * * True: if the filename is suitable for this directory. It can be + * true if a given name is not suitable for a strict encoding + * directory, but the directory being used isn't strict * * False if the filename isn't suitable for this directory. This only - * happens when a directory is casefolded and the filesystem is strict - * about its encoding. + * happens when a directory is casefolded and the filesystem is strict + * about its encoding. */ static inline bool generic_ci_validate_strict_name(struct inode *dir, stru= ct qstr *name) { --=20 2.47.0 From nobody Sun Nov 24 20:33:27 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 A6FA033F7; Fri, 1 Nov 2024 16:43:35 +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=1730479417; cv=none; b=EDF6aik0K8zPmDtbdbMxQJxwPNWFppWwUqWqXzALGxWyZMaR6kjIS0wixWdtqWNtJsg+k/+X7cjpkyn9ZqKqoePQuqUNQHZSshB3k3GsW7W6ecrZyY8+u5I8MSo2pM9WGMTj1jpgmQL8zJxSWHBFnwzlfYtrtRMeioavOcG0fRI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730479417; c=relaxed/simple; bh=PK2v487FHAoC3wGhbaXrY59m3+cfmucKsS9/WZjxzZg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YSDuw6VJXwO7DKvrCSroniHEgWGBwc12nPvyR4KqSVowDtEOL0GnZesiCeuOUdpmWtzVem5NFc5diqaai+GQQvp5lVBrBV8AcLu7GaTMM3Yv5wOMGvBSZW0MnotcETlsRBItPnqnaoM7fuuBa6wGxSZAL87be/II/wzvxn8WarY= 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=czU4tOPy; 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="czU4tOPy" 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=s2zJ3ZAsAPQ0E9uJzi8hgSgBj9U5Eh/vvFyC13/+d5w=; b=czU4tOPy9JPLZZs+bxemSdZzV5 /rpbQSDGQENcIJBnYPji0JLIMHGJzmvhFqnTK1JRE6WCUHznLbk8ETVJUw+hCSb9kvFQ+5x80idPV bQi67u3Fnc41GYhvnpoKVp5qVUc+kHXfTp3SdwXUTlBqHlcTLvMTtLFbI/LVhZVAyD+CkECEoSKXG Hmk7nI9g8d4OhUhZ7/0uR0o1VPaljl8ssXLel3QvOXM1A+rQQ+3LenzA89PdfAl2WOXpK3KzvQwJi Icdy2puxLfCgC/mhKhtRDGmsRSaUP1VeNViyZye0EVUWcKR1+X9koKub9NY/exwJyTDK6cX8Gy/gh bjhTsZyA==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6uk7-000V2F-1g; Fri, 01 Nov 2024 17:43:23 +0100 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 2/3] tmpfs: Fix type for sysfs' casefold attribute Date: Fri, 1 Nov 2024 13:42:50 -0300 Message-ID: <20241101164251.327884-3-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-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 DEVICE_STRING_ATTR_RO should be only used by device drivers since it relies on `struct device` to use device_show_string() function. Using this with non device code led to a kCFI violation: > cat /sys/fs/tmpfs/features/casefold [ 70.558496] CFI failure at kobj_attr_show+0x2c/0x4c (target: device_show= _string+0x0/0x38; expected type: 0xc527b809) Like the other filesystems, fix this by manually declaring the attribute using kobj_attribute() and writing a proper show() function. Also, leave macros for anyone that need to expand tmpfs sysfs' with more attributes. Fixes: 5132f08bd332 ("tmpfs: Expose filesystem features via sysfs") Reported-by: Nathan Chancellor Closes: https://lore.kernel.org/lkml/20241031051822.GA2947788@thelio-3990X/ Signed-off-by: Andr=C3=A9 Almeida Reviewed-by: Nathan Chancellor Tested-by: Nathan Chancellor --- mm/shmem.c | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index b86f526a1cb1..6038e1d11987 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5548,13 +5548,38 @@ struct page *shmem_read_mapping_page_gfp(struct add= ress_space *mapping, EXPORT_SYMBOL_GPL(shmem_read_mapping_page_gfp); =20 #if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + +#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ +{ \ + .attr =3D { .name =3D __stringify(_name), .mode =3D _mode }, \ + .show =3D _show, \ + .store =3D _store, \ +} + +#define TMPFS_ATTR_W(_name, _store) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) + +#define TMPFS_ATTR_RW(_name, _show, _store) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0644, _show, _store) + +#define TMPFS_ATTR_RO(_name, _show) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) + #if IS_ENABLED(CONFIG_UNICODE) -static DEVICE_STRING_ATTR_RO(casefold, 0444, "supported"); +static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *= a, + char *buf) +{ + return sysfs_emit(buf, "supported\n"); +} +TMPFS_ATTR_RO(casefold, casefold_show); #endif =20 static struct attribute *tmpfs_attributes[] =3D { #if IS_ENABLED(CONFIG_UNICODE) - &dev_attr_casefold.attr.attr, + &tmpfs_attr_casefold.attr, #endif NULL }; --=20 2.47.0 From nobody Sun Nov 24 20:33:27 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 817341CC177; Fri, 1 Nov 2024 16:43:37 +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=1730479421; cv=none; b=VrN3oxRo0o1M6UGjkM0ZpNkzuCaKEFxiMnxs/NU+IaJFBtO7PjhmsN5iDBQSX0XHICDxLEHIKNqXFk4EHA1IxC4woOxpQjf3xY33GXHt3m1kSTskOp/0RWGu/CCyjdLVGN1+N05jx4omutgX6Et0r8NgouXRBtXZFh1wb2QkrU0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1730479421; c=relaxed/simple; bh=lb9RjaO/cLTpIA5ytTYGjlJe27AiShJpYxvElcVEufQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MZRfmEhIEinO8KuG/taDa7IDAmUCguqUE//gh4l/uH1OeICCWhaSZmZg8nMz0KMK01ty904aDmfH5H7Z2C2hZZBjHFTc2iNE2FqZg3ByxV/wZV9t05j/Y5XU9yQ4G2r04RXcjGn2VsnfMGAEG5Hxubk8GDz0FXGGTIuPbeuVB5U= 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=pn87DnAX; 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="pn87DnAX" 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=1Ftxs1X2bzMP8j6QK8gh+paXxKWIM0HgFnEN8ePS9Tc=; b=pn87DnAXiqTKqX3MhKegErUZj5 8fCM7W1FYVlDWFulKMj228VX/ZFBQhPW4JdWHiNJiwft3+OKS2uzZ38b0zQkfN7UDdR63V5WJmxNJ 0cosR6SaUcOAmBfdPq5JkJzMoDj8rmyXRxm5n8gdLhSHxkpUdnkxrjNy6F6WQp+T9Hq942V7HLV3C riIgfxGS/lJw0g3kwhnuyvJbZ219OKN0jbsI4l8TPLXRXOdfFlve7BfHTYfALrHsT8CTepBHlg3m+ +N3x4S5N5bDYQV3qfkogt58NtqJQWVUwatzywOpDBtCpGXtluXxG07xA2u0cIp2s8qwApichjWNIj cvwLKPEQ==; Received: from [189.78.222.89] (helo=localhost.localdomain) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t6ukB-000V2F-9N; Fri, 01 Nov 2024 17:43:27 +0100 From: =?UTF-8?q?Andr=C3=A9=20Almeida?= To: Hugh Dickins , Andrew Morton , Alexander Viro , Christian Brauner , Jan Kara , krisman@kernel.org, Stephen Rothwell , Nathan Chancellor Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, kernel-dev@igalia.com, Theodore Ts'o , =?UTF-8?q?Andr=C3=A9=20Almeida?= Subject: [PATCH v2 3/3] tmpfs: Initialize sysfs during tmpfs init Date: Fri, 1 Nov 2024 13:42:51 -0300 Message-ID: <20241101164251.327884-4-andrealmeid@igalia.com> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241101164251.327884-1-andrealmeid@igalia.com> References: <20241101164251.327884-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 Instead of using fs_initcall(), initialize sysfs with the rest of the filesystem. This is the right way to do it because otherwise any error during tmpfs_sysfs_init() would get silently ignored. It's also useful if tmpfs' sysfs ever need to display runtime information. Signed-off-by: Andr=C3=A9 Almeida --- Changes from v1: - Fixed ifdef guard for tmpfs_sysfs_init() --- mm/shmem.c | 130 ++++++++++++++++++++++++++++------------------------- 1 file changed, 68 insertions(+), 62 deletions(-) diff --git a/mm/shmem.c b/mm/shmem.c index 6038e1d11987..a5355cf9443c 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5126,6 +5126,66 @@ static struct file_system_type shmem_fs_type =3D { .fs_flags =3D FS_USERNS_MOUNT | FS_ALLOW_IDMAP | FS_MGTIME, }; =20 +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + +#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ +{ \ + .attr =3D { .name =3D __stringify(_name), .mode =3D _mode }, \ + .show =3D _show, \ + .store =3D _store, \ +} + +#define TMPFS_ATTR_W(_name, _store) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) + +#define TMPFS_ATTR_RW(_name, _show, _store) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0644, _show, _store) + +#define TMPFS_ATTR_RO(_name, _show) \ + static struct kobj_attribute tmpfs_attr_##_name =3D \ + __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) + +#if IS_ENABLED(CONFIG_UNICODE) +static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *= a, + char *buf) +{ + return sysfs_emit(buf, "supported\n"); +} +TMPFS_ATTR_RO(casefold, casefold_show); +#endif + +static struct attribute *tmpfs_attributes[] =3D { +#if IS_ENABLED(CONFIG_UNICODE) + &tmpfs_attr_casefold.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; +} +#endif /* CONFIG_SYSFS && CONFIG_TMPFS */ + void __init shmem_init(void) { int error; @@ -5149,6 +5209,14 @@ void __init shmem_init(void) goto out1; } =20 +#if defined(CONFIG_SYSFS) && defined(CONFIG_TMPFS) + error =3D tmpfs_sysfs_init(); + if (error) { + pr_err("Could not init tmpfs sysfs\n"); + goto out1; + } +#endif + #ifdef CONFIG_TRANSPARENT_HUGEPAGE if (has_transparent_hugepage() && shmem_huge > SHMEM_HUGE_DENY) SHMEM_SB(shm_mnt->mnt_sb)->huge =3D shmem_huge; @@ -5546,65 +5614,3 @@ 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) - -#define __INIT_KOBJ_ATTR(_name, _mode, _show, _store) \ -{ \ - .attr =3D { .name =3D __stringify(_name), .mode =3D _mode }, \ - .show =3D _show, \ - .store =3D _store, \ -} - -#define TMPFS_ATTR_W(_name, _store) \ - static struct kobj_attribute tmpfs_attr_##_name =3D \ - __INIT_KOBJ_ATTR(_name, 0200, NULL, _store) - -#define TMPFS_ATTR_RW(_name, _show, _store) \ - static struct kobj_attribute tmpfs_attr_##_name =3D \ - __INIT_KOBJ_ATTR(_name, 0644, _show, _store) - -#define TMPFS_ATTR_RO(_name, _show) \ - static struct kobj_attribute tmpfs_attr_##_name =3D \ - __INIT_KOBJ_ATTR(_name, 0444, _show, NULL) - -#if IS_ENABLED(CONFIG_UNICODE) -static ssize_t casefold_show(struct kobject *kobj, struct kobj_attribute *= a, - char *buf) -{ - return sysfs_emit(buf, "supported\n"); -} -TMPFS_ATTR_RO(casefold, casefold_show); -#endif - -static struct attribute *tmpfs_attributes[] =3D { -#if IS_ENABLED(CONFIG_UNICODE) - &tmpfs_attr_casefold.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.47.0