From nobody Mon Feb 12 20:17:51 2024 X-Original-To: dev-commits-src-all@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 4TYbNw0b07z5BWYW; Mon, 12 Feb 2024 20:17:52 +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 4TYbNw03dZz45wQ; Mon, 12 Feb 2024 20:17:52 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707769072; 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=j8qcmRVsihBu3uQPRY9GyWjQssVnSBOsKrwlUsCE7ws=; b=ijmtKCR+RN2Pv6WjiCF/jmZIPboIk8OsOVUj15FBsvrVKHjcboeqd/ro3UqQHSOq0xvLeO uykoxndCxSRO57UyLYQs8SPJFlUcp9nxkireedY8DVdsuXDRA7zBk7i28tz7OTOr3ow84+ WHE4j2vGx9vkvTJ+5CmntaQ44Eqo4a83YiHknBI6lvAetcMy3hG9OoflDi+zODzzgsqSDc huTH1lXGn/dWVea/S5hwRtOvt3I+PMRYoOsszRDJI7HU2yrXeU8pyUnrRqEWez/tSv3q+C WnTgnNu2b/6IMnUHe8Oz98K7S9ObK2JUKX8DzpFxOLiez1kR3wjS0rVt+ZAKYw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707769072; a=rsa-sha256; cv=none; b=GmiHUk7Xr5vwX5RJS1Vgo1xT3xMAj3Tc4RDzztku6SsWrlv8kQ7zqcswVDlOzTYVqZRfgN dYmRF2vQC/30sFTe24krBZJRMrI4x8YLkW7R8mAYFxERtB/A0EYRSctlohqjsWnlQmRg4u FqYvw6JBPi95x5cwL7sPWPncNEzz5R9gYim+AOFte24wbcG9rN+T6UY/NhjbdQzBoOvmSn lQjavpdnhOZ1742A9bS2mi4n/6yzzIp+lpU0NiWRxtVniK7WNd3E/MmyidiKqsFylRXv9J zOmPZFA3G3LperptWt1y6z2xYjgEedI+dwD/irih7rMT38BchoGNATGNsdCDAQ== 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=1707769072; 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=j8qcmRVsihBu3uQPRY9GyWjQssVnSBOsKrwlUsCE7ws=; b=ysZbuDDZQ9r9UFmlfozHZ4AxtUJ5jI5hyJ0tAuUSK0U18PpAh9QEcqtv1pbAxPWwo1vMDC PzNQt+oU+nqrLs2TF0/x8nprsYzdFNPBdEKC0MjlXJVpUIo8bWH1OeNo8zLqZPh3IrbSdN m4F/+7goctcTEtr9DmV3ueRx74ZkczdK2CpvfZpOhPMEI37IOJpSYCOEG3sa35Dj2bPsHz +xmRnpH4uyhderSqi8senq+mpZPDxlgv+KpvajzM/xj6f0xTqZfRXziZpJurenkE8iWp11 a16sQ4pgkylzfiaESPrZiHF16DxErCh0wmRmopFKoQ+1P2akFgYIB7HWPqVovA== 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 4TYbNv6Djlzlxq; Mon, 12 Feb 2024 20:17:51 +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 41CKHpQo066340; Mon, 12 Feb 2024 20:17:51 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CKHp7K066337; Mon, 12 Feb 2024 20:17:51 GMT (envelope-from git) Date: Mon, 12 Feb 2024 20:17:51 GMT Message-Id: <202402122017.41CKHp7K066337@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: f2c72486da30 - releng/13.3 - fusefs: fix invalid value for st_birthtime.tv_nsec List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/releng/13.3 X-Git-Reftype: branch X-Git-Commit: f2c72486da30eda54f0db1a9b7ca822afc835ecf Auto-Submitted: auto-generated The branch releng/13.3 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=f2c72486da30eda54f0db1a9b7ca822afc835ecf commit f2c72486da30eda54f0db1a9b7ca822afc835ecf Author: Alan Somers AuthorDate: 2024-01-25 15:19:37 +0000 Commit: Alan Somers CommitDate: 2024-02-12 20:17:13 +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 Approved by: re (cperciva) Differential Revision: https://reviews.freebsd.org/D43590 (cherry picked from commit 65e25e4a614a99243e7419279b294e399991dfff) --- 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 13d18127d2e6..c851cb2e34f4 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 a02b41e24ad8..52bd2d92f4da 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); } /*