From nobody Sun Feb 04 21:02:53 2024 X-Original-To: dev-commits-src-main@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 4TShmY6CpVz58nn1; Sun, 4 Feb 2024 21:02:53 +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 4TShmY5l33z4Nfp; Sun, 4 Feb 2024 21:02:53 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707080573; 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=CgfO5OkIToc4rrrKyjRR34kXM1YotvHkqC/ppoIIueM=; b=dx1OC3TkS6AtJVcLx5ZMcJXKjz1MWP/RlmUBS0taEPEW3W3iE0UBquBsIBAEtasmbU4sDy oxIB58MRPDPaWGD5L+T4TWXK9WyjOhiPJCXAfWHN8OwhU0Ibptb8xdMOc2MVwE/D40rfai iD53weFWlcsa358DWaVyLcfcxfUaEmzK5Awq4RRnpPo3OMf8WRq0W6PK4VGSGMcNcOjiF1 K+LRBLHoDQ4prKmgz1hW9BtVRXg/GnV0o7lNGKKSFB1UZBTUIQITupNSDl82OPMPtH+54J i+43doS52GvKodzcE3apjbGcXQhReLJzsCqARgbzSMSHIO6tfjeFbRzydlmAiw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707080573; 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=CgfO5OkIToc4rrrKyjRR34kXM1YotvHkqC/ppoIIueM=; b=doDDfuSkcFaoKRoAaS62N47Pe7NGQY+YKGJw/nZNrLKpkibMQarnDqPFvFcTDfAKwVL58l u43YSznCLrvh1ZRmZ9UAL0sO3D1DDE07nKLC7XgMsnS8O1KowhUkqQr+Es0fVvuhb+HLPw 1JhshCerLOEhN/zUvvxIKVQtZuAC3ZcStjZKipcmQAIBx2cdIOdEtpAenrq15Colbujau2 vxP4xsLMInRWxl7zVuPfx9N5YDwlz+i5vX9eKOAYzuLuuvcAXS2uLa3PISyR/JVRNsA/KV xFPm9fREI/PM31O0Q1m84TYLtsPo6/AFvvtdVl+K3I+OAQpfdIknnru0GEwmpw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707080573; a=rsa-sha256; cv=none; b=K9dIxnJX29xrOUzzKPip1+LxeHbvJxpRHhOJYyGgN8PIApKo5vmff6FH5+8EYhjWAV+9bv lQn5KmDnvkKMoAcneafThTIN2RyMW9eIiSS7kBeVSrA8OayLen3GKV1MfFJxlnKPIo1Sr0 paKmhrhMqX4d8aKZebPNMqe3bUayyS+7KbiU5baShLQbskgFpO98GG2NQ1kN4OVOYXfdJM AAxi6gSff5JeyscJkKotBfxrRDKLTki0tzM/4SaNRbcfywtXcyIx219c/wOrkHpBP6xXYY 3uaMSsk67l3CXwucS/cmYlOOdmiWlqJqoUGuieMFeb/hTtmLOMdxmKpeqwBTHw== 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 4TShmY4nXqz1C2q; Sun, 4 Feb 2024 21:02:53 +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 414L2ra7000241; Sun, 4 Feb 2024 21:02:53 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 414L2rCw000238; Sun, 4 Feb 2024 21:02:53 GMT (envelope-from git) Date: Sun, 4 Feb 2024 21:02:53 GMT Message-Id: <202402042102.414L2rCw000238@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Alan Somers Subject: git: 55b80e2ca52c - main - fusefs: fix invalid value for st_birthtime.tv_nsec List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 55b80e2ca52c4b27c4920d372a6e71ac9ab7da9e Auto-Submitted: auto-generated The branch main has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=55b80e2ca52c4b27c4920d372a6e71ac9ab7da9e commit 55b80e2ca52c4b27c4920d372a6e71ac9ab7da9e Author: Alan Somers AuthorDate: 2024-01-25 15:19:37 +0000 Commit: Alan Somers CommitDate: 2024-02-04 21:01:06 +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 MFC after: 1 week Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D43590 --- 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 f4a2e7efc908..ffbf1f9bcc40 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -325,7 +325,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 ecff94cf6dd9..13c2b59c7c97 100644 --- a/sys/fs/fuse/fuse_node.c +++ b/sys/fs/fuse/fuse_node.c @@ -155,7 +155,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); } /*