From nobody Mon Feb 12 18:03:03 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 4TYXPN1m0Rz5BGMj; Mon, 12 Feb 2024 18:03:04 +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 4TYXPN1KgHz4ZlY; Mon, 12 Feb 2024 18:03:04 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1707760984; 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=W5CcNBQQ4eWsDPk/6qQ7k+ilEdGZHhU+Wd6L0s0u+nw=; b=JKha0R4XSct8arkjNyKMe02klGixCYQGTgRjp70RUfzpYIDcx3ZipZ+ejUsgRnQgXeQR2r iYv2AvXy09PcYXdqJP7n10/H3ivMktr9WcPlgJ8fP2r48CrRdiXDzuS3NhsClDn5wQo+B4 BG72M9ljJgk8wqk9A+dWlwsUhdqEbq2eiFXhiomCNi2QE3JFWlDjujmzHHUXnbHdPiiZzl cCoWYO2cicw/Qf0Y/lz/G4rNJzag8rRpKI7nAtr3i9QGdnw17r7vp2/8iZFZ2awUrkusab ZB5x6zpPS3UbW6vLZC+i8kux8t79d6nE3hh7EmpbWbiVpOhqjO1ZIyYbjcV5lg== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1707760984; a=rsa-sha256; cv=none; b=D1sGJGHQtIRRLuoThU9iYz6EmViZWlrvCxO52j6FPrbjToJCvch1UZn4RGErJkIovP/q2H 6EP01r47STH5I2SdcHajZnA6SEanJQ4SvQwLSuLKOPhfU9/xQ/NDP28IpcN3+dcVA6Ec9G 20vnWKuo1ucAaQjCRP0ndda5I/2/5XJdzQSXHvwwrjBjvuxxmExpktHeAG/F7S1O9LhbmV MNvWWme29rfCVj7QVqKyZnWhp++1xeEYzonlXYIHxEnU1wrgBq9ec5PkcxX+qELyxRiz4H kUjS5roJXUQriJFI+4a+5fwJ99P7Z1r5GHliZsEyiXSWpcJOBL85mJfTgyrm3A== 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=1707760984; 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=W5CcNBQQ4eWsDPk/6qQ7k+ilEdGZHhU+Wd6L0s0u+nw=; b=YEm+C787jWc18Ajl1tXjWoiPwUrPtpfc7NqgvUqt5uLeCGTJFw6giUPQQEKMApjc62Y51V qYzmfABbkULeTlls17TiBUx4R28zIfcToAyiogKn8wMIlbt3WNFh/22bfS18jYUAmtIOGp Hpv43jvhjz4meHNVCAKUQhRJ0d22CcZqvhDPOA4UCiPCTEkllmoS20cmhySd9QHeNzMMe6 m4e0OfGjBG0HW6RYenAeDa/GtPL8JxmyxJhU3x0Ij1Fr73djICtpsegs10YCm6Hw66sRQ4 +bvHWiSQSxx11H4eMy9XeTeJJjHj/hVBsVtJeA60OMU0af9axWen6+wwEtpy/A== 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 4TYXPN0PRBzhVq; Mon, 12 Feb 2024 18:03:04 +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 41CI33AW046622; Mon, 12 Feb 2024 18:03:03 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 41CI338i046619; Mon, 12 Feb 2024 18:03:03 GMT (envelope-from git) Date: Mon, 12 Feb 2024 18:03:03 GMT Message-Id: <202402121803.41CI338i046619@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: 65e25e4a614a - stable/13 - 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/13 X-Git-Reftype: branch X-Git-Commit: 65e25e4a614a99243e7419279b294e399991dfff Auto-Submitted: auto-generated The branch stable/13 has been updated by asomers: URL: https://cgit.FreeBSD.org/src/commit/?id=65e25e4a614a99243e7419279b294e399991dfff commit 65e25e4a614a99243e7419279b294e399991dfff Author: Alan Somers AuthorDate: 2024-01-25 15:19:37 +0000 Commit: Alan Somers CommitDate: 2024-02-12 18:02:50 +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 --- 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); } /*