From nobody Mon Feb 12 17:43:49 2024 X-Original-To: dev-commits-src-branches@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4TYWzB0qmqz5BDFk; Mon, 12 Feb 2024 17:43:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4TYWz96nmJz4Vdx; Mon, 12 Feb 2024 17:43:49 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707759830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U2+n8BJjXbB0TjdH3nHpwHsSCyGn3lVxm5R+bTx3RpE=; b=qrYcSg4Rm/93cqT7rIkD/a3Ksp1KXy1DJI4z/c1x+NfTHV/fsp9l0xPm8cQAgEt38Jq2La tHxO8dtEaz6c1xNluGe6czoUcWULWTzccvUiOjt0ZIyehZQCBrQpU0iM7AqndBjUyGu35f zW6/Q8ZOqWE2h9P64w2MgrtE/DD5uLVU0N2BSNiuUaRY9vLz1oNR3rckCpK1N1NsKALd0W uAisWYVcimhKdk1/AKY/Wa6ohmF/6Ua6OKCyn0MQgNc3g5FyAqG2qQit1Qw1EBwoZXP4tA qlRm3y0eBYV3TcoR7wksawam/UHqbOVKEy3XH1b5yXM1acDnWlKu0Yo/PSWfUQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707759830; a=rsa-sha256; cv=none; b=P2A2dmcFtuCzbbfxqr0snR6i0DekXU7vgjt8ed7mFks6GZ9aYxYAlNUadiWubMu06PXuc1 ZOa/lytTloY15eb1RaI7Gx4n2OUUG7QUSQMUqLKdMDsShkMjLe7gRhXAEJkeRLcqrklgOD 5cnlN3UHoLBoBoWI46X4CJ4weZePSdE+GYiPZADXxuj5XvDRxmB3eeZwa3cG+Mn0krzlx+ 1h65Jqd0B0K/GRxbCUxTtGspB6U9YFj8E/+/yNMJTWTObBfBWtF2u/tXRpMH4wpiGYmWhD fTSu269aJR0lt+9BMP1Egkh6pCXLSCWiG8u/+E0uJmN9KPeKrsaxxZxm2SqqyA== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707759830; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=U2+n8BJjXbB0TjdH3nHpwHsSCyGn3lVxm5R+bTx3RpE=; b=uoWSeLn1fwTFDmO56ZCFoUYAe7xeMKAP4fgeDsl9NoT33x0WIuTsiEA7DubHBUGN4HhhsT waVCh8DbfztVMFvveuHO/AmJF6jDBhvkMDgd4M7dbsr2K+HGg66bfIznxp/Z1lrXYJ+/Rt JNKbPekzwmFE46uKvMJhHFZK8epDa0nivUcFiKDAiuKPOlCe1et+zZWEHLo67gWOpq479s VyhkLyfqYf7Ch/TVQefg2sbxeJTGaz+kl9ZnTmsIqPQ0lyn42uXtdJ9GtfMrAaM8ZIUFKg fWpPyiqAH4UDOwr43b9QayDn46m4KLGPoLWVzJ0Je4H39F0S7EGIlRUEhPRa6Q== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4TYWz95qM4zh9P; Mon, 12 Feb 2024 17:43:49 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 41CHhnKi012363; Mon, 12 Feb 2024 17:43:49 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CHhn4t012360; Mon, 12 Feb 2024 17:43:49 GMT (envelope-from git) Date: Mon, 12 Feb 2024 17:43:49 GMT Message-Id: <202402121743.41CHhn4t012360@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Alan Somers Subject: git: 739488cc21b1 - stable/14 - fusefs: fix invalid value for st_birthtime.tv_nsec List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: asomers X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: 739488cc21b1ad08994aa5c36d85b9c11866b29d Auto-Submitted: auto-generated The branch stable/14 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=739488cc21b1ad08994aa5c36d85b9c11866b29d commit 739488cc21b1ad08994aa5c36d85b9c11866b29d Author: Alan Somers AuthorDate: 2024-01-25 15:19:37 +0000 Commit: Alan Somers CommitDate: 2024-02-12 17:43:11 +0000 fusefs: fix invalid value for st_birthtime.tv_nsec If a file system's on-disk format does not support st_birthtime, it isn't clear what value it should return in stat(2). Neither our man page nor the OpenGroup specifies. But our convention for UFS and msdosfs is to return { .tv_sec = -1, .tv_nsec = 0 }. fusefs is different. It returns { .tv_sec = -1, .tv_nsec = -1 }. It's done that ever since the initial import in SVN r241519. Most software apparently handles this just fine. It must, because we've had no complaints. But the Rust standard library will panic when reading such a timestamp during std::fs::metadata, even if the caller doesn't care about that particular value. That's a separate bug, and should be fixed. Change our invalid value to match msdosfs and ufs, pacifying the Rust standard library. PR: 276602 Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D43590 (cherry picked from commit 55b80e2ca52c4b27c4920d372a6e71ac9ab7da9e) --- sys/fs/fuse/fuse_internal.c | 1 - sys/fs/fuse/fuse_node.c | 7 +++++++ tests/sys/fs/fusefs/getattr.cc | 15 +++++++++------ tests/sys/fs/fusefs/lookup.cc | 15 +++++++++------ 4 files changed, 25 insertions(+), 13 deletions(-) diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index e2351e4ac24a..2d1c729a395a 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -326,7 +326,6 @@ fuse_internal_cache_attrs(struct vnode *vp, struct fuse_attr *attr, else return; - vattr_null(vp_cache_at); vp_cache_at->va_fsid = mp->mnt_stat.f_fsid.val[0]; vp_cache_at->va_fileid = attr->ino; vp_cache_at->va_mode = attr->mode & ~S_IFMT; diff --git a/sys/fs/fuse/fuse_node.c b/sys/fs/fuse/fuse_node.c index 6a7f2e88831c..1ff67ecf74e4 100644 --- a/sys/fs/fuse/fuse_node.c +++ b/sys/fs/fuse/fuse_node.c @@ -156,7 +156,14 @@ fuse_vnode_init(struct vnode *vp, struct fuse_vnode_data *fvdat, { fvdat->nid = nodeid; LIST_INIT(&fvdat->handles); + vattr_null(&fvdat->cached_attrs); + fvdat->cached_attrs.va_birthtime.tv_sec = -1; + fvdat->cached_attrs.va_birthtime.tv_nsec = 0; + fvdat->cached_attrs.va_fsid = VNOVAL; + fvdat->cached_attrs.va_gen = 0; + fvdat->cached_attrs.va_rdev = NODEV; + if (nodeid == FUSE_ROOT_ID) { vp->v_vflag |= VV_ROOT; } diff --git a/tests/sys/fs/fusefs/getattr.cc b/tests/sys/fs/fusefs/getattr.cc index 1795f29a5d76..98a757fdff94 100644 --- a/tests/sys/fs/fusefs/getattr.cc +++ b/tests/sys/fs/fusefs/getattr.cc @@ -246,12 +246,15 @@ TEST_F(Getattr, ok) EXPECT_EQ(ino, sb.st_ino); EXPECT_EQ(S_IFREG | 0644, sb.st_mode); - //st_birthtim and st_flags are not supported by protocol 7.8. They're - //only supported as OS-specific extensions to OSX. - //EXPECT_EQ(, sb.st_birthtim); - //EXPECT_EQ(, sb.st_flags); - - //FUSE can't set st_blksize until protocol 7.9 + /* + * st_birthtim and st_flags are not supported by the fuse protocol. + * They're only supported as OS-specific extensions to OSX. For + * birthtime, the convention for "not supported" is "negative one + * second". + */ + EXPECT_EQ(-1, sb.st_birthtim.tv_sec); + EXPECT_EQ(0, sb.st_birthtim.tv_nsec); + EXPECT_EQ(0u, sb.st_flags); } /* diff --git a/tests/sys/fs/fusefs/lookup.cc b/tests/sys/fs/fusefs/lookup.cc index 549df0369fa7..6d506c1ab700 100644 --- a/tests/sys/fs/fusefs/lookup.cc +++ b/tests/sys/fs/fusefs/lookup.cc @@ -112,12 +112,15 @@ TEST_F(Lookup, attr_cache) // fuse(4) does not _yet_ support inode generations //EXPECT_EQ(generation, sb.st_gen); - //st_birthtim and st_flags are not supported by protocol 7.8. They're - //only supported as OS-specific extensions to OSX. - //EXPECT_EQ(, sb.st_birthtim); - //EXPECT_EQ(, sb.st_flags); - - //FUSE can't set st_blksize until protocol 7.9 + /* + * st_birthtim and st_flags are not supported by the fuse protocol. + * They're only supported as OS-specific extensions to OSX. For + * birthtime, the convention for "not supported" is "negative one + * second". + */ + EXPECT_EQ(-1, sb.st_birthtim.tv_sec); + EXPECT_EQ(0, sb.st_birthtim.tv_nsec); + EXPECT_EQ(0u, sb.st_flags); } /*