From patchwork Thu Apr 24 21:41:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076926 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TNA1yZ0T; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=ldu3=xk=vger.kernel.org=linux-ext4+bounces-7468-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Y24H1dz1yN2 for ; Fri, 25 Apr 2025 07:40:54 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8YN0ZBFz4wyk for ; Fri, 25 Apr 2025 07:41:12 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8YN0Vk5z4xD3; Fri, 25 Apr 2025 07:41:12 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530872; cv=pass; b=ecbCQe6Mg29Zwl76MNih5hC/87KpjRL214Vjc+ZxV+rb8YVBSpUbp7qFBGiz1dGgAUCcRESrqpk6VaAUZBjqEo9OvvLs6mgBIkh/SPUVsKR65N+FVZKSCpUc8aPFkNzbjj1As5wjNvBZEbMs7/EGctPlhrxru0MWC0xHwm9dpFxp/o27JLjIIYhNaTsUyWJBWYGIYmyuUe+hIAJWxTDQRJ00jm1MFx6uayLmHqMCDhqrVClxSzjeNuSWxoK1+50P++/D+NK/7IRQ/uz7QTAnpLEb08kQpdsThbyoIIU6uXeG0tdTIr/Od5+HvN9KnFW8xWNlgzMHyOcCplg6f8cZcQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530872; c=relaxed/relaxed; bh=7B6HqkJTGwwW7mfchcQD08lAz/xxNu9DkKbDtYd+fwg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=aBB3g7+D5P/3NKRQ2R1kew8q7WflSqxIxbkf2/BZhVp2BeZajDD+DngLeemaI2vjzuve7UGaKil4y2kGaykl4OT0og1Aon7hBievVcC4ScwzcOU+1AMnHbd7cZwSCmvHnvxCBjAa2zupbmiY9xSPkNwYVqF7IHDJ1mdE5fW1RlkziejnV8ov9YuFVWpnvZKb+amu05XoyaKd+5NLOg0YZOwP2YkktVpWKfiTCh6YPjeP4R/SLun9uG9V7M/o0AzPjk59AmrAwzPLsUOzWzlLr6e8EyR4pyqOilYihzE9oNortYPXRi5NnaBAoXM0cDSTh7c9igtIetTFsApNIZUAzg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TNA1yZ0T; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TNA1yZ0T; dkim-atps=neutral Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8YJ65v9z4wyk for ; Fri, 25 Apr 2025 07:41:08 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 6E8953BBF7B for ; Thu, 24 Apr 2025 21:40:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2560B21D3E3; Thu, 24 Apr 2025 21:41:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TNA1yZ0T" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 DA432199949 for ; Thu, 24 Apr 2025 21:41:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530863; cv=none; b=gFmlhGwmihk5OKKCuruzYI2umUb7ch03zY6BKKoFJ9PVXEyC1sQERHDCt49PXUMOJ3DAfVaXnvier4TXxFtCRUFJsgx9RX4xmX+t2WNgitRTBkQyOMAQ5jEj7FVv8Bjks2417DSgzSxSqVMjLgjJGrhh26jKNrrgioGutYrzrUo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530863; c=relaxed/simple; bh=aGNVkF9Gwp5vxHu1+fKNEWQdyG9neVlz9EZ8RDACgaA=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eo6/G/t4VuG1FFeHGek92551Wu+oxLqIM5zoXTHg7MUDsIm4Db9eRgg2kE0FjSq6FVitN2X0gYLCpuAbsr4ylIRMJiO1Z8I18BJvXqnFG/HCsuFz4UCxfHGLEkwWayCNK93RW3AUISqMTDAozqXPLbmP6ukmqcqIaSi+5pFsGwA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TNA1yZ0T; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 4735DC4CEE3; Thu, 24 Apr 2025 21:41:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530863; bh=aGNVkF9Gwp5vxHu1+fKNEWQdyG9neVlz9EZ8RDACgaA=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=TNA1yZ0TUE5QRVj5YQzU0CWpfE0W2JqaoxopTnULm3gQq1mSgOf2czFqJzmcmzDZc rWeufncMrKeT31/i1/1SlzQ08Qu1XMx5yrJHV/P0A3JdAGKwwh2JOwYV9NjRsSL6UG 3GH6yn+askkc9Uu64Xmn+ICb4VmNjYi6md2+gqiyEmiQeV+RJnZgnjk/QGSy8NLEDz ahJMPpxRT9CR7X8QY3sfh2CuvE+ukxfLMOPn3r+6TGuq28c/dsyJyVoD+CDltxwKxU JRiFeGgra+j4Jp0NzlRAuVsUCwepq3CxAsPdY2fVD1nBKw+v3r04kkqud9NV6YSJ3R K1eQMutKo9+pA== Date: Thu, 24 Apr 2025 14:41:02 -0700 Subject: [PATCH 01/16] fuse2fs: refuse unsupported features From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064943.1160461.14810321477577468832.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Don't mount a filesystem with superblock features that we don't actually know how to support. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index f974171d3e726d..5a92e54031a8b7 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3902,6 +3902,26 @@ int main(int argc, char *argv[]) ret = 3; + if (ext2fs_has_feature_quota(global_fs->super)) { + err_printf(&fctx, "%s", _("quotas not supported.")); + goto out; + } + if (ext2fs_has_feature_verity(global_fs->super)) { + err_printf(&fctx, "%s", _("verity not supported.")); + goto out; + } + if (ext2fs_has_feature_encrypt(global_fs->super)) { + err_printf(&fctx, "%s", _("encryption not supported.")); + goto out; + } + if (ext2fs_has_feature_casefold(global_fs->super)) { + err_printf(&fctx, "%s", _("casefolding not supported.")); + goto out; + } + + if (ext2fs_has_feature_shared_blocks(global_fs->super)) + fctx.ro = 1; + if (ext2fs_has_feature_journal_needs_recovery(global_fs->super)) { if (fctx.norecovery) { log_printf(&fctx, "%s\n", From patchwork Thu Apr 24 21:41:18 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=m3V8kEBj; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=oi7m=xk=vger.kernel.org=linux-ext4+bounces-7469-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8YP0X2sz1yN2 for ; Fri, 25 Apr 2025 07:41:13 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8Yk3wrhz4wyk for ; Fri, 25 Apr 2025 07:41:30 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8Yk3tGyz4xD3; Fri, 25 Apr 2025 07:41:30 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:4601:e00::3" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530890; cv=pass; b=pAHtkLIranvlUdv2jwVMpF1/+tIUDNzeX2wPIj49/Lml457eRdOfPFF4UNB7v/25r4wA4O/QnS/KiFWBl51S3LEsm7MYCa61MZntQ9U/LHYG45a9YZMF/cYywtYd/q7fDmL2BvE6UWVIg8rygtTEHndNcV5Upct/SE4jCgquTEY6gn/QJhlJ1ID7S+uUtRaVM/XAaTTGu5AscJyj5xcsLsVjSqj0W7Df/31VMfZ/BWtDifEmD8g1yY4LsNvdSc7SnqXIl3qkErZ/kTklOHEgmRwnS9JgpMNE4OFroT/ipFow6hNcn9Pe9hcNZwCEfpuc5ueKZU4ZQVYu4s8RpIOvbQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530890; c=relaxed/relaxed; bh=uOnzFN+ZX0aNclE4gNwnglpTDmnjux2A8km+AsQLMp8=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=eoxKO9th6zxWFpdis7nre5dV3MP5rm08cBTX2In8Vn76cYDL1eNb8atsbmHROOHkRxXjAWnTFF1JN0+uA6ZNotdnF23LU7yjhXsrWKgF9qNp5z2fdXtsWpqk3K3MaTh3mRlo4awa2BEfJXUcL5AVDtZd0jeqgRd9Ax6Kk9XvaRpm1VOO0N9yNYT69UEC9f3gwjqgqwi1z6AzOK3Q/8UM2MLPvn7w2/UGHbtRF9cAgc4Cp8Mxi20tN32X5++vCaghWCcThlZR+X1sjC2tQH3wJN9ntL2aLllXivihxPyI5rJMTObWOF82TANGURWuBgQ+0WesXzMwnS5SbZMgUu8Nvg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=m3V8kEBj; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=m3V8kEBj; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8Yg0frVz4wyk for ; Fri, 25 Apr 2025 07:41:27 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 85CB21B82DD1 for ; Thu, 24 Apr 2025 21:41:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 61CCD1F4297; Thu, 24 Apr 2025 21:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="m3V8kEBj" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 22DE5198851 for ; Thu, 24 Apr 2025 21:41:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530879; cv=none; b=G/+XZCk88rfXOK54m+H+H4V10LwTdZIPxrh2UGK4fHVxmLs7qaPQ0PeOaooUPTa1iAmk20lqC1U0A/z/YcAHViY2ldUKHZq4rUQFfhy7K+YlACZeIyjOJBDotZGxTFrUNPI5qVq9g4E8yR7mhW6Qa9c5oRxnT9AH8SIcNSDQxdg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530879; c=relaxed/simple; bh=7OMDSKRAX383h6SIuAw74KK4e78c1PHpR2HJA7capr0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=U1UxafFnGWgHD+Gp7Np5tPwg2Uz+ZLh++H6QVINi2S21G2DEhT9rC5g7ZPVxJ/lTXyhUf87OngUqgjx5aU36dzD1BEIPrC/Ua4hFp+258vbMBqrx9bqcdpwM8LtCX/qFnpkQb3iEmPHX+QSRlxFPUtwL9NX9SUyPo6EfGqJtyeA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=m3V8kEBj; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id E390BC4CEE3; Thu, 24 Apr 2025 21:41:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530879; bh=7OMDSKRAX383h6SIuAw74KK4e78c1PHpR2HJA7capr0=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=m3V8kEBjfLf8iNEmVpAn3Hg99aNWb6LInXlJM/VTWPqmcc2YmZbnFExBrXZZQ8OqV GeOHHXUdlM4liUhYbGwPEe+qLAyFNhTcN97DT5Cu/6cVWYCcrf09/RlLNXFMM9UNiF tqpwysituvAR8LbDgchADDocbdnyhtdqFceZcSnjqIryAodYlcZcTzj35YM1tQWJRu 7PV36kb9a0wDTDk8hq6lfezEEygsJIhx6IcMIz2C5aHBAV0YqC6sZPVd5uEWFHmsJn jI+wClDFLvYkFeYNYqh/gzxCPD7mHTyK3Bfcya+OfHXV8dCmPfn63hIhEIiz7Ug/7w mwdFRJNvh9hCA== Date: Thu, 24 Apr 2025 14:41:18 -0700 Subject: [PATCH 02/16] fuse2fs: return -EOPNOTSUPP when we don't recognize a fallocate mode From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064961.1160461.9412670014664878384.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong If we don't recognize a set bit in the mode parameter to fallocate, return EOPNOTSUPP to communicate that we don't support that mode instead of EINVAL. This avoids unnecessary failures in generic/521 such as: generic/521 - output mismatch (see /var/tmp/fstests/generic/521.out.bad) --- tests/generic/521.out 2025-01-30 10:00:16.898276477 -0800 +++ /var/tmp/fstests/generic/521.out.bad 2025-04-03 14:46:20.019822396 -0700 @@ -1,2 +1,9 @@ QA output created by 521 +zero range: 0x407ca to 0x52885 +do_zero_range: fallocate: Invalid argument Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 5a92e54031a8b7..e5f3cec083c0f5 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3630,7 +3630,7 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, /* Catch unknown flags */ if (mode & ~(FL_PUNCH_HOLE_FLAG | FL_KEEP_SIZE_FLAG)) - return -EINVAL; + return -EOPNOTSUPP; pthread_mutex_lock(&ff->bfl); if (!fs_writeable(fs)) { From patchwork Thu Apr 24 21:41:34 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076928 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=eaeRE0zC; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=denp=xk=vger.kernel.org=linux-ext4+bounces-7470-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Yd3gTfz1yN2 for ; Fri, 25 Apr 2025 07:41:25 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8Yz02HQz4wyk for ; Fri, 25 Apr 2025 07:41:43 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8Yz00Jgz4xD3; Fri, 25 Apr 2025 07:41:43 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=139.178.88.99 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530902; cv=pass; b=bcCA2R9r6b6IC86f24A6TpCPXaFigs8GdsExOx3lBji5TGjKU7sVN8SacDodE+tjgIKJ6Sjnk2D5ZDK4+UAf9ehw1G4/NfDei9QJ4RxIoKG6DcQOYmQmlyMptDTDo1gSHeLubkXSyyROdkHwXeCkXXTqARkIkaqF/gTYwfkq8QP9lw5WveBFHLq51rUIRU3p+TLAwU4V5IPUQRu4IwPyBHVGnD5AaE2vMcLoEkISSGqeTTwX9hLRmNRKQv4g+lQzd+cxY4pvCOIg3u/MPIqaHe4zzFqeAEUgzQtofpn9Jy+Rp0V7qY+9TUBGHXJpsfb2SucT2U74Uzzv88/sL5nZOA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530902; c=relaxed/relaxed; bh=bCmopPAN3QEK8MhKpiZIdUpU4OEDRactyGxX4t1WUwY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=dI6+9NavwtfVD2dfda1JuX8wAQULzas0AdFELtlXe6iUuLi3okO3ZYcH2aNxqkiv6lZR4A1TU423emxtbG88mvnO5+i2yF7hz1A9fhLwid/yhqQ17sDbHfjaJsAW+lxDCRgXPWrZV8plnVTrFDbyeq04sz2+7PllPgOdtAUcjmLvD6iw8jFAGI0ksz0x3iZkecwg8zFvV4g9dJ4t5qMMt1oaCQkEr7BxKIr5WYTFi2tHw4H16O+AZHbw9M8dUbzUEe1UUQT9NVtccNzbkhcCC6hh+J56gdKW+yV6c+iyyC3BI3aAdeiWAxV0iZGDpPtG8hv4ZMaq/4sjOerbQodCtQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=eaeRE0zC; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=eaeRE0zC; dkim-atps=neutral Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8Yv5s6Rz4wyk for ; Fri, 25 Apr 2025 07:41:39 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 64CAB3BB99F for ; Thu, 24 Apr 2025 21:41:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E946421E087; Thu, 24 Apr 2025 21:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="eaeRE0zC" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 A65A4198851 for ; Thu, 24 Apr 2025 21:41:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530894; cv=none; b=C/iNpUw79JCl+7Zz5a/MJKLCtM+qWzM3DlDTkMGlWNLUft1uGWB88ZS2Y7WfuBSmBssv3vvOnO7J8RTcCzamWtHmHug45hM/VYuOu5i5fBrmq8KzF3bQyOypJPbaSOhbXQoTTS9B9gMwb075uMDQArQhQFjpbeM/KdfalxevcEw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530894; c=relaxed/simple; bh=vC+a9wc5odosz5bMxn0skrpmfTWOrjXyr1Cy7onlWlQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=UxcJ9ZTaKuRX5znnbx256pKkW2uL3G5MDeNfxjCyaH06FqscoUvD+WzrnJvuKQAaBimAAqHZLhJyYqhogstnxPv2R8aqb6UyzO8+5LvAqLVtRIvhIkhqIEfW1B0kjp3cZbiDF37EiNYDVZUJKIHXqE9FGUHBYpfdFXjqxXuJQD8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=eaeRE0zC; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7DCC4C4CEE3; Thu, 24 Apr 2025 21:41:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530894; bh=vC+a9wc5odosz5bMxn0skrpmfTWOrjXyr1Cy7onlWlQ=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=eaeRE0zCKUVDam5j3O4ezznAoEg/0OK4IhbCP0mZPVBSq+gp5/8TCsbxulhJV2O37 38ewLmh6USfO2F79D/nmjU2z55vzTxeFNkfpf/7cyF15J++urbcudHbRm5MUww/ZmW agjyTegckQbbqM9rEjSdymCluoi8xU4/wiKBljYhDboCzNwMxnYnArzHbTNZvrE6aw ADuQLXNEkX5CU8SO5e0jZ/5gip52jVppNxkGJEMaEBcu04IhAtKu0a7Uh0mcPnN5IA ZTYXIVPzp/ECc6oG9rLD8J8EavAgpdwpWVCXbNGEs+kNDvMAUi9+NTcQ9p3tJB0HdY QgBiSHHkOBkoA== Date: Thu, 24 Apr 2025 14:41:34 -0700 Subject: [PATCH 03/16] fuse2fs: implement zero range From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064980.1160461.9850792727586596449.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Implement FALLOC_FL_ZERO_RANGE. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index e5f3cec083c0f5..4f3074261d0f53 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -123,6 +123,12 @@ static ext2_filsys global_fs; /* Try not to use this directly */ # define FL_PUNCH_HOLE_FLAG (0) #endif +#ifdef FALLOC_FL_ZERO_RANGE +# define FL_ZERO_RANGE_FLAG FALLOC_FL_ZERO_RANGE +#else +# define FL_ZERO_RANGE_FLAG (0) +#endif + errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs); #ifdef CONFIG_JBD_DEBUG /* Enabled by configure --enable-jbd-debug */ @@ -3619,6 +3625,16 @@ static int punch_helper(struct fuse_file_info *fp, int mode, off_t offset, return 0; } +static int zero_helper(struct fuse_file_info *fp, int mode, off_t offset, + off_t len) +{ + int ret = punch_helper(fp, mode | FL_KEEP_SIZE_FLAG, offset, len); + + if (!ret) + ret = fallocate_helper(fp, mode, offset, len); + return ret; +} + static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, off_t offset, off_t len, struct fuse_file_info *fp) @@ -3637,7 +3653,9 @@ static int op_fallocate(const char *path EXT2FS_ATTR((unused)), int mode, ret = -EROFS; goto out; } - if (mode & FL_PUNCH_HOLE_FLAG) + if (mode & FL_ZERO_RANGE_FLAG) + ret = zero_helper(fp, mode, offset, len); + else if (mode & FL_PUNCH_HOLE_FLAG) ret = punch_helper(fp, mode, offset, len); else ret = fallocate_helper(fp, mode, offset, len); From patchwork Thu Apr 24 21:41:49 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076929 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=kKeTEFtp; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=ig2t=xk=vger.kernel.org=linux-ext4+bounces-7471-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Yz41Z2z1yN2 for ; Fri, 25 Apr 2025 07:41:43 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8ZK0KZTz4xD3 for ; Fri, 25 Apr 2025 07:42:01 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8ZK0HKMz4xM3; Fri, 25 Apr 2025 07:42:01 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=139.178.88.99 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530921; cv=pass; b=LEqVvkvFi1+z+3GUprYeRLTHnA3QaDwYdKmco0YcIYnR1uhd3uaPHre9QE0naQz7uqWXh/uP2xnrWrobx27HuHN6mMjmm//3E69DAbK6HySNDAZ9/utLFAX00ch2kxmmzNlqfNJGAotg3QEh/rDv7nFbYCT7o82Sv+AKN1v+QB/KqNbKKqK1h/gFDift7R2IW/A2v3djO8iC+vG5IEgAnCSrbneYHE715E4/gnRQtaP2FmPfkO+wyqivyCNcJF5yEpRgMPKv+DIX0aDpfdrsKyUhB+raZ3dKAaumNaygD6VIQslCjijUI2RsAWhiXOdVnUWqtwnqiVUWTGm5ppXoHA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530921; c=relaxed/relaxed; bh=Pgcpn1fOjoQbMlU0rT9fwVRc6iZdFNuaBXZOtMi7egY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TYclKr9C0VoBcUUqWVmIu9dXwnCTZ6lDsqOGrabrg0sXE6xQd1gRS8EhTmy/Q3nNRcbHmjPk3yLxStvJWIIAULVhlLuNw/Kf2o8QDVXGpBoiIfIHkRyFaTB5cO8azV3QK1sRkqg7BxK1N6bPzXz8GE/zYrjWd2ZMnevCdsQ4CmZlgIsbnan7uUCZW9bmeosrXUmBxnmEEgJsHUP1DxYBIEI/1n3HInAm6Fx6yghf3CX+JAFXwcSrZMkAeMGjKVMWfJfdpVwugA3vt0GLas6ggDrQ2YSdtQL1SR1Oav7prEKiut2tkGJIP0qQ3trSfam2Q2rTxhrqa2ZrTg4b6YxRLA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=kKeTEFtp; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=kKeTEFtp; dkim-atps=neutral Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8ZF5qFBz4xD3 for ; Fri, 25 Apr 2025 07:41:57 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5FF6F3BB99F for ; Thu, 24 Apr 2025 21:41:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id ECCBE2222C5; Thu, 24 Apr 2025 21:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kKeTEFtp" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 AC9FA1F4297 for ; Thu, 24 Apr 2025 21:41:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530910; cv=none; b=CknbnyxnQkS6rW5YORlXfj2EPrRhe19YEczjjhMufuvdTpxeiOT03tui1fMxrWUDteC6vI/ys/TF/RYmXiGsbAWZt3zHtD/YBynRdXKShbkWjgER9YsPfWoqZq/jR7J4H8+fH0desnb+JqL+NhQLPE3R+GPaM+5EqCEMPCamfTM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530910; c=relaxed/simple; bh=eeFN9BzuZlvUZE5pS6q0XdCN+Q53JkaU+InlCJNRRRE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=GP+FCRjtmxfQuUKG3SvszWT8XHToXlqQWDjTZ6o0MHH8+3kXWdFF98lOxnUkC2Gm1tIVfqY5mdCH9vLZOYFJb9FmgMENpCiMPiFdB2+aL3/DjdZOutk6oZ2sV5Wqpd2QUtEYUYwAW9goRedVeAIyyCU6dtyhiH+awamoU9Cdzm8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=kKeTEFtp; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 21755C4CEE3; Thu, 24 Apr 2025 21:41:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530910; bh=eeFN9BzuZlvUZE5pS6q0XdCN+Q53JkaU+InlCJNRRRE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=kKeTEFtpPl3kyPRLjviHyOGiircDA2+8sn48Xi1y/xxADCxZ/ywEPtf2hfSYNtOMa dVIJVBqyEm6MKJQTVukIuSLgTA/wlAb0EcoZKK3uOf3FliANBEOJoB5n6r3l63Jy2g Z2OtDzxYl13jzg43KVIDnjBgi3QYICkZlauSTHwZkYF1YHwt1DQ/SlqJ4TqyBkRuCy 1Hdse+c7mPKYbjh/6//sYaIo7sRevof59J19962yVt3+rheUAfzakHHHuPaFwgoIii Q80qPt7g+PAMwwie3chAxZ7la18mhXDHVRMi/NEw/qd431+GGALHkQ/UulZNDlm3WT bH4EchX6thuwg== Date: Thu, 24 Apr 2025 14:41:49 -0700 Subject: [PATCH 04/16] fuse2fs: remove posix acl translation From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553064997.1160461.14235157932332388225.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Remove the POSIX ACL format translation since libext2fs takes care of that now. Fixes: 0ee1eaf70c257e ("libext2fs: translate internal ext4 acl to Posix ACL in ext2fs_xattr_[sg]et()") Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 267 +------------------------------------------------------- 1 file changed, 4 insertions(+), 263 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 4f3074261d0f53..5de6562ff97ecd 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -17,12 +17,6 @@ # include # include # include -# ifdef HAVE_SYS_ACL_H -# define TRANSLATE_LINUX_ACLS -# endif -#endif -#ifdef TRANSLATE_LINUX_ACLS -# include #endif #include #include @@ -135,206 +129,6 @@ errcode_t ext2fs_run_ext3_journal(ext2_filsys *fs); int journal_enable_debug = -1; #endif -/* ACL translation stuff */ -#ifdef TRANSLATE_LINUX_ACLS -/* - * Copied from acl_ea.h in libacl source; ACLs have to be sent to and from fuse - * in this format... at least on Linux. - */ -#define ACL_EA_ACCESS "system.posix_acl_access" -#define ACL_EA_DEFAULT "system.posix_acl_default" - -#define ACL_EA_VERSION 0x0002 - -typedef struct { - u_int16_t e_tag; - u_int16_t e_perm; - u_int32_t e_id; -} acl_ea_entry; - -typedef struct { - u_int32_t a_version; -#if __GNUC_PREREQ (4, 8) -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wpedantic" -#endif - acl_ea_entry a_entries[0]; -#if __GNUC_PREREQ (4, 8) -#pragma GCC diagnostic pop -#endif -} acl_ea_header; - -static inline size_t acl_ea_size(int count) -{ - return sizeof(acl_ea_header) + count * sizeof(acl_ea_entry); -} - -static inline int acl_ea_count(size_t size) -{ - if (size < sizeof(acl_ea_header)) - return -1; - size -= sizeof(acl_ea_header); - if (size % sizeof(acl_ea_entry)) - return -1; - return size / sizeof(acl_ea_entry); -} - -/* - * ext4 ACL structures, copied from fs/ext4/acl.h. - */ -#define EXT4_ACL_VERSION 0x0001 - -typedef struct { - __u16 e_tag; - __u16 e_perm; - __u32 e_id; -} ext4_acl_entry; - -typedef struct { - __u16 e_tag; - __u16 e_perm; -} ext4_acl_entry_short; - -typedef struct { - __u32 a_version; -} ext4_acl_header; - -static inline size_t ext4_acl_size(int count) -{ - if (count <= 4) { - return sizeof(ext4_acl_header) + - count * sizeof(ext4_acl_entry_short); - } else { - return sizeof(ext4_acl_header) + - 4 * sizeof(ext4_acl_entry_short) + - (count - 4) * sizeof(ext4_acl_entry); - } -} - -static inline int ext4_acl_count(size_t size) -{ - ssize_t s; - - size -= sizeof(ext4_acl_header); - s = size - 4 * sizeof(ext4_acl_entry_short); - if (s < 0) { - if (size % sizeof(ext4_acl_entry_short)) - return -1; - return size / sizeof(ext4_acl_entry_short); - } - if (s % sizeof(ext4_acl_entry)) - return -1; - return s / sizeof(ext4_acl_entry) + 4; -} - -static errcode_t fuse_to_ext4_acl(acl_ea_header *facl, size_t facl_sz, - ext4_acl_header **eacl, size_t *eacl_sz) -{ - int i, facl_count; - ext4_acl_header *h; - size_t h_sz; - ext4_acl_entry *e; - acl_ea_entry *a; - unsigned char *hptr; - errcode_t err; - - facl_count = acl_ea_count(facl_sz); - h_sz = ext4_acl_size(facl_count); - if (facl_count < 0 || facl->a_version != ACL_EA_VERSION) - return EXT2_ET_INVALID_ARGUMENT; - - err = ext2fs_get_mem(h_sz, &h); - if (err) - return err; - - h->a_version = ext2fs_cpu_to_le32(EXT4_ACL_VERSION); - hptr = (unsigned char *) (h + 1); - for (i = 0, a = facl->a_entries; i < facl_count; i++, a++) { - e = (ext4_acl_entry *) hptr; - e->e_tag = ext2fs_cpu_to_le16(a->e_tag); - e->e_perm = ext2fs_cpu_to_le16(a->e_perm); - - switch (a->e_tag) { - case ACL_USER: - case ACL_GROUP: - e->e_id = ext2fs_cpu_to_le32(a->e_id); - hptr += sizeof(ext4_acl_entry); - break; - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_MASK: - case ACL_OTHER: - hptr += sizeof(ext4_acl_entry_short); - break; - default: - err = EXT2_ET_INVALID_ARGUMENT; - goto out; - } - } - - *eacl = h; - *eacl_sz = h_sz; - return err; -out: - ext2fs_free_mem(&h); - return err; -} - -static errcode_t ext4_to_fuse_acl(acl_ea_header **facl, size_t *facl_sz, - ext4_acl_header *eacl, size_t eacl_sz) -{ - int i, eacl_count; - acl_ea_header *f; - ext4_acl_entry *e; - acl_ea_entry *a; - size_t f_sz; - unsigned char *hptr; - errcode_t err; - - eacl_count = ext4_acl_count(eacl_sz); - f_sz = acl_ea_size(eacl_count); - if (eacl_count < 0 || - eacl->a_version != ext2fs_cpu_to_le32(EXT4_ACL_VERSION)) - return EXT2_ET_INVALID_ARGUMENT; - - err = ext2fs_get_mem(f_sz, &f); - if (err) - return err; - - f->a_version = ACL_EA_VERSION; - hptr = (unsigned char *) (eacl + 1); - for (i = 0, a = f->a_entries; i < eacl_count; i++, a++) { - e = (ext4_acl_entry *) hptr; - a->e_tag = ext2fs_le16_to_cpu(e->e_tag); - a->e_perm = ext2fs_le16_to_cpu(e->e_perm); - - switch (a->e_tag) { - case ACL_USER: - case ACL_GROUP: - a->e_id = ext2fs_le32_to_cpu(e->e_id); - hptr += sizeof(ext4_acl_entry); - break; - case ACL_USER_OBJ: - case ACL_GROUP_OBJ: - case ACL_MASK: - case ACL_OTHER: - hptr += sizeof(ext4_acl_entry_short); - break; - default: - err = EXT2_ET_INVALID_ARGUMENT; - goto out; - } - } - - *facl = f; - *facl_sz = f_sz; - return err; -out: - ext2fs_free_mem(&f); - return err; -} -#endif /* TRANSLATE_LINUX_ACLS */ - /* * ext2_file_t contains a struct inode, so we can't leave files open. * Use this as a proxy instead. @@ -2451,30 +2245,6 @@ static int op_statfs(const char *path EXT2FS_ATTR((unused)), return 0; } -typedef errcode_t (*xattr_xlate_get)(void **cooked_buf, size_t *cooked_sz, - const void *raw_buf, size_t raw_sz); -typedef errcode_t (*xattr_xlate_set)(const void *cooked_buf, size_t cooked_sz, - const void **raw_buf, size_t *raw_sz); -struct xattr_translate { - const char *prefix; - xattr_xlate_get get; - xattr_xlate_set set; -}; - -#define XATTR_TRANSLATOR(p, g, s) \ - {.prefix = (p), \ - .get = (xattr_xlate_get)(g), \ - .set = (xattr_xlate_set)(s)} - -static struct xattr_translate xattr_translators[] = { -#ifdef TRANSLATE_LINUX_ACLS - XATTR_TRANSLATOR(ACL_EA_ACCESS, ext4_to_fuse_acl, fuse_to_ext4_acl), - XATTR_TRANSLATOR(ACL_EA_DEFAULT, ext4_to_fuse_acl, fuse_to_ext4_acl), -#endif - XATTR_TRANSLATOR(NULL, NULL, NULL), -}; -#undef XATTR_TRANSLATOR - static int op_getxattr(const char *path, const char *key, char *value, size_t len) { @@ -2482,9 +2252,8 @@ static int op_getxattr(const char *path, const char *key, char *value, struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; ext2_filsys fs; struct ext2_xattr_handle *h; - struct xattr_translate *xt; - void *ptr, *cptr; - size_t plen, clen; + void *ptr; + size_t plen; ext2_ino_t ino; errcode_t err; int ret = 0; @@ -2526,17 +2295,6 @@ static int op_getxattr(const char *path, const char *key, char *value, goto out2; } - for (xt = xattr_translators; xt->prefix != NULL; xt++) { - if (strncmp(key, xt->prefix, strlen(xt->prefix)) == 0) { - err = xt->get(&cptr, &clen, ptr, plen); - if (err) - goto out3; - ext2fs_free_mem(&ptr); - ptr = cptr; - plen = clen; - } - } - if (!len) { ret = plen; } else if (len < plen) { @@ -2546,7 +2304,6 @@ static int op_getxattr(const char *path, const char *key, char *value, ret = plen; } -out3: ext2fs_free_mem(&ptr); out2: err = ext2fs_xattrs_close(&h); @@ -2664,9 +2421,6 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; ext2_filsys fs; struct ext2_xattr_handle *h; - struct xattr_translate *xt; - const void *cvalue; - size_t clen; ext2_ino_t ino; errcode_t err; int ret = 0; @@ -2705,26 +2459,13 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), goto out2; } - cvalue = value; - clen = len; - for (xt = xattr_translators; xt->prefix != NULL; xt++) { - if (strncmp(key, xt->prefix, strlen(xt->prefix)) == 0) { - err = xt->set(value, len, &cvalue, &clen); - if (err) - goto out3; - } - } - - err = ext2fs_xattr_set(h, key, cvalue, clen); + err = ext2fs_xattr_set(h, key, value, len); if (err) { ret = translate_error(fs, ino, err); - goto out3; + goto out2; } ret = update_ctime(fs, ino, NULL); -out3: - if (cvalue != value) - ext2fs_free_mem(&cvalue); out2: err = ext2fs_xattrs_close(&h); if (!ret && err) From patchwork Thu Apr 24 21:42:05 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076930 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=vEwBzH3y; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=ua3i=xk=vger.kernel.org=linux-ext4+bounces-7472-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8ZD4pvQz1yN2 for ; Fri, 25 Apr 2025 07:41:56 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8ZZ16Nsz4xD3 for ; Fri, 25 Apr 2025 07:42:14 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8ZZ14N5z4wyk; Fri, 25 Apr 2025 07:42:14 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45e3:2400::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530934; cv=pass; b=QPZk3+HIa9kEne+Wz9ZToVkr26jUQGyocUElqwTDoA13eAMYa47DEnPuDxVC+lQLc6zSQwZowgRDoKWQxtKQ6/KLgjtyLW9BKumZp7t1Tx3cJWDbYxKqq2bUTZch+ZxJhmsE9GEbRUNuSy7aD08AXzK85jZG16xytnSMIjafNAfRs0u6+8nESpsmAg6urvvwxe7mMPssHQQknUAAcrFCTxCREIWTmh2QACTQtNLaDqWSDBTihH57+Xtlm+zHG9hddgNt5nVqSF3Bik4Di0cbIDqx1FM93valvI6kd0lfJmJSH27QqhCAPwTAn0wbMjkAxlIeGnXGQTLZjo9bf4h1Gw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530934; c=relaxed/relaxed; bh=Zr/xhvHH+FZTmvYyOG88rhAUyrwi4JALINWjwMIXWII=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=JjgOXXVL8W2T558/U/vt+8PV1tE1ERneJFwYDTYAkyePqlZqOdapTWH63mm4Dzb379sMm+5FqH2JqY3pq0bNXPcqz4/7cA0oeWNnSnnXCxPro/Vp5na2vkNNHQbZDtVn3Gyq7SL30JTZUjkH1MUzcXGAdrjKH5Tm2i77flMGm0ItEe4vFM/5ufLIITBUD5HRZlMSTmTu7Ft2liirrZKSY8hnI4oyfWoRQb/evJiLP9E6PF6YqaRfOh8isPxADn8ai74K+bFCIRblBZoiCnq8NQRQ2QYoy3iyFskfUyb4gYvdLYStiaVyosIz56CAk0Ye8W8SvL7kuyyEXa2e3rvXmg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=vEwBzH3y; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=vEwBzH3y; dkim-atps=neutral Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [IPv6:2604:1380:45e3:2400::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8ZV6wRvz4xD3 for ; Fri, 25 Apr 2025 07:42:10 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 89F663BD82D for ; Thu, 24 Apr 2025 21:41:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2FAF821D3E3; Thu, 24 Apr 2025 21:42:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="vEwBzH3y" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E4384198851 for ; Thu, 24 Apr 2025 21:42:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530926; cv=none; b=kMNjggc/Vo8s6faraSq7wU/49QXh7vO55s3BRgAmsJzj1mp3YniuEaBm2e/A+Bj2/49rglNsodgSIpdoFOvTtVSM4l8RFVTXR9MrnGsov9JEyr9T3nMHP56cs7d+hiAoOXNEw6WrPtmydTeERYEOGC/Z21tkkRQi8Kyh0Hq6z9E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530926; c=relaxed/simple; bh=jWeBc0koSNIJqO5MUwn9WWNEUxvr5fVfH4obk/mpjtU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ajt0wn0RYvodLFI1Ai1aCeqLA/CpK1gVHNhc+ssAs2SyXvxlJDh7MnQOP208BvbwCZDiXSUw2o2r+0B5rpIbqDm9NK+6rK5z23sdJibu01hG5cmLJ+/AUFCGtkFidXAVLfQUJ4MHN905bY7+Wjh3cBk67e4R0fyNN95tnaP/JMM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=vEwBzH3y; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id B8E3BC4CEE3; Thu, 24 Apr 2025 21:42:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530925; bh=jWeBc0koSNIJqO5MUwn9WWNEUxvr5fVfH4obk/mpjtU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=vEwBzH3yKdaZKGHjwr3eUhHzDzvNpwybZkCo4HixiojeL7xtPI6+Ijgxbp/nEUAQ7 UtstMhgqpBr+XDi6PoFVVijTT0Gv0W3jgkEIq94+vGPg5JJ6p9NyEMG00/9B+WnP4o xAiqv2JDLOZQoD/R3/+XtCDUixcZ7UKxDdOslHfIF8iKxxGbOO1cJh6j/x+jmPNc27 WuvBRRbkikkjdr9VRpWpWhEPMQt8stE7mzz1e/TS1jlW0EtHUDiXeyLpFhjfiew0Av M24M1eAA7STtQGFNZZDJS8OShNM5+5BG0zlSdwAhZw1xZixzS8gapWtogelmuy4f0b gPd4UuoJgImzQ== Date: Thu, 24 Apr 2025 14:42:05 -0700 Subject: [PATCH 05/16] fuse2fs: log names of xattrs being set/get/removed From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065016.1160461.12942341433377716292.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Actually record the names of the xattrs being modified to make it easier to debug fstests failures. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 5de6562ff97ecd..f499231dd04c94 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -2271,7 +2271,7 @@ static int op_getxattr(const char *path, const char *key, char *value, ret = translate_error(fs, 0, err); goto out; } - dbg_printf(ff, "%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d name=%s\n", __func__, ino, key); ret = check_inum_access(fs, ino, R_OK); if (ret) @@ -2438,7 +2438,7 @@ static int op_setxattr(const char *path EXT2FS_ATTR((unused)), ret = translate_error(fs, 0, err); goto out; } - dbg_printf(ff, "%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d name=%s\n", __func__, ino, key); ret = check_inum_access(fs, ino, W_OK); if (ret == -EACCES) { @@ -2504,7 +2504,7 @@ static int op_removexattr(const char *path, const char *key) ret = translate_error(fs, 0, err); goto out; } - dbg_printf(ff, "%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d name=%s\n", __func__, ino, key); ret = check_inum_access(fs, ino, W_OK); if (ret) From patchwork Thu Apr 24 21:42:20 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=LmvIYlKs; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=ytba=xk=vger.kernel.org=linux-ext4+bounces-7473-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8ZZ0Mtsz1yN2 for ; Fri, 25 Apr 2025 07:42:14 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8Zv3pSHz4wyk for ; Fri, 25 Apr 2025 07:42:31 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8Zv3mFKz4xD3; Fri, 25 Apr 2025 07:42:31 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.48.161 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530951; cv=pass; b=ptfxp7he6yG3EYvWDf3ZPSc7NUM0BnndNGAmfr/nJa93uTYrI7zfZw5y4wnT1Y5by0XeyT3/YJbMKxpT7uUYSpz4JVIuvBoco0h4fiqORivES2rixLyx2YVTmrAK4AdeCm23JqJKHrgJcyVejgvVwBMXLTFpZdsc1/wHgowcAtbD5bloSuNu7xuo8ecNOCmvO/J1bMY75fnmKjX2O4EkdRSxfABen1y/NmjTIMEufJDSfzcgb4T5HPXGksdjLEbP+9q3FJpqZFxh0kZAvDHNx8FnZEJoGdpm9Ip4sE9jZ8GS2NZCMkrdL9lmUzYMPWTgCNKKl4Td2ERqDhUgIdqjMA== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530951; c=relaxed/relaxed; bh=+WG6hxPmnzE48FJ2DL/87ZsCKxlnPg7ld7U1Nq9KziQ=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=g81TZflB3jplsjEwydSvlltfttJIcs3lZMrQhlV0AgL/Vbg4Liwv9yftqcbpbfVf8O2fcfgKUxZIemZPNoqwKgUhlGp7f6unYBMKxR2uk2KPFjG2Qx+dTas965N/PBvPGAXY4IPD2Qe5fUVJj/rbPXQwcOvL5MeM4v1mco6Etkbf5Zyb7OKD/YjChR07DFKgXErkGY55SJaGawMgnKM5dt+64r+3bC61DGfR5djK/mFHEE8BajgSTkonj+4yKCamEHbW1ceO0IPPvmfmtcjfgIIOMcyp5UGbNgsL8+tvIDAM/gmkctKaERU1lB7cgMDwCN8dVfwUtCsEjsCg0bwE3w== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=LmvIYlKs; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=LmvIYlKs; dkim-atps=neutral Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8Zr4DSTz4wyk for ; Fri, 25 Apr 2025 07:42:28 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8C42D7AAA07 for ; Thu, 24 Apr 2025 21:41:18 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3164F21E087; Thu, 24 Apr 2025 21:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="LmvIYlKs" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 E5F781F4297 for ; Thu, 24 Apr 2025 21:42:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530942; cv=none; b=kUdLcaJuY0QqBN/QdnGeWnBXGNTG0SPZ9Z+SWxb0FzLLIRg3n1rIaTQKvl05Wk7JlfvXpz6WJSprzlKiW8KA3U+DoVNov3qy1dBdW+IXrWy0kSorIMe5oUSYzXAetdIt92QXyAgts0Tg6Hbsr+lpu51h3rKuu0AZqHyMh0RCge8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530942; c=relaxed/simple; bh=zJWCn8dBm22R53cf3QymTm7R9y/cFHogHseBh1pO7AY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=hUqE76gzXNK92ZVHEUXu3+i+AzZVHAw9w3bMnYeFEv1F1LDfRLJ+dc+uN5vkLV4c7IiyjKOn4Y1xR+nB+7XxQSKlYzjzpiDGKz04mQ8CnEmTDOTotQQc08a44hg57DpLw96UKG1rnYvjn5+DrHL2X54bIosb8ApvVYcEjLx6SzA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=LmvIYlKs; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5CB67C4CEE3; Thu, 24 Apr 2025 21:42:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530941; bh=zJWCn8dBm22R53cf3QymTm7R9y/cFHogHseBh1pO7AY=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=LmvIYlKsMrTbNyWRyeDZPjRUz2ADd1fmqEGmf3O8iTPO5bPLU/EvUo5Ms5JwLM9iR G2Az/cMEl0D2gQzhFKR05+hISYosSphszdtscQeazEzWPeWJZ7eYJGz+zoT/vn/tAD cCHDucdewd3WeQMMGGAFbGB1jQz2S3x4QXzq6CjbmWwce31L7lp8JUk4WJxDup6tQv mEvVXjkGN2Ls1MIbYPWxGsLNHaucNVisAcxmg9vzwjuc4pxZ92BZQ+4RP5DSnFdiyW BsDGqmKETn0QJqU9+jCwSpV4lSoVpx19RlQz1tFXu1kG8rVd8wv9GSihIm6NsV8R0z pu3eMS+LWBZtQ== Date: Thu, 24 Apr 2025 14:42:20 -0700 Subject: [PATCH 06/16] fuse2fs: add an easy option for emulating kernel access behaviors From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065033.1160461.1393760776420459221.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong By default, fuse doesn't allow processes with a uid/gid that don't match those of the server process to access the fuse mount, it doesn't allow suid files or devices, and it relies on the fuse server to perform permissions checking. This is a secure default for very untrusted filesystems, but it's possible that we might actually want to allow general access to an ext4 filesystem as part of containerizing the ext4 metadata parsing. In other words, we want the kernel access control behavior. Add an "kernel" mount option that moves most of the access permissions interpretation back into the kernel, and logs mount/unmount/error messages to dmesg. Right now this is mostly useful for fstests, so we leave it off by default. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.1.in | 9 +++++++++ misc/fuse2fs.c | 30 ++++++++++++++++++++++++++++++ 2 files changed, 39 insertions(+) diff --git a/misc/fuse2fs.1.in b/misc/fuse2fs.1.in index 1a0c9d54f5893a..517c67ff719911 100644 --- a/misc/fuse2fs.1.in +++ b/misc/fuse2fs.1.in @@ -53,6 +53,15 @@ .SS "fuse2fs options:" .TP \fB-o\fR fuse2fs_debug enable fuse2fs debugging +.TP +.BR -o kernel +Behave more like the kernel ext4 driver in the following ways: +Allows processes owned by other users to access the filesystem. +Uses the kernel's permissions checking logic instead of fuse2fs's. +Enables setuid and device files. +Note that these options can still be overridden (e.g. +.I nosuid +) later. .SS "FUSE options:" .TP \fB-d -o\fR debug diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index f499231dd04c94..d56d51207d1f25 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -52,6 +52,7 @@ #endif #include "../version.h" +#include "uuid/uuid.h" #ifdef ENABLE_NLS #include @@ -156,6 +157,7 @@ struct fuse2fs { int fakeroot; int alloc_all_blocks; int norecovery; + int kernel; unsigned long offset; unsigned int next_generation; }; @@ -556,6 +558,13 @@ static void op_destroy(void *p EXT2FS_ATTR((unused))) if (err) translate_error(fs, 0, err); } + + if (ff->kernel) { + char uuid[UUID_STR_SIZE]; + + uuid_unparse(fs->super->s_uuid, uuid); + log_printf(ff, "%s %s.\n", _("unmounting filesystem"), uuid); + } } static void *op_init(struct fuse_conn_info *conn @@ -589,6 +598,13 @@ static void *op_init(struct fuse_conn_info *conn } if (ff->debug) cfg->debug = 1; + + if (ff->kernel) { + char uuid[UUID_STR_SIZE]; + + uuid_unparse(fs->super->s_uuid, uuid); + log_printf(ff, "%s %s.\n", _("mounted filesystem"), uuid); + } return ff; } @@ -3506,6 +3522,7 @@ static struct fuse_opt fuse2fs_opts[] = { FUSE2FS_OPT("no_default_opts", no_default_opts, 1), FUSE2FS_OPT("norecovery", norecovery, 1), FUSE2FS_OPT("offset=%lu", offset, 0), + FUSE2FS_OPT("kernel", kernel, 1), FUSE_OPT_KEY("acl", FUSE2FS_IGNORED), FUSE_OPT_KEY("user_xattr", FUSE2FS_IGNORED), @@ -3551,6 +3568,8 @@ static int fuse2fs_opt_proc(void *data, const char *arg, " -o offset= similar to mount -o offset=, mount the partition starting at \n" " -o norecovery don't replay the journal\n" " -o fuse2fs_debug enable fuse2fs debugging\n" + " -o kernel run this as if it were the kernel, which sets:\n" + " allow_others,default_permissions,suid,dev\n" "\n", outargs->argv[0]); if (key == FUSE2FS_HELPFULL) { @@ -3636,6 +3655,13 @@ int main(int argc, char *argv[]) } stderr = fp; stdout = fp; + } else if (fctx.kernel) { + /* in kernel mode, try to log errors to the kernel log */ + FILE *fp = fopen("/dev/ttyprintk", "a"); + if (fp) { + stderr = fp; + stdout = fp; + } } /* Will we allow users to allocate every last block? */ @@ -3762,6 +3788,10 @@ int main(int argc, char *argv[]) #endif } + if (fctx.kernel) + fuse_opt_insert_arg(&args, 1, + "-oallow_other,default_permissions,suid,dev"); + if (fctx.debug) { int i; From patchwork Thu Apr 24 21:42:36 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=WJUMV3yi; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=gutu=xk=vger.kernel.org=linux-ext4+bounces-7474-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8Zs235kz1yN2 for ; Fri, 25 Apr 2025 07:42:29 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8bB5Vvkz4wyk for ; Fri, 25 Apr 2025 07:42:46 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8bB5SZlz4xD3; Fri, 25 Apr 2025 07:42:46 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45d1:ec00::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530966; cv=pass; b=w/YBSeC1vLs04zDjvWnW6LjOf72OPhEdo5nOyjeF8nl7vxGp307RW75UlcqqpLL/BKMLuzMWNM9cAOnbt5UaULwJhh42KLdUi8Wy4WI6mdI+6C8UdDXbbkq/DoVuGNpHe9l58T4wI4+S4WUywibBMpC1hv4gj9l2IeFGX5BtHe0Oh8lDpE5UwL/Ik8sLzhHg00gvWcclNCEhaXB8PCHUCs3tnT9grbGl3zomYz7kpsV//FgsNh+IvImmkHsMZiH56auA1FTaoaG0WM6mC6qOXMp14WDV0jip4e5j8Sri++WYl/tqIWzN8OFcYdQTt2DK8kVqBncUF/SXO7kmCWr+qQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530966; c=relaxed/relaxed; bh=h0NWaqCOLByuAOo8DBd5kMHJS1Zy2utZKWU+0osdfCI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=tbXtAovtWh6aXRJxLCBHCM/jYW4H0t/bd+hqyMGP5wEtDw/cfUwbI36+TKzXrOnORJVSfNrhTywxRDeoTqDJLFbl6ZO/wqHyUdxb7yzD3rwfthdGkwhk8gmst5qWxdzvS+4Az76mq3sWJF0XVXUnoe/isPRhK9NJ+IzuBqRPFNLpo9U4btnX/CZQLxhIAPanLjlgrf932nDxYZLKng1vh1OCiZhJ74qZimfuAxnSKqgaxZiqjhPpjZvs4XBVfRStiVG40cEAb2GSpKs/lkuUWML70B+iZJ42NdiSSzg2VCCgvai744ijxP3oxad8ugzscu1AtgwEwnpGA1MyJcMF3Q== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=WJUMV3yi; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=WJUMV3yi; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8b730mgz4wyk for ; Fri, 25 Apr 2025 07:42:43 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id C8AD816C42D for ; Thu, 24 Apr 2025 21:42:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B53C21D3E3; Thu, 24 Apr 2025 21:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="WJUMV3yi" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 2AA36198851 for ; Thu, 24 Apr 2025 21:42:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530957; cv=none; b=rCxCW8B7P3jv3e7b8z6b8wUWrZ9ANW1jgr+VdlJNqXrzI9EtE/I2q4Vfe3/NOTunxv0+iZHFwz7Uz+fwQ7HwmUtkGKaXGB5g6n9+69OmE2n/I+r8sAoZitQqpugjy/qDmuTLAIFob5fZuletMUX3CFTbz6N0FOEHtJclps28RTw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530957; c=relaxed/simple; bh=hfSbPHxvzK2ie1tDWhDt2mANUHzXZfQHNwkeRxQ17lU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=E344q9elIKjszyZGblD4ynhEKWfDUx469hcOuy/lILIL3x7MJt2t2z+PHG9VnwJRO/NWxxOPLCMx7+1/ruZAIRgiU0bEQFTDdXhY3BczRdIqDApUqfshWGC+6FXQmXIRSLdDBwOzJ2oJu8E9tJlZz+F+Y3u/kxSV0PvKvpK016M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=WJUMV3yi; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 0118FC4CEE3; Thu, 24 Apr 2025 21:42:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530957; bh=hfSbPHxvzK2ie1tDWhDt2mANUHzXZfQHNwkeRxQ17lU=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=WJUMV3yiIg2zKNnLguim090rXRfy3GatOfvxIB5n+Sd46/fkMOyQt2dr5Jpxo9V7C 443RV1AGVc7JaYGz4sO+T/sZ5W5h7GcMOzTcsBupsFfcX9CRcLkzTN5lpbPOvm0puk ZgrTroE7OarGBGCqnyknEITLdyAHayI6p1VIy69GpBLNSieeQGlrVJFhPNEYNPj2M7 MUpTrrXXqSSTYnJYUYKC1bu1NiCNZBKnlw0TUqSkfQ6ZiKTta3kZ4dXLfBSfOIQiF4 wPlTWhhv4K0/GpWzXrGK0XJ2U3O+vw9lr+oHWAY9CRHcpKymbzYC6P8UgbvDB4lQK6 8+v7751vZXrJg== Date: Thu, 24 Apr 2025 14:42:36 -0700 Subject: [PATCH 07/16] fuse2fs: report nanoseconds resolution through getattr From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065051.1160461.5080284869849276746.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Report the nanonseconds component of timestamps via getattr, and tell fuse that we actually support nanosecond granularity. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index d56d51207d1f25..bf4e592e7d2782 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -586,6 +586,9 @@ static void *op_init(struct fuse_conn_info *conn dbg_printf(ff, "%s: dev=%s\n", __func__, fs->device_name); #ifdef FUSE_CAP_IOCTL_DIR conn->want |= FUSE_CAP_IOCTL_DIR; +#endif +#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) + conn->time_gran = 1; #endif if (fs->flags & EXT2_FLAG_RW) { fs->super->s_mnt_count++; @@ -635,10 +638,13 @@ static int stat_inode(ext2_filsys fs, ext2_ino_t ino, struct stat *statbuf) (struct ext2_inode *)&inode); EXT4_INODE_GET_XTIME(i_atime, &tv, &inode); statbuf->st_atime = tv.tv_sec; + statbuf->st_atim.tv_nsec = tv.tv_nsec; EXT4_INODE_GET_XTIME(i_mtime, &tv, &inode); statbuf->st_mtime = tv.tv_sec; + statbuf->st_mtim.tv_nsec = tv.tv_nsec; EXT4_INODE_GET_XTIME(i_ctime, &tv, &inode); statbuf->st_ctime = tv.tv_sec; + statbuf->st_ctim.tv_nsec = tv.tv_nsec; if (LINUX_S_ISCHR(inode.i_mode) || LINUX_S_ISBLK(inode.i_mode)) { if (inode.i_block[0]) From patchwork Thu Apr 24 21:42:52 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UcraiIWc; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=pdma=xk=vger.kernel.org=linux-ext4+bounces-7475-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8bB44R2z1yN2 for ; Fri, 25 Apr 2025 07:42:46 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8bX0N1Bz4x6n for ; Fri, 25 Apr 2025 07:43:04 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8bX0LCSz4xD3; Fri, 25 Apr 2025 07:43:04 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.80.249 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530984; cv=pass; b=abMuUK2/FO/88lrdTXw2EGr0JHqKOTc5wPE54BGNcpn3ypqZU2PUS2W02+9/k+ozpxcA3cMBMIzJrLVFgOIWHr+1oCmsYmp3PYRnCaU9yUyDlHwP5R4AJ2K7NhJc0vMJe+BDmVhRcuIxTkUythRPEz2FixfgFKY8/t4VP+wu27V/9InKj8PDaIaOz1LyI7ubn+vmkca4lL9PuWCqIvDO06iAUS44YFIZp2PJwMSrnTogBk/X+Yjzz5P4Yw9UiEC6YhMSDtPPy/DSnnhZ68tq9I97VmPyUsJXT8Jvut7JDlst7iI79TktUM8UG2gfbgWyx50B8ghp7sVT9W5FCa2fiQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530984; c=relaxed/relaxed; bh=HfgVnDZYQgCCc7r5ttvt+IrJmidLV4DxbogHcp+WnKM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=B7X7SYpXlFN/OdnAElkviqWTdgtnQnvsZ2f+O5rIs8dV6A9OBu2hKyXKW0T8eEht/pcFK+Jq62YlqK8HsE0Z8FsAXpHbotKBK08MUIjQCiyWb55f3cV8vL5NMB0AyeZXzPdDU7tR4lRLyNkmFFvtG2BCGGHDPYWfIQvHYQsnt3DNnhfPy27CIV4ql5qP2ZBrUbl11zb9eOnOlB942cElC8SMMUOdrxZ8yFQ2JcnNhRTyJyWUdmhRSYwcIF2I7zB7y/MsK5VAnSsgX52MzGXsVoa5rKDs8Oh4XTU2N3FQLrsXtUvBA0S57KFn0+l5h2NzxcZ9c4p4gcWdWmq6y+ihxA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UcraiIWc; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=UcraiIWc; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8bS4p4nz4x6n for ; Fri, 25 Apr 2025 07:43:00 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1618B1BA38D2 for ; Thu, 24 Apr 2025 21:43:10 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 11DB321E087; Thu, 24 Apr 2025 21:42:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="UcraiIWc" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C64BD198851 for ; Thu, 24 Apr 2025 21:42:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530972; cv=none; b=T3W5k9r2hPxLTCdz84CtyXWTE+6tc8QTNND0ep2CN3jfkRW+n3p5t/hZZ6UboI00dIKiuMcXpRKedUmsi4vE2k+LW9Y+Bm4VFuqvXGM5pYMbwd94KbEUjQcZFi9CxUV8fb1pgCjzmjUUCP4olt4+WW8jQUogbC0DGPaD1brJi2Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530972; c=relaxed/simple; bh=D3geD668dYQCYWALjajm4BVmx4d0jul3yq8hsw1QP1M=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=lmRKXkDGoiLENz+RG5zHnuAinuzG9rXkzTqQe1xDShDRB0mCMgk2p6Qef6CRcnHb6XS5JClgyc8nYXqSnbBPiS+FALyz/TvTOlXwWI1FeWEcmHXURhe5Lgrwks1dx6gZzKGQylyFl6tmo649o0X0XND29IwaBH1CsQgmY3OIdRA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=UcraiIWc; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 9DBA5C4CEE3; Thu, 24 Apr 2025 21:42:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530972; bh=D3geD668dYQCYWALjajm4BVmx4d0jul3yq8hsw1QP1M=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=UcraiIWc8hX7yCzQv1ZkUUmU5ekPfpBnGtNr9/613nttI03IqZwEy6L1MJOGnAsvq p0xyGc6nIUtiMRWItQ6tJac+jOb5D0FFLVLcqP3NcL+wrzJnVKeQCBY+mC2c/a9HLq E8u6dOGKipuGNqxoBRhSOkH/Cuc+n7ZLoZqlSAjtpBsOLjOsNAhPO+AglhEEy3lrUv U3fqAeWg6P4yn3MSrjNV3NEO43cnHZSgE3PXoJ/PeGHgwbZ6odIq5h576uSsVqD80j SNhjypABnEZepzUfM+1NwILaJ+Ub9h1bwNYkoQKrukv42WkQgOSS83ovihZGsyf078 GAnH+zptVifVA== Date: Thu, 24 Apr 2025 14:42:52 -0700 Subject: [PATCH 08/16] fuse2fs: clamp timestamps that are being written to disk From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065069.1160461.14751120886781323020.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Clamp the timestamps that we write to disk to the minimum and maximum values permitted given the ondisk format. This fixes y2038 support, as tested by generic/402. Signed-off-by: "Darrick J. Wong" --- lib/ext2fs/ext2_fs.h | 4 ++++ misc/fuse2fs.c | 39 ++++++++++++++++++++++++++++++++------- 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/lib/ext2fs/ext2_fs.h b/lib/ext2fs/ext2_fs.h index 3a5eb7387d0c9d..fcd42055665788 100644 --- a/lib/ext2fs/ext2_fs.h +++ b/lib/ext2fs/ext2_fs.h @@ -801,6 +801,10 @@ struct ext2_super_block { #define EXT2_GOOD_OLD_INODE_SIZE 128 +#define EXT4_EXTRA_TIMESTAMP_MAX (((int64_t)1 << 34) - 1 + INT32_MIN) +#define EXT4_NON_EXTRA_TIMESTAMP_MAX INT32_MAX +#define EXT4_TIMESTAMP_MIN INT32_MIN + /* * Journal inode backup types */ diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index bf4e592e7d2782..9cf8c59b8b88ee 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -227,21 +227,43 @@ static inline void ext4_decode_extra_time(struct timespec *time, __u32 extra) time->tv_nsec = ((extra) & EXT4_NSEC_MASK) >> EXT4_EPOCH_BITS; } +#define EXT4_CLAMP_TIMESTAMP(xtime, timespec, raw_inode) \ +do { \ + if ((timespec)->tv_sec < EXT4_TIMESTAMP_MIN) \ + (timespec)->tv_sec = EXT4_TIMESTAMP_MIN; \ + if ((timespec)->tv_sec < EXT4_TIMESTAMP_MIN) \ + (timespec)->tv_sec = EXT4_TIMESTAMP_MIN; \ + \ + if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) { \ + if ((timespec)->tv_sec > EXT4_EXTRA_TIMESTAMP_MAX) \ + (timespec)->tv_sec = EXT4_EXTRA_TIMESTAMP_MAX; \ + } else { \ + if ((timespec)->tv_sec > EXT4_NON_EXTRA_TIMESTAMP_MAX) \ + (timespec)->tv_sec = EXT4_NON_EXTRA_TIMESTAMP_MAX; \ + } \ +} while (0) + #define EXT4_INODE_SET_XTIME(xtime, timespec, raw_inode) \ do { \ - (raw_inode)->xtime = (timespec)->tv_sec; \ + typeof(*(timespec)) _ts = *(timespec); \ + \ + EXT4_CLAMP_TIMESTAMP(xtime, &_ts, raw_inode); \ + (raw_inode)->xtime = _ts.tv_sec; \ if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) \ (raw_inode)->xtime ## _extra = \ - ext4_encode_extra_time(timespec); \ + ext4_encode_extra_time(&_ts); \ } while (0) #define EXT4_EINODE_SET_XTIME(xtime, timespec, raw_inode) \ do { \ + typeof(*(timespec)) _ts = *(timespec); \ + \ + EXT4_CLAMP_TIMESTAMP(xtime, &_ts, raw_inode); \ if (EXT4_FITS_IN_INODE(raw_inode, xtime)) \ - (raw_inode)->xtime = (timespec)->tv_sec; \ + (raw_inode)->xtime = _ts.tv_sec; \ if (EXT4_FITS_IN_INODE(raw_inode, xtime ## _extra)) \ (raw_inode)->xtime ## _extra = \ - ext4_encode_extra_time(timespec); \ + ext4_encode_extra_time(&_ts); \ } while (0) #define EXT4_INODE_GET_XTIME(xtime, timespec, raw_inode) \ @@ -2884,7 +2906,10 @@ static int op_utimens(const char *path, const struct timespec ctv[2] ret = translate_error(fs, 0, err); goto out; } - dbg_printf(ff, "%s: ino=%d\n", __func__, ino); + dbg_printf(ff, "%s: ino=%d atime=%lld.%ld mtime=%lld.%ld\n", __func__, + ino, + (long long int)ctv[0].tv_sec, ctv[0].tv_nsec, + (long long int)ctv[1].tv_sec, ctv[1].tv_nsec); ret = check_inum_access(fs, ino, W_OK); if (ret) @@ -2908,9 +2933,9 @@ static int op_utimens(const char *path, const struct timespec ctv[2] #endif /* UTIME_NOW */ #ifdef UTIME_OMIT if (tv[0].tv_nsec != UTIME_OMIT) - EXT4_INODE_SET_XTIME(i_atime, tv, &inode); + EXT4_INODE_SET_XTIME(i_atime, &tv[0], &inode); if (tv[1].tv_nsec != UTIME_OMIT) - EXT4_INODE_SET_XTIME(i_mtime, tv + 1, &inode); + EXT4_INODE_SET_XTIME(i_mtime, &tv[1], &inode); #endif /* UTIME_OMIT */ ret = update_ctime(fs, ino, &inode); if (ret) From patchwork Thu Apr 24 21:43:07 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076934 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sIsXLX+X; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=pfj6=xk=vger.kernel.org=linux-ext4+bounces-7476-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8bS1V3kz1yN2 for ; Fri, 25 Apr 2025 07:43:00 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8bn4w2gz4x6n for ; Fri, 25 Apr 2025 07:43:17 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8bn4swcz4xD3; Fri, 25 Apr 2025 07:43:17 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45d1:ec00::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530997; cv=pass; b=NsrcftCouK6AGGm7FwZ3xu1NpwUySDOI0VErLv7pkHvgBP8oZ1sy1BXmZk0tbEDA6btG9USSIJ2WIQvMkzTAGnkgxBEEsynFTopXzTmVm+YVYMw1JKFIwl8PYiQ9ErfEDOMbmMCfXuVH0GS5YQFcRWPMKRCO5d3tOU1QS/1khMO+ozgwy6S/KVqOGf0gKnsM5drbnsB3Vr3Y0i92d0oP0So1TgmGtSXRl+GF5VuwFfvfSecGI363+gH9gk0//mp7H5lemoQ0ibKCnkodMuJI0mtiu59h1W9OJnZSbSbxv79XwQZekmeOygvyVO6DPh6Ja4WtViKfS+wDlOlqd2p3BQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745530997; c=relaxed/relaxed; bh=zNo3pFwd3XvjaoZX6eiY4ozxNKajRZthliLb/V0NxgU=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=jgQX1GdheXqjmGB7mUmGlD7TqAsxtlOshHYyToBLjPiQJ3z9duAC0OAGh4UzTtYbNWRE06C2B92T+l5ZMAr0xqdUItyPrRIZ9T1aF5eLGUTy3rgH7u7R0PbKS4Tod0dl1CF2hEs6IKprPhIG2EUGbXnuEwJ0lKPPNiR1CDXh+RLu4LL9aKcQuuHoFE6nd8rXCvprVRZ6UmpnyKTK47QAznqbsC0y+DDkzBXPaj9GQ3+RVvchjrK3UqREm6S1857ezkrrTBeZmyCvyuTcdsrxWqfd9fTNMWNHI6pnki11ApKbWOurh5WWBlozcXvB2U821Bdcpo5Fs8IB4fq57a8DZQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sIsXLX+X; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=sIsXLX+X; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8bk2Tjtz4x6n for ; Fri, 25 Apr 2025 07:43:14 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id B8A011789BB for ; Thu, 24 Apr 2025 21:43:13 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A51B321D3E3; Thu, 24 Apr 2025 21:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="sIsXLX+X" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 65B99198851 for ; Thu, 24 Apr 2025 21:43:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530988; cv=none; b=Ekh//hdtYm46Cr41PmARYfj/mRNhfopWSXGXDX0fzjp/7kZ2bi+0w7jJWT4PBm6VXrB6VWIJs/haZvYmlVUW9Z37jV7EseZcQ212hGzu4SoRNfqFZ1tWn+iK4UflEi6JlFr7UBT3cS5pC0hWSpRQuLLZoFIbSoNafcx+pBdwzXQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745530988; c=relaxed/simple; bh=yYFuAfYsVL3y5Fan6j006h23grJ71vIIkI7i5BU+aFc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Tz01KkPJ7PkDqrTmVl0Oe7jUvXb9nHdDLHat+xrMeM7dXSAqWGt464t0DHS6WwFYKDFggOMUg/TT67Jhx69rGjIDGVlXRNJOIZx33QV3n1z7Z/U/s7KsG8PHx30KTF36i48Tfo5o+U46uCHxrK8YB0HpsOK0VAKy0IEq7dpxxZM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=sIsXLX+X; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3B48CC4CEE3; Thu, 24 Apr 2025 21:43:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745530988; bh=yYFuAfYsVL3y5Fan6j006h23grJ71vIIkI7i5BU+aFc=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=sIsXLX+XjMV8ml2iQ8vQeF2B8hsioYc0X6248saMFsmxPNSXJqagGrCqdQgAznFs8 icRGTKfE6CNDCNSdo3lgOswYYeKVLybKRm4lGIjomGq8SB/4WQjwypUZAHyhej5cle r6sOpv3gXpsaBNRODHQgBRBHHcQPXvrj0DU9oWR8pxXQZ1tm/H/1aoMqaLp6e6OA2v FHcsvVcbz/Y/MudLGDnTEjRX97Tfx2mc5rfhJYMbG8C9UUx4r06UBsATPBb8N00PVf uoX0Xd1nCll5WZ9KT/GGOE5ngHY78Fev6/+ZrnzmNushuewypI88pTYET6uRl7DlAO Hp/sc7ttws7NQ== Date: Thu, 24 Apr 2025 14:43:07 -0700 Subject: [PATCH 09/16] fuse2fs: add supportable mount options from the kernel From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065087.1160461.16716917319493753291.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Add all the kernel mount options that we can actually support. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 9cf8c59b8b88ee..9e416e8af77e1b 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3548,15 +3548,18 @@ static struct fuse_opt fuse2fs_opts[] = { FUSE2FS_OPT("rw", ro, 0), FUSE2FS_OPT("errors=panic", panic_on_error, 1), FUSE2FS_OPT("minixdf", minixdf, 1), + FUSE2FS_OPT("bsddf", minixdf, 0), FUSE2FS_OPT("fakeroot", fakeroot, 1), FUSE2FS_OPT("fuse2fs_debug", debug, 1), FUSE2FS_OPT("no_default_opts", no_default_opts, 1), FUSE2FS_OPT("norecovery", norecovery, 1), + FUSE2FS_OPT("noload", norecovery, 1), FUSE2FS_OPT("offset=%lu", offset, 0), FUSE2FS_OPT("kernel", kernel, 1), FUSE_OPT_KEY("acl", FUSE2FS_IGNORED), FUSE_OPT_KEY("user_xattr", FUSE2FS_IGNORED), + FUSE_OPT_KEY("noblock_validity", FUSE2FS_IGNORED), FUSE_OPT_KEY("-V", FUSE2FS_VERSION), FUSE_OPT_KEY("--version", FUSE2FS_VERSION), From patchwork Thu Apr 24 21:43:23 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076935 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=IQCIWPdV; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=2tib=xk=vger.kernel.org=linux-ext4+bounces-7477-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8bp5qN7z1yN2 for ; Fri, 25 Apr 2025 07:43:18 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8c82695z4x6n for ; Fri, 25 Apr 2025 07:43:36 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8c823fnz4xD3; Fri, 25 Apr 2025 07:43:36 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:4601:e00::3" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531016; cv=pass; b=lGPceraOoCXDdR27fXuqx3+W5UIIaMKIRaforM4z/wV+iC8X8l3Z1ZUy9GlEMlEoc+EG5RmawN5JJNMq2Ftqj2k5twFT/Zorq8uxq83s5DFUyz5Xso0CxpfuSii82mxO/izkuOsmwtRdhibWjI+ZYjGRiFRRopAeG7d5PzUa4UDXoVC6oyXuzFpArBoTbn4HGH28ZOuL03ThMYV0P3k+s1EECEnpVtJDwiOMv0DN33pVCh/J2r/nXTwqRu6A/XB9f3PdS65qdzKSehNUIgtpG1LUbniZ/KI8+kOqvD0M1Tqi+bJdTefTHTTj94Bgtt2FWFF9f9CMtNzG29fUmEWQZQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531016; c=relaxed/relaxed; bh=ocgfyKeEWSa4zFuIpMNsTY4shztRn6PzLtmYKDWkbr0=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=uK3HyXIzLTkvTuF3FEQjoDjpzY+aJ03I5Hr96Yazh56slJD9iP8wkx8SIwXiz7b+QVs0/tOpzWtlGl+C+NIIxYsS2k+Jldmy30GtFgQz0Qst1WriKEyKnzDHEHY6jK6iM98Rx9n8slwRV6N4oXsiSBh8BcHPnrb4JnT+JnZGkzeAi7399pBLFXRG/jgcG8499c6SamtfYONWzE1FM3qyRTEbsfT2KaqiQpD2ZhsGGMdFr38wL0K1SfTyGod+ZkEcD4VTlu3U8cIlysyi2U2Qt3lMv5hTPX6+5YaMYD8syvOqCj7C53b8303+RWiWZEjmr5ADPlcnAG3SGHWuVPAATQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=IQCIWPdV; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=IQCIWPdV; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [IPv6:2604:1380:4601:e00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8c46PzSz4x6n for ; Fri, 25 Apr 2025 07:43:32 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 1425A1BA38DE for ; Thu, 24 Apr 2025 21:43:42 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AF4E921D3E3; Thu, 24 Apr 2025 21:43:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="IQCIWPdV" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 6F103198851 for ; Thu, 24 Apr 2025 21:43:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531004; cv=none; b=hKraNupSbzqVaiu8cRXLgrJhEtnA//LxrwAsz3SGho5PXfaAyWG3WxFJ3DaT5zePFXpr09RZt7PIocB3Fj1PhLUiKm0yPClp2o5ER57ZikJZK4UjCI2Xrhp5u3q/b27yVhbcCqWs0CTY/g17MY6SyhQLjHgNCB0mqaa1tbBG+DA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531004; c=relaxed/simple; bh=+Awq1YT89VTAg6ap62FaTcQtIg1BtLcGTpp3WzJUxOI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=SA9J1NO8OSYvvg3sGayO6yEbuzdUpWS25Rff6jqAP2j65fYjQ8+M5bVc9CRf9Luv+yVQ+lgh2oCuuwl1EyVJyZBRWv+Sug6hm4IPRuJx6FTgg7luABTeahuZiHij0L9UipTFIUQYOK0mz2WUMu1RyUvHTexMAi8r++jXp0R9B5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=IQCIWPdV; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC830C4CEE3; Thu, 24 Apr 2025 21:43:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531003; bh=+Awq1YT89VTAg6ap62FaTcQtIg1BtLcGTpp3WzJUxOI=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=IQCIWPdVGVJRPzvJCkuF7MvVHJUsZsOj+/PT/krCrhU548HJzpnxfX8bMujMJggCU IG7WA0aymXuHbXMy81xnbaY6CSUtFAQk/CSXJwxEVGI6sedM8IbRnzNliA7lDap0sK d8+Hkab/RHA0Evm/ghiOeDvofg7isWFInW6w6c3kwE78wQnbxxMdtCM2GE5VekhYVB t46Z1JJSk+KjoE+bSTs9UbYk5OFsOitWdBKM/7SiJbK3HAs/IDsB8y0qXMbGBZG7Kg WfhXn8ct2cF4oEJFbT36QWzq5DRUG65KCmrbWNIabplheYd1BfAk7Pz9qIlz/0tffp QsJKdk9u/1b/g== Date: Thu, 24 Apr 2025 14:43:23 -0700 Subject: [PATCH 10/16] fuse2fs: support getting and setting via struct fsxattr From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065105.1160461.8046224721957766466.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Support querying xfs file attributes in fuse2fs so that the vfs getattr/setattr functions continue to work. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 178 ++++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 153 insertions(+), 25 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 9e416e8af77e1b..6066984fa7f6e0 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -2953,31 +2953,41 @@ static int op_utimens(const char *path, const struct timespec ctv[2] return ret; } -#ifdef SUPPORT_I_FLAGS -static int ioctl_getflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, - void *data) -{ - ext2_filsys fs = ff->fs; - errcode_t err; - struct ext2_inode_large inode; - - FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); - dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); - memset(&inode, 0, sizeof(inode)); - err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, - sizeof(inode)); - if (err) - return translate_error(fs, fh->ino, err); - - *(__u32 *)data = inode.i_flags & EXT2_FL_USER_VISIBLE; - return 0; -} - #define FUSE2FS_MODIFIABLE_IFLAGS \ (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL | EXT2_NODUMP_FL | \ EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \ EXT2_TOPDIR_FL) +static inline int set_iflags(struct ext2_inode_large *inode, __u32 iflags) +{ + if ((inode->i_flags ^ iflags) & ~FUSE2FS_MODIFIABLE_IFLAGS) + return -EINVAL; + + inode->i_flags = (inode->i_flags & ~FUSE2FS_MODIFIABLE_IFLAGS) | + (iflags & FUSE2FS_MODIFIABLE_IFLAGS); + return 0; +} + +#ifdef SUPPORT_I_FLAGS +static int ioctl_getflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, + void *data) +{ + ext2_filsys fs = ff->fs; + errcode_t err; + struct ext2_inode_large inode; + + FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); + memset(&inode, 0, sizeof(inode)); + err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, + sizeof(inode)); + if (err) + return translate_error(fs, fh->ino, err); + + *(__u32 *)data = inode.i_flags & EXT2_FL_USER_VISIBLE; + return 0; +} + static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) { @@ -2999,11 +3009,9 @@ static int ioctl_setflags(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, if (!ff->fakeroot && ctxt->uid != 0 && inode_uid(inode) != ctxt->uid) return -EPERM; - if ((inode.i_flags ^ flags) & ~FUSE2FS_MODIFIABLE_IFLAGS) - return -EINVAL; - - inode.i_flags = (inode.i_flags & ~FUSE2FS_MODIFIABLE_IFLAGS) | - (flags & FUSE2FS_MODIFIABLE_IFLAGS); + ret = set_iflags(&inode, flags); + if (ret) + return ret; ret = update_ctime(fs, fh->ino, &inode); if (ret) @@ -3072,6 +3080,118 @@ static int ioctl_setversion(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, } #endif /* SUPPORT_I_FLAGS */ +#ifdef FS_IOC_FSGETXATTR +static __u32 iflags_to_fsxflags(__u32 iflags) +{ + __u32 xflags = 0; + + if (iflags & FS_SYNC_FL) + xflags |= FS_XFLAG_SYNC; + if (iflags & FS_IMMUTABLE_FL) + xflags |= FS_XFLAG_IMMUTABLE; + if (iflags & FS_APPEND_FL) + xflags |= FS_XFLAG_APPEND; + if (iflags & FS_NODUMP_FL) + xflags |= FS_XFLAG_NODUMP; + if (iflags & FS_NOATIME_FL) + xflags |= FS_XFLAG_NOATIME; + if (iflags & FS_DAX_FL) + xflags |= FS_XFLAG_DAX; + if (iflags & FS_PROJINHERIT_FL) + xflags |= FS_XFLAG_PROJINHERIT; + return xflags; +} + +static int ioctl_fsgetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, + void *data) +{ + ext2_filsys fs = ff->fs; + errcode_t err; + struct ext2_inode_large inode; + struct fsxattr *fsx = data; + unsigned int inode_size; + + FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); + memset(&inode, 0, sizeof(inode)); + err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, + sizeof(inode)); + if (err) + return translate_error(fs, fh->ino, err); + + memset(fsx, 0, sizeof(*fsx)); + inode_size = EXT2_GOOD_OLD_INODE_SIZE + inode.i_extra_isize; + if (ext2fs_inode_includes(inode_size, i_projid)) + fsx->fsx_projid = inode_projid(inode); + fsx->fsx_xflags = iflags_to_fsxflags(inode.i_flags); + return 0; +} + +static __u32 fsxflags_to_iflags(__u32 xflags) +{ + __u32 iflags = 0; + + if (xflags & FS_XFLAG_IMMUTABLE) + iflags |= FS_IMMUTABLE_FL; + if (xflags & FS_XFLAG_APPEND) + iflags |= FS_APPEND_FL; + if (xflags & FS_XFLAG_SYNC) + iflags |= FS_SYNC_FL; + if (xflags & FS_XFLAG_NOATIME) + iflags |= FS_NOATIME_FL; + if (xflags & FS_XFLAG_NODUMP) + iflags |= FS_NODUMP_FL; + if (xflags & FS_XFLAG_DAX) + iflags |= FS_DAX_FL; + if (xflags & FS_XFLAG_PROJINHERIT) + iflags |= FS_PROJINHERIT_FL; + return iflags; +} + +static int ioctl_fssetxattr(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, + void *data) +{ + ext2_filsys fs = ff->fs; + errcode_t err; + struct ext2_inode_large inode; + int ret; + struct fuse_context *ctxt = fuse_get_context(); + struct fsxattr *fsx = data; + __u32 flags = fsxflags_to_iflags(fsx->fsx_xflags); + unsigned int inode_size; + + FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); + dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); + memset(&inode, 0, sizeof(inode)); + err = ext2fs_read_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, + sizeof(inode)); + if (err) + return translate_error(fs, fh->ino, err); + + if (!ff->fakeroot && ctxt->uid != 0 && inode_uid(inode) != ctxt->uid) + return -EPERM; + + ret = set_iflags(&inode, flags); + if (ret) + return ret; + + inode_size = EXT2_GOOD_OLD_INODE_SIZE + inode.i_extra_isize; + if (ext2fs_inode_includes(inode_size, i_projid)) + inode.i_projid = fsx->fsx_projid; + + ret = update_ctime(fs, fh->ino, &inode); + if (ret) + return ret; + + err = ext2fs_write_inode_full(fs, fh->ino, (struct ext2_inode *)&inode, + sizeof(inode)); + if (err) + return translate_error(fs, fh->ino, err); + + return 0; +} +#endif /* FS_IOC_FSGETXATTR */ + #ifdef FITRIM static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, void *data) @@ -3160,6 +3280,14 @@ static int op_ioctl(const char *path EXT2FS_ATTR((unused)), ret = ioctl_setversion(ff, fh, data); break; #endif +#ifdef FS_IOC_FSGETXATTR + case FS_IOC_FSGETXATTR: + ret = ioctl_fsgetxattr(ff, fh, data); + break; + case FS_IOC_FSSETXATTR: + ret = ioctl_fssetxattr(ff, fh, data); + break; +#endif #ifdef FITRIM case FITRIM: ret = ioctl_fitrim(ff, fh, data); From patchwork Thu Apr 24 21:43:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076936 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ugNcQWpT; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=zkrw=xk=vger.kernel.org=linux-ext4+bounces-7478-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8c21GJgz1yN2 for ; Fri, 25 Apr 2025 07:43:30 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8cM4fmCz4xD3 for ; Fri, 25 Apr 2025 07:43:47 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8cM4cC7z4x6n; Fri, 25 Apr 2025 07:43:47 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.48.161 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531027; cv=pass; b=Z2YF9X09sW09tMuPU4s6puOz0e67xHUY9W6fmsWodAypqX8F7jI4AXFnu7FRjtmh9By+fqXbT4kY3h0mGJsqP+4DW02jzfhAqwuNUaorCTGv/Hhpj6o8tjUyoOmdok6vKw6bfkgGmJZzz38JGHfovB5amDKHLdBCu/k/wnzTT4AYhXEAEWJUHUpsC89bwAE4M1CKNjlvhZcJZwuT1Gj0EVANwWga9jGTmWg5avkCdXFuS9DvfipbEikgloVnWDsAaVLbnWq4Emq1hyird+6pPTj+xwX9BidZPP1YvTMdbF2F0CsxEbgx2RiwdoW3ZUFTiCdRtCeAFP5lLf4Pq1g+Pw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531027; c=relaxed/relaxed; bh=Wulrm2PLswI0tKN3MGkfph0gbBnW4eGv0Wn75alBzvM=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=CPqluXrvXqO4Rah8ZuagFKGL8hBTNhkiScJEl5RjTHU9jySAnQde0ggG4cxt4uHTfSsJBKD7Sw3Tn0ftdirAkOwDuxRww1YRcD9viw6o9n2Vmr+vtqRBNvPRuY5+8uYhYc9g9Ru0LzDROPzUQW8ltBeFWpXCfRaBoRarvv5nwB4dGlxQ4ZyiU8beDWjwcY+pukOerSSi2ogaybNrQ6GLP7XFOBN6zmSok9VgqO9ZIBQUUUpVy/ckubidvcz7DldNZ0MwUXTmwpZF5WinXPQws8F0Pxdwdg9Q7vNuVqyveApW/N6CMzjkKJnupXFDSlukDAGQvgxfRxOZa61bqGrp7w== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ugNcQWpT; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ugNcQWpT; dkim-atps=neutral Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [147.75.48.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8cJ5Cfqz4xD3 for ; Fri, 25 Apr 2025 07:43:44 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 28EB17A8D5B for ; Thu, 24 Apr 2025 21:42:35 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D6609198851; Thu, 24 Apr 2025 21:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ugNcQWpT" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 9727E1F4297 for ; Thu, 24 Apr 2025 21:43:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531019; cv=none; b=MRnDwSZv77sjeb7M4OSgTjlX++ykLTMpuHm+7Hkk9SK/hju3QO8H4ZyHvqKiln4FDh3xbi8nuIy11A0qjoW/b81FGcPlIAbAVBRNaiXvfrh2uaoq83+WPjkyInqb+5SrfBy280WNEEY9Rb8flDsBnlx1XFRzGIaPa6XFLFT3bgw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531019; c=relaxed/simple; bh=yYJKuhBHMX43MXvKWwAin9TiUnd5UIlZ651Ti87vW3s=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HFkaKrxOcXOUEWR+qwHY8kTnAcdbWxoyfvL2N8KMOUyAq6MgWEjyaYj12YCiKQrtGD7SF9LWESSv5z6XMXeVz5bep2zk0SsqcnD2rELnOzFxD6WKSev/eTc20wEcC3EQMk//4mqmvnrYcDlg6TkUihlihfWBtlhb+9hNc1e58aA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ugNcQWpT; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 6C301C4CEE3; Thu, 24 Apr 2025 21:43:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531019; bh=yYJKuhBHMX43MXvKWwAin9TiUnd5UIlZ651Ti87vW3s=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ugNcQWpTfl9RG0iVgNtyYOX7/XxCRft0BPo/ETEUDqrNMsYD+gSfQLjBj4+GuNWC5 d41yUZFy2UyYuN8vy3vAqSx9gfEjVkzvd6w91OTFQ29p9OFciU27rXQHoRPiXG2jca Ae84fCxerkLGvcLY3GOFNflOEFB0yqToqHls4C0288IoX8uKtj/0jjAe20xrRMwQ+h ETZ2jwM0evcQPA/VxxeHPtyr4FzmYRjWqd9G0/MKC6IHh8zSCxqV6x6JgHFnzpBVbd LRVA2b1tnoZpxBgMBJ4MYugLkvLGCZyCZz/Sof/cUF6CR019pVR3Ppjk25Ag/NgZOE rhvvG7a4qOefw== Date: Thu, 24 Apr 2025 14:43:39 -0700 Subject: [PATCH 11/16] fuse2fs: support changing newer iflags From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065123.1160461.3149004980436873980.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Redefine FUSE2FS_MODIFIABLE_IFLAGS so that userspace can modify any flags that the kernel can, except for the ones that fuse2fs lacks the ability to change. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 6066984fa7f6e0..2220da4c3e8f64 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -2954,9 +2954,8 @@ static int op_utimens(const char *path, const struct timespec ctv[2] } #define FUSE2FS_MODIFIABLE_IFLAGS \ - (EXT2_IMMUTABLE_FL | EXT2_APPEND_FL | EXT2_NODUMP_FL | \ - EXT2_NOATIME_FL | EXT3_JOURNAL_DATA_FL | EXT2_DIRSYNC_FL | \ - EXT2_TOPDIR_FL) + (EXT2_FL_USER_MODIFIABLE & ~(EXT4_EXTENTS_FL | EXT4_CASEFOLD_FL | \ + EXT3_JOURNAL_DATA_FL)) static inline int set_iflags(struct ext2_inode_large *inode, __u32 iflags) { From patchwork Thu Apr 24 21:43:54 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076938 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nn8f/wqd; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=iowk=xk=vger.kernel.org=linux-ext4+bounces-7479-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8cQ19Gxz1yN2 for ; Fri, 25 Apr 2025 07:43:50 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8cl4c20z4xD3 for ; Fri, 25 Apr 2025 07:44:07 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8cl4Z0zz4xM7; Fri, 25 Apr 2025 07:44:07 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip="2604:1380:45d1:ec00::1" arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531047; cv=pass; b=NL1ndPI0mR6BykHfbpAfV3KWiOPc8iWS86ULdT23e8R+PICwRmhCRDm99vBmgAES2QRgZVNqiZQNtHIPJf+2s6wF8DtbEXf8wYuZlaSL3yyYqVfA0BPJb4omzT3N7VuHDUEhETvbOTZiNOwKCdVUXRqj+fyfs4cHn/R9gdEIc5ycF52KnG2WRZ1QRbb81QQGyaNGXUZ6WCcERn6ek+x2yWa8oB7CStcYFkt1qLFmz4c3QpKkIAuRwE8Go9+ytBVh/S++1tsHiS47wMQk3I0Ezt671LXQio3/njE8SH6VBqLVTtXBCRG2qPlToNxEKIcj0BDPYMutQNei2ZPee/B8pQ== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531047; c=relaxed/relaxed; bh=/iTgLb3y/pPcJZ2t/lrn0/qFgr0U6VWIu8fNS0pZanc=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=ehQACqKo3GDWY7jR/o7wqJH/bI6GCaJfEnGMA2f/YrbUpE4PzUYVjr3/iAKQgyNpEHaJ46hwwl8xebn4oWvPoDZQ5YBzX7PI/jU1MpXQdYNGc3kueGsy8UtTAodbeP1YtbW1HsLFStiADFqKA1qD7wYwvdJth++ohgNuWGdswYwz2xTq495Jg8iNhDfvIBYTMhhjvt8Lja8DsaSHxiB/RNblkb/yi9zIw//uPveNkOEh7uQDZH+h9o/SyKUvRhZZlIcCsUwSN8xVhYPHUAS1lnLbySbA+cWimu2I0hFEjj56QwttX02JRkKhe783JYsblTP/je4/XYPyP07rTR6bvw== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nn8f/wqd; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=nn8f/wqd; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8ch2Y2Fz4xD3 for ; Fri, 25 Apr 2025 07:44:04 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4C33516D8EA for ; Thu, 24 Apr 2025 21:44:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7BC1621D3E3; Thu, 24 Apr 2025 21:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="nn8f/wqd" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3CC94198851 for ; Thu, 24 Apr 2025 21:43:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531035; cv=none; b=DBIFWHJNuSUOANr3XGKNtlTFYo5aQrnJgo2AFo9cCuY+zN8gPRPQph4nwygrhIfjRuWV4HfufUnF2njlER2398+rEOB1aY14C+d72KP87M6T3+nbKFrqd+IiaeXqCXiULM+orz4ZMYoGsbfTbW9oWbbFKsz6Lx9J1PJbiBEFwX4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531035; c=relaxed/simple; bh=11Xa9EFYuEtyWzGR6r+2kUDLydjV6VpSoQ21b28o+78=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=PiOw8Q7+vBjqI0PZ5gV1IwGeGkTQ8MI1X4nJ28pRSz+MJ9JsJ6ll/S083Dmi3wUp0rj3M8wn/X0Fb4s0sEa3XL0anMpBRifUe+Rt5Xm435e8IM4kHAzN9f0jsRf6uU3dCz7+v1hZNNE07t5bvNd/edPIchaIhwY8MBlnZqrBOY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=nn8f/wqd; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 11C66C4CEE3; Thu, 24 Apr 2025 21:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531035; bh=11Xa9EFYuEtyWzGR6r+2kUDLydjV6VpSoQ21b28o+78=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=nn8f/wqd8aOoqaheR+bEVCNsA0tKJRfMB3N9VS/Ktv+B9T+R36lfALXphWPWbERws +8AnDGEo7CiENPdXjI1GDRHYZuVpodrGyiom+dDRNTJsHfKW84DKEL79ASCo5Z7ILB martsGsWWCiFZENYsFCZwecRXa70W2K8WLx7VPvkpp4T2oYFHE9cSw1ywFwf3HMUFe qmheuimmM2LrUZPQt9djWCZgYw83Vc+1jZfMPgJYGFNOcPdZw6PGNZXpVQxSncMlIy rXyUhrCytDi7Q+ljPCb0lZZ26PNVzK61URSeEx9svLpoV5e5S0Q7LfqCfJZnhdsKhx Ar/n83bY/4b8Q== Date: Thu, 24 Apr 2025 14:43:54 -0700 Subject: [PATCH 12/16] fuse2fs: update new child timestamps during mkdir/symlink From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065141.1160461.7342685341356901806.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-2.2 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong These two file creation functions fail to update the timestamps of the new child file, unlike the others (mknod/creat). Fix that. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 2220da4c3e8f64..a13564a30575da 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -1016,6 +1016,7 @@ static int op_mkdir(const char *path, mode_t mode) inode.i_mode = LINUX_S_IFDIR | (mode & ~S_ISUID) | parent_sgid; inode.i_generation = ff->next_generation++; + init_times(&inode); err = ext2fs_write_inode_full(fs, child, (struct ext2_inode *)&inode, sizeof(inode)); @@ -1390,6 +1391,7 @@ static int op_symlink(const char *src, const char *dest) inode.i_gid = ctxt->gid; ext2fs_set_i_gid_high(inode, ctxt->gid >> 16); inode.i_generation = ff->next_generation++; + init_times(&inode); err = ext2fs_write_inode_full(fs, child, (struct ext2_inode *)&inode, sizeof(inode)); From patchwork Thu Apr 24 21:44:10 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076940 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ahOChj8O; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=4pdh=xk=vger.kernel.org=linux-ext4+bounces-7480-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8cg0fhDz1yN2 for ; Fri, 25 Apr 2025 07:44:03 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8d046qXz4xD3 for ; Fri, 25 Apr 2025 07:44:20 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8d044gwz4x6n; Fri, 25 Apr 2025 07:44:20 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=139.178.88.99 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531060; cv=pass; b=FudkRJxwwhVjukduCHqinVeyqTbD9XV7gD/pH/VIP73nC4Nf/WBbxbsWmu7UdX3CgZnW9gQh4p0Rw7g7OD40+9EErbauRSrOFYFp/8ZbJxTUIaEHMEMaN3hAU72AqdXmvhi0LY1asc8VLI6lSDiAX20/S12LrpcGAq3qr/AQ/YwZApJB88jcumMlvC6npAOka6k0PmyHmkKJaq62qrg7q7ZNe+TepVIk73x7CbRL+BTpHeePxeGkLKykipYgP391CLnmW2I4N2KFDMTFJvgrx+vQ9E1ZKG6q5+rtGcjmA3DJWH1uFGRrokX8l/QW3faabHTvP0vK2Z3i1sfJE6UYmg== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531060; c=relaxed/relaxed; bh=nmhJPmV6YaNtzKLV1K5jBIsUYu2D24qpViT4GWw1mOY=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Y2KKAdrv0cCIRzsIfrGPZRSSaCOZgFyBcm5sXOjJQmU1wrIvd+r76m4DWyt0huca+AM/wolSnYLbdDpFZ/S4YxG2MVHDNWxGF2K1jKB0Op+Tm45MDPVmx7uDW/qj7wgx15CauQKBQOO8XkTjlYivogCPAfigPEMEBA2cWfwghw/BrFDqDftKHuTWwlKAjSxuOcJzs6OCx5QcHfjDDO8/pLBZX9R7rhKa5OAorOcOUJwD91d9Ry5GWBaxT69YnxLLNfPH9IEyHhbpLhubiMmbQYxlJriEeTtvuR8zmMAT/aQW2y2RyXXSzZKvOzJMEI2OuSXPLkKygjPVfLTinD6fUg== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ahOChj8O; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=ahOChj8O; dkim-atps=neutral Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org [139.178.88.99]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8cx3c7Qz4xD3 for ; Fri, 25 Apr 2025 07:44:17 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 1796C9A182D for ; Thu, 24 Apr 2025 21:44:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7487F21E087; Thu, 24 Apr 2025 21:44:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="ahOChj8O" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 3229A214A7A for ; Thu, 24 Apr 2025 21:44:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531052; cv=none; b=gzjr5PH83QcSdjxMCRjFCMV1u0zrjqC+dG0wvLNhsJ87TeVqPc/VnIrqbKRKyxOZypxwOnJP4Epk1uaxK6HGRYb2+eUyZC4qPLbvOZId19PxeU8xGqRsmVVite9XzrD1Izz0dlmwXtYtluErMaaA1vSP7AKI/v7VNmIMzG5fDbg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531052; c=relaxed/simple; bh=iToVKcpBO0yXTryFfVGjySUD3whJPZ/zHKrwP2k2mGE=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=fYtDzkwrfC+98wPiq+N/JVruDgGBuX7WwIZNEhJc3rzqea7Qkd0tzXaWD8dzxHM9C+eXcrpSo7HVfQE79wKg1ey2hRQ0ZM4dlPHUUx3eWY3IPTjIHzEVYY6RkT5UdWKyzEZNaqYjd6JyNQa8nAw5gAEtvcEqZcGlk0vBKxotAgs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=ahOChj8O; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id A1AEEC4CEE4; Thu, 24 Apr 2025 21:44:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531050; bh=iToVKcpBO0yXTryFfVGjySUD3whJPZ/zHKrwP2k2mGE=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=ahOChj8OWNvXi+0UcqFrqZ65qXt5pmQigm77A3eGzmZtFI3vTCkxzVvJyt4X56Bdb StvlsGOqSfDjeQUi2j29FHhRgnvHY+bSjc32KQyn10Rd6u/GQ6s61wDqsLjOZlaYu/ ztjawRaZvl7EwD0uhyV2KhDhkjPXDI9uobsd0Fr5r8TbbqGgsvrDfsqMroEawSzRkE y7O5SiMxtxKL05qCOJ7z2qxZhMq6fXzYBfRl2ObJ0CxPQrTtQ1alyq2W5tU9ddZLHS pgj11P1RO04Kt/M8cMYHdv9n97YSHrihkAKh9UWrDl805xDArAGmuyVvJJ684Wuygh QMBYrzocSRbMQ== Date: Thu, 24 Apr 2025 14:44:10 -0700 Subject: [PATCH 13/16] fuse2fs: report real inode numbers From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065159.1160461.12395515521619169511.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Report real inode numbers in stat instead of letting fuse invent them for us. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index a13564a30575da..7db0a2d1f2d855 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -611,6 +611,7 @@ static void *op_init(struct fuse_conn_info *conn #endif #if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) conn->time_gran = 1; + cfg->use_ino = 1; #endif if (fs->flags & EXT2_FLAG_RW) { fs->super->s_mnt_count++; From patchwork Thu Apr 24 21:44:25 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076941 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TjL5Y2tF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=0roj=xk=vger.kernel.org=linux-ext4+bounces-7481-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8d00Ht7z1yN2 for ; Fri, 25 Apr 2025 07:44:20 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8dK3kTJz4x6n for ; Fri, 25 Apr 2025 07:44:37 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8dK3hKTz4xD3; Fri, 25 Apr 2025 07:44:37 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.80.249 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531077; cv=pass; b=u9kszhwUvSFEU946DyzLgMuBK96qzrHOQ0t98XWnE+9kuPfzSxweWlToZQkK/SDUOJDH++jhWPAOdomzRrLiDqEz3VUyWp9p15c6oDc9PZAhc5BZAse7vpAKnH6SmmQ39oUBiHsnIyp+IMTpLbz6QY//CEcnSeij/5q1WKrPb0KJ8V/qPyZlryHRtXOxme+hO5B6NJg9mPKrBRGOMyV4/uHGalkpzuqG0KmullyQHIXvGDpNduFGAR06qrwwYDgPDpPwOMFZXVHtXbfbo7aOVUl9/D7eWEhmS1S8PZHbr1c/NEZYjjXPm1UVbUyr3nnfm2UAwUcG2ggXhV5avdvbPw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531077; c=relaxed/relaxed; bh=vfcCohusd/7PiyWh7WneiRt8L7OP6Jvo/Atx4elpTgk=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=YjYK/eIx+xi+QSbq92kYkOpc7AjTEe7aimOfKc+o655r0ISQ0AKl7WMRazN2o0u/dSxqBwz8occQ1htDavGYOaVQzWqqr99NznSbmU3lBEhBQYAUi06YQL9L+uZpFCJP78MDcAXu2PJZL5b/cvrPUIZWPM2NK8vjR8sVXxJAkaPRsmCgQNSFjCXWX+tXbUdjfW75j2jJcSgWxO4eZiONxZljvrPh/l2H8SHPNFdeSAsSNDHV4JE2kOr2bnVzYB7U+SyGjThPigeXkGaNwhnOINAhpRrW1+ZDzOWLxYSlyDTIgfA5gwK4Bms4tBaYO1Kemz+vupg9SEtKAnBjHgxCJA== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TjL5Y2tF; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=TjL5Y2tF; dkim-atps=neutral Received: from am.mirrors.kernel.org (am.mirrors.kernel.org [147.75.80.249]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8dG0wbZz4x6n for ; Fri, 25 Apr 2025 07:44:34 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 5B8651BA4E92 for ; Thu, 24 Apr 2025 21:44:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 0F33621D3E3; Thu, 24 Apr 2025 21:44:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="TjL5Y2tF" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 C3F8D1F4297 for ; Thu, 24 Apr 2025 21:44:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531066; cv=none; b=fve/KsIq31r8b/nAnQrV9vblxKS2bmWYBgtvTrrb0VzJxFIKLFPz13cumEpK1vvt4/vsBGgks3TqwJ887d5qBf0Gu6AUrihSj0Hl5RRaqBnz8eNbDD4J0AC5gaLR57YQDVhL21cyIq617nO1Fx0Rbfg9yNp3VktC1wk/ICN8FGk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531066; c=relaxed/simple; bh=qts1Pq5kmv68nJ7gFEIuAv+NiTVluEh0zzBcrAgnn3s=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=svBq3GFl00oUu6AFv2rdtRU4RwXLVoofyLXpUxIHm3M0a00nLwsqdFr8p0e02hQzSxhdm+LSSbPjRRQY4EVdJpKxnO9i/j6qh5QpBxu23cWgJ4HkP0YFGlCzokbvbbE7c/WjY3dh8wd7XI+4Odj1DB63TvA6zsDd/PHIX56khk0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=TjL5Y2tF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 42DB4C4CEE3; Thu, 24 Apr 2025 21:44:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531066; bh=qts1Pq5kmv68nJ7gFEIuAv+NiTVluEh0zzBcrAgnn3s=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=TjL5Y2tFSiPVSHRqJhIfiR2CJ4EoK7dv6o7ag0b7ZkD7nELEDCt9TZl68Xeust6ks 1P5seSgi0sE8yGLBIL1sT7D5IMzwa/Ic8j0zQYvVf1vAPohIbhzM9aLtzKpfw3AH/C 2gwOe7n//HMDTFYw41fwj+7lYr14nAbL1YuERzGUD44P+/O1dOhF21mUVDSgTnXGej PgTAL7+Yh/npWHXHMpR94j8rgqrxKRf9SVvKGUC7TdtwzYd3ybgQVBcZ+VRpPaeN3b Tm6XN5XmOhkdTiIoFhjZ/i03TemleGifxO/Ehb9CqFVlbdHELf717bDTtv8LrOUBZz V7ITRe6uaC6NA== Date: Thu, 24 Apr 2025 14:44:25 -0700 Subject: [PATCH 14/16] fuse2fs: disable renameat2 From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065177.1160461.684615549721279410.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Apparently fuse munged rename and renameat2 together into the same upcall, so we actually have to filter out nonzero flags because otherwise we do a regular rename for a RENAME_EXCHANGE/WHITEOUT, which is not what the user asked for. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 7db0a2d1f2d855..420fbfd5db5969 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -1447,6 +1447,12 @@ static int op_rename(const char *from, const char *to struct update_dotdot ud; int ret = 0; +#if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) + /* renameat2 is not supported */ + if (flags) + return -ENOSYS; +#endif + FUSE2FS_CHECK_CONTEXT(ff); fs = ff->fs; dbg_printf(ff, "%s: renaming %s to %s\n", __func__, from, to); From patchwork Thu Apr 24 21:44:41 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076942 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=O1eB65uF; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=2404:9400:2221:ea00::3; helo=mail.ozlabs.org; envelope-from=srs0=hxwg=xk=vger.kernel.org=linux-ext4+bounces-7482-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8dG1280z1yN2 for ; Fri, 25 Apr 2025 07:44:34 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8db4TNdz4x6n for ; Fri, 25 Apr 2025 07:44:51 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8db4QLXz4xD3; Fri, 25 Apr 2025 07:44:51 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531091; cv=pass; b=EJHxn/Cf1TOlzbHoB2ucYAFOwdHD7w2bCHHAbSjs4iWQn9zbg1UG144lvWMySsXf0kB2G4sptwZJ38Jp5OyQhvdoYqp5gFfXsD9fWd2gBfkIYlQv54gNYh4ZcaH/qY7jujbsi5KRxjCZoDrj4PcDkADCDoUGK+2t90oRsy7c6ApXpp1EUdX/L1chnk12J1Kg5355sk/NjbcBNqlNDF80XtWyX8GCRgVGdkJTZbRGsfVqvxBDuWQlTTxmNSchJdGYmcKmmgLsVisJXwDY8twG+0cvqMXUe0cdo85sLvNNAxoXqDEgURnyVi8HM2n4j/F+1Y2cTQ9uComeDPCztmS6Gw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531091; c=relaxed/relaxed; bh=KRZkNIyOBfHzlmwM6tgn8zOSjUrHFetedCnrcMicMpI=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=TKyhoxBz25WN49UYN+63AZl+WkWDMfpFux6X3DwwoELX6Ecv9A7o4V6sdnbr4qOgCrX58+QVwxFy/6CxoJwCU7vYdfSHuYqXPI5npLRshgb5BzWJEsQ+pJFSRUQvFPld7quRJpcYORY7bZpu7IOISwDLEtMVLMmgo9gZO2R7XGg+qu+cebMNWj8kt89nh3ShNn/yVxo/Z4CTHwhSWV+K+U7hE98PoSg+8QAL/pTPpEprkG8bJzm9CtK5UVehm6J0je6CLxTIUIECpjGcE3dPn/xLXQhRbJz10hbPHVlo8HMnjeSR9I2NPl5YPYNoPSzRWwrD+ikx02SFCMwLmJ2Few== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=O1eB65uF; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=O1eB65uF; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8dX2LQ3z4x6n for ; Fri, 25 Apr 2025 07:44:48 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id A1D0A4A7CC5 for ; Thu, 24 Apr 2025 21:44:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4BC9821FF2C; Thu, 24 Apr 2025 21:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="O1eB65uF" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 0BC90214A7A for ; Thu, 24 Apr 2025 21:44:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531082; cv=none; b=P3Nhrs9i3nZ3obb6msmNvdO+rgbxudUWTpqopT7PsBJldZLdbwKp1IvOTzN/itYkowMSD+a5aX0NLBIUM0cv/Nyrd+VNOFLdKhvGyES25qp8ZLaMYiGd1EOkulSiCTttmzZZ58Lnp8Qc3FPcFHFO5ScDoqbGyUWLvB/1bQf7zPA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531082; c=relaxed/simple; bh=Qx8Q1UUgJaI0Agsx5pkcLh6uhI10QloDedS//70Vq8I=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=XNW4uc57fx2+inKRjUsXy3sjhQqEMGYGM6fnQYzNZiWB8xLVeJdd1Y1sOM45Vk6PZ2Uwyi6K/47hejqPxuc+UXgkw9EEvqjVD6ljJ7oVrKnHMCXwDy/BhQZUDB+sV6676qNyHSVXoL/TN3UlCXaU0rpvGDfrn4iKpU+V/wAN0pM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=O1eB65uF; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id D7A20C4CEE3; Thu, 24 Apr 2025 21:44:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531081; bh=Qx8Q1UUgJaI0Agsx5pkcLh6uhI10QloDedS//70Vq8I=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=O1eB65uF9X0hruodcO+kfSi8RN1YFTJIWLszW1xT16iF4nzJPQ2/lHH6wEmOqFOsV GVWzM8Oo8NkQf6gDV9RWDLMPUTkU3pfn6fNVLRYsgUdt2zIDC6hM0K0pdpT3MUxMzj Bxsm9+whRo0tvvxMBMYe/e2H5Br9nDct25ZBCb8XyYBRx6EishjYisAFp7s/rMgDQD 0mfERa6TwQw1zBt0IRyGsf9DGihFhsG+Ry6Z1FNmeO8mpRbCoSv9+kCo7vxzdfOiRe QAmMNzIwM1rUYtHK6gXHm6k5i1L7cNhBRvG/7GlTcED3Qzq1e8LfE2Dr7hANZ+T77V 8dt/5VDVDSIDw== Date: Thu, 24 Apr 2025 14:44:41 -0700 Subject: [PATCH 15/16] fuse2fs: fix FITRIM validation From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065195.1160461.15575039465292160279.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Fix the validation here to match the kernel, and report the number of blocks trimmed. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 420fbfd5db5969..5a6b607ead9b4b 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -3206,17 +3206,27 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, { ext2_filsys fs = ff->fs; struct fstrim_range *fr = data; - blk64_t start, end, max_blocks, b, cleared; + blk64_t start, end, max_blocks, b, cleared, minlen; + blk64_t max_blks = ext2fs_blocks_count(fs->super); errcode_t err = 0; + if (!fs_writeable(fs)) + return -EROFS; + start = fr->start / fs->blocksize; end = (fr->start + fr->len - 1) / fs->blocksize; - dbg_printf(ff, "%s: start=%llu end=%llu\n", __func__, start, end); + minlen = fr->minlen / fs->blocksize; + + if (EXT2FS_NUM_B2C(fs, minlen) > EXT2_CLUSTERS_PER_GROUP(fs->super) || + start >= max_blks || + fr->len < fs->blocksize) + return -EINVAL; + + dbg_printf(ff, "%s: start=%llu end=%llu minlen=%llu\n", __func__, + start, end, minlen); if (start < fs->super->s_first_data_block) start = fs->super->s_first_data_block; - if (start >= ext2fs_blocks_count(fs->super)) - start = ext2fs_blocks_count(fs->super) - 1; if (end < fs->super->s_first_data_block) end = fs->super->s_first_data_block; @@ -3230,17 +3240,23 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, while (start <= end) { err = ext2fs_find_first_zero_block_bitmap2(fs->block_map, start, end, &start); - if (err == ENOENT) - return 0; - else if (err) + switch (err) { + case 0: + break; + case ENOENT: + /* no free blocks found, so we're done */ + err = 0; + goto out; + default: return translate_error(fs, fh->ino, err); + } b = start + max_blocks < end ? start + max_blocks : end; err = ext2fs_find_first_set_block_bitmap2(fs->block_map, start, b, &b); if (err && err != ENOENT) return translate_error(fs, fh->ino, err); - if (b - start >= fr->minlen) { + if (b - start >= minlen) { err = io_channel_discard(fs->io, start, b - start); if (err) return translate_error(fs, fh->ino, err); @@ -3250,6 +3266,8 @@ static int ioctl_fitrim(struct fuse2fs *ff, struct fuse2fs_file_handle *fh, start = b + 1; } +out: + fr->len = cleared; return err; } #endif /* FITRIM */ From patchwork Thu Apr 24 21:44:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Darrick J. Wong" X-Patchwork-Id: 2076943 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=t+OjGu5Z; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=ozlabs.org (client-ip=150.107.74.76; helo=mail.ozlabs.org; envelope-from=srs0=mtyl=xk=vger.kernel.org=linux-ext4+bounces-7483-patchwork-incoming=ozlabs.org@ozlabs.org; receiver=patchwork.ozlabs.org) Received: from mail.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Zk8dZ49jLz1yN2 for ; Fri, 25 Apr 2025 07:44:50 +1000 (AEST) Received: from mail.ozlabs.org (mail.ozlabs.org [IPv6:2404:9400:2221:ea00::3]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4Zk8dw0NMcz4x6n for ; Fri, 25 Apr 2025 07:45:08 +1000 (AEST) Received: by gandalf.ozlabs.org (Postfix) id 4Zk8dw0Kcxz4x8f; Fri, 25 Apr 2025 07:45:08 +1000 (AEST) Delivered-To: patchwork-incoming@ozlabs.org Authentication-Results: gandalf.ozlabs.org; arc=pass smtp.remote-ip=147.75.199.223 arc.chain=subspace.kernel.org ARC-Seal: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531108; cv=pass; b=rsoj0L2XAN06SLbU1MWvNU1Kin6pkMGzQ79hJM/hlwIb1ly8/+Ei9ZA78gk91cPvtLqbfVxqgZmT7mxpwvDNkQ6rEATugVZs+j3nzzuagy0xCXWR8LpIPlFGbECQbkH6WG5hvVnXF9i3/tev47zWTUId8OuHzPpk89gWbzr2pzADzuSmS6eHRiOzxUFRM5etShXivESqdTHFabR8L5bNzCAtetD75qkmTNFyt2xpzpdB/RyB9yusE95eUwCs+Rp3n2n8jOzfSZTvTdvmg7tsC8rtPBD2ZGqVdzoOVLlqY57z6hKEpmaZY91akdLeP87HNkobr/EgKKxwRMXpNORAEw== ARC-Message-Signature: i=2; a=rsa-sha256; d=ozlabs.org; s=201707; t=1745531108; c=relaxed/relaxed; bh=uhmNZapNf0hn2230lCJQyNjhQYSSqDkILiYmZuePgng=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HT5ApziOMgZwgAOQNqL3Ht+Y0qvu3RN/FafRpUnEfh11NrMO9PqkvovL+Aa0IaqED1zxi4V0aimuS9NFfGOPUH/miyWHGzjuONzRHdwGh2R0620Xoy73UGgi1PdKDnq1kZpro5ugUuzVHeUltZnhQVt/ImAHHrLRTnSXubShM8l3Jw+4BNcfcf48mlhuNJZLaxCuCt/noB709kbOO3mmE+m9yNowEVAHeFi8mgU8zFZ6gaNY8DqRx6uq/guVp40ej/cE65LdPTZOK9JXdH6AthEeZXzgFOZZU1FFkXE0NWVqRtUA5FhbA0qnZIBi+yxtvgnuD459VcmjPIiFj6kPDQ== ARC-Authentication-Results: i=2; gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org; spf=pass smtp.mailfrom=vger.kernel.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=t+OjGu5Z; dkim-atps=neutral Authentication-Results: gandalf.ozlabs.org; dmarc=pass (p=quarantine dis=none) header.from=kernel.org Authentication-Results: gandalf.ozlabs.org; spf=pass smtp.mailfrom=vger.kernel.org Authentication-Results: gandalf.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=t+OjGu5Z; dkim-atps=neutral Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by gandalf.ozlabs.org (Postfix) with ESMTPS id 4Zk8dr5C5wz4x6n for ; Fri, 25 Apr 2025 07:45:04 +1000 (AEST) Received: from smtp.subspace.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 19E9F16D706 for ; Thu, 24 Apr 2025 21:45:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 56AE721D3E3; Thu, 24 Apr 2025 21:44:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="t+OjGu5Z" X-Original-To: linux-ext4@vger.kernel.org Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 153921F4297 for ; Thu, 24 Apr 2025 21:44:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531098; cv=none; b=XUokfWeyiFnV83A7v9ZlJybh+/Z9xiIV6XAKMDDk1KF4LQVaJKTTyFF2t1uCvaM7AM2X+FPSarScbbWu60ru9V/VLBqa8mfthk220if8dBsmk8GKXwf92L9Kj1WNp7PFjK8Z0xacVZQTgRMbhK5SfoEjI6WPDy/RnqxddHBb0xQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745531098; c=relaxed/simple; bh=Sv1cI1AZcgkhXBHNMhit9FDF8UKfsaOU1+TNtKK9IHg=; h=Date:Subject:From:To:Cc:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=HTLvC96YWuGPvEYYbGK7XNyGZGvXWelaiw7s0DhDHqI4SDUCEZfEL7qxTXTu7XF6aXy1r0z3D7o5FvMwMyREUq2sVS0Da9NLUurryQqTXiSNZoD6QUsIKA9SS0CNkpq9XukxJg6s6UST5Wc20iIH/Ftc/Th9kuAT8iYeqTdoPjo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=t+OjGu5Z; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 7A1F1C4CEE3; Thu, 24 Apr 2025 21:44:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1745531097; bh=Sv1cI1AZcgkhXBHNMhit9FDF8UKfsaOU1+TNtKK9IHg=; h=Date:Subject:From:To:Cc:In-Reply-To:References:From; b=t+OjGu5Z5K9bQyjLH7J7gGCheO3iijqYFP2IkhNgL1r8ZqLBsiQpBjb2x21vU0uBG yfCkhDIfzDeqOZRlTa7CR6oW/7JPiltXK90wALpu+HezLbhmIzKYF3w4Ha17ap01x6 OQ/And9nZ9HorU1YGYqVzvyf1WJJIfOvHq+7+vYpL2SFyDLuj/JBXR8WP7yIQKzQtU +ieZqO/osdAafGtLGtJucFwHI7SOB1bdJXRwiqB3CoQTnn32z0HTmMI7NWCfcvdqTD zSN43CEYR6rgGBFd/EpTBEEtHbdDupZS4L4dG0nhH/EwD7AqKjz0WkFcFV2tfBbZXg 9Eys3QR9qskbw== Date: Thu, 24 Apr 2025 14:44:57 -0700 Subject: [PATCH 16/16] fuse2fs: report inode number and file type via readdir From: "Darrick J. Wong" To: tytso@mit.edu Cc: linux-ext4@vger.kernel.org Message-ID: <174553065213.1160461.4431922817174080124.stgit@frogsfrogsfrogs> In-Reply-To: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> References: <174553064857.1160461.865616278603382583.stgit@frogsfrogsfrogs> Precedence: bulk X-Mailing-List: linux-ext4@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Status: No, score=-4.5 required=5.0 tests=ARC_SIGNED,ARC_VALID, DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DMARC_PASS, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=disabled version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-25) on gandalf.ozlabs.org From: Darrick J. Wong Report the inode number and file type in readdir to speed up directory iteration a bit. Signed-off-by: "Darrick J. Wong" --- misc/fuse2fs.c | 46 ++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 8 deletions(-) diff --git a/misc/fuse2fs.c b/misc/fuse2fs.c index 5a6b607ead9b4b..480463e0bc4b1c 100644 --- a/misc/fuse2fs.c +++ b/misc/fuse2fs.c @@ -2594,9 +2594,36 @@ static int op_removexattr(const char *path, const char *key) struct readdir_iter { void *buf; + ext2_filsys fs; fuse_fill_dir_t func; }; +static inline mode_t dirent_fmode(ext2_filsys fs, + const struct ext2_dir_entry *dirent) +{ + if (!ext2fs_has_feature_filetype(fs->super)) + return 0; + + switch (ext2fs_dirent_file_type(dirent)) { + case EXT2_FT_REG_FILE: + return S_IFREG; + case EXT2_FT_DIR: + return S_IFDIR; + case EXT2_FT_CHRDEV: + return S_IFCHR; + case EXT2_FT_BLKDEV: + return S_IFBLK; + case EXT2_FT_FIFO: + return S_IFIFO; + case EXT2_FT_SOCK: + return S_IFSOCK; + case EXT2_FT_SYMLINK: + return S_IFLNK; + } + + return 0; +} + static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)), int entry EXT2FS_ATTR((unused)), struct ext2_dir_entry *dirent, @@ -2606,11 +2633,15 @@ static int op_readdir_iter(ext2_ino_t dir EXT2FS_ATTR((unused)), { struct readdir_iter *i = data; char namebuf[EXT2_NAME_LEN + 1]; + struct stat stat = { + .st_ino = dirent->inode, + .st_mode = dirent_fmode(i->fs, dirent), + }; int ret; memcpy(namebuf, dirent->name, dirent->name_len & 0xFF); namebuf[dirent->name_len & 0xFF] = 0; - ret = i->func(i->buf, namebuf, NULL, 0 + ret = i->func(i->buf, namebuf, &stat, 0 #if FUSE_VERSION >= FUSE_MAKE_VERSION(3, 0) , 0 #endif @@ -2634,26 +2665,25 @@ static int op_readdir(const char *path EXT2FS_ATTR((unused)), struct fuse2fs *ff = (struct fuse2fs *)ctxt->private_data; struct fuse2fs_file_handle *fh = (struct fuse2fs_file_handle *)(uintptr_t)fp->fh; - ext2_filsys fs; errcode_t err; struct readdir_iter i; int ret = 0; FUSE2FS_CHECK_CONTEXT(ff); - fs = ff->fs; - FUSE2FS_CHECK_MAGIC(fs, fh, FUSE2FS_FILE_MAGIC); + i.fs = ff->fs; + FUSE2FS_CHECK_MAGIC(i.fs, fh, FUSE2FS_FILE_MAGIC); dbg_printf(ff, "%s: ino=%d\n", __func__, fh->ino); pthread_mutex_lock(&ff->bfl); i.buf = buf; i.func = fill_func; - err = ext2fs_dir_iterate2(fs, fh->ino, 0, NULL, op_readdir_iter, &i); + err = ext2fs_dir_iterate2(i.fs, fh->ino, 0, NULL, op_readdir_iter, &i); if (err) { - ret = translate_error(fs, fh->ino, err); + ret = translate_error(i.fs, fh->ino, err); goto out; } - if (fs_writeable(fs)) { - ret = update_atime(fs, fh->ino); + if (fs_writeable(i.fs)) { + ret = update_atime(i.fs, fh->ino); if (ret) goto out; }