From nobody Tue Nov 26 06:46:22 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 61B221EABDA; Mon, 21 Oct 2024 16:38:17 +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=1729528699; cv=none; b=A8rFH6n9YPZPHIJKD5dhF2821K0qp22zGYdPcJy+vxdewGyHEDtzq1mL6DhF06FxUer7EzOjSNwZ/+XL1FnYZyQitT0eiADJR52cyDM0J/d60fVLXHBI/K8ezmZkMQJfVhBP5JK+oSQAGggSWsDQ6jYzxBeWnvAZut1ZQ0bLY8Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729528699; c=relaxed/simple; bh=FMH5TUOquAKQUbGz2hzZZXDeLjI1URI181+5P3DsnuI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LF+N02eIFSH49XeWsh7JHxH0NGv5vqtM6v/uZ80RVVe8EL01+YsPgeYeB8qGK2+pbjs0xodRm2JB1jb8+P4uqLGaMbgLfgWAhR9QtQ8WapLvkyuGGqh6IKc+sTyd6Bb5RkEC+ywloYH/l800iY8FQI1jiZBmuo6XRGQ9NbiN3uo= 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=ng3tGDT4; 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="ng3tGDT4" DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Cc:To:In-Reply-To:References:Message-Id: Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:Date: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=SbTvLQbuG7yeLrygZxqm3PkbVldfcIwV1lI2HDmaGB0=; b=ng3tGDT4cx9xfXAgnjbczk8AVt 8VDuXwyw4Nz7jqIThpbDd5tui0FNOI/+nvnS1lw9Jov8iFzGRpkVK+PaeceBs8GE1eh9uKxeGT7Iu nGGX3uWpKbFTnYT7zWcK+X+DpbOjFg+O3xObm6DP+quVe3X0RP/k6QyJY0yUTp3dITyGt6X2VQT54 p9LSsgj7k2hB3qISbYBFcNhnA445dYuOKRzcNN0ZFJ59n/3bek/jxYUdIq8RwX3+mCvPpcIvYsG3Z 1bOrLwofFZXvPLWeOjsweF7w0AuOLQKuwSzlKH83sNHYtRCI9lwN2F4Zro3Zb10FMJ5u0PM/ARfY1 lGRkU2Hg==; Received: from [191.204.195.205] (helo=[192.168.15.100]) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1t2vQ7-00DECf-5L; Mon, 21 Oct 2024 18:38:15 +0200 From: =?utf-8?q?Andr=C3=A9_Almeida?= Date: Mon, 21 Oct 2024 13:37:24 -0300 Subject: [PATCH v8 8/9] tmpfs: Expose filesystem features via sysfs 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 Message-Id: <20241021-tonyk-tmpfs-v8-8-f443d5814194@igalia.com> References: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> In-Reply-To: <20241021-tonyk-tmpfs-v8-0-f443d5814194@igalia.com> To: Gabriel Krisman Bertazi , Alexander Viro , Christian Brauner , Jan Kara , Theodore Ts'o , Andreas Dilger , Hugh Dickins , Andrew Morton , Jonathan Corbet , smcv@collabora.com Cc: kernel-dev@igalia.com, linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org, linux-ext4@vger.kernel.org, linux-mm@kvack.org, linux-doc@vger.kernel.org, =?utf-8?q?Andr=C3=A9_Almeida?= , Gabriel Krisman Bertazi X-Mailer: b4 0.14.2 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 ea01628e443423d82d44277e085b867ab9bf4b28..0739143d1419c732359d3a3c345= 7c3acb90c5b22 100644 --- a/mm/shmem.c +++ b/mm/shmem.c @@ -5546,3 +5546,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.47.0