Date: Wed, 30 Oct 2019 01:35:01 +0000 (UTC) From: Alan Somers <asomers@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r354161 - in stable/12: sys/fs/fuse tests/sys/fs/fusefs Message-ID: <201910300135.x9U1Z1lr001102@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: asomers Date: Wed Oct 30 01:35:00 2019 New Revision: 354161 URL: https://svnweb.freebsd.org/changeset/base/354161 Log: MFC r352404, r352413-r352414 r352404: fusefs: fix some minor issues with fuse_vnode_setparent * When unparenting a vnode, actually clear the flag. AFAIK this is basically a no-op because we only unparent a vnode when reclaiming it or when unlinking. * There's no need to call fuse_vnode_setparent during reclaim, because we're about to free the vnode data anyway. Reviewed by: emaste Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21630 r352413: fusefs: fix some minor Coverity CIDs in the tests Where open(2) is expected to fail, the tests should assert or expect that its return value is -1. These tests all accepted too much but happened to pass anyway. Reported by: Coverity Coverity CID: 1404512, 1404378, 1404504, 1404483 Sponsored by: The FreeBSD Foundation r352414: fusefs: initialize C++ classes the Coverity way Coverity complained that I wasn't initializing some class members until the SetUp method. Do it in the constructor instead. Reported by: Coverity Coverity CIDs: 1404352, 1404378 Sponsored by: The FreeBSD Foundation Modified: stable/12/sys/fs/fuse/fuse_node.h stable/12/sys/fs/fuse/fuse_vnops.c stable/12/tests/sys/fs/fusefs/create.cc stable/12/tests/sys/fs/fusefs/default_permissions.cc stable/12/tests/sys/fs/fusefs/io.cc stable/12/tests/sys/fs/fusefs/mknod.cc stable/12/tests/sys/fs/fusefs/opendir.cc Directory Properties: stable/12/ (props changed) Modified: stable/12/sys/fs/fuse/fuse_node.h ============================================================================== --- stable/12/sys/fs/fuse/fuse_node.h Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/sys/fs/fuse/fuse_node.h Wed Oct 30 01:35:00 2019 (r354161) @@ -174,6 +174,8 @@ fuse_vnode_setparent(struct vnode *vp, struct vnode *d MPASS(dvp->v_type == VDIR); VTOFUD(vp)->parent_nid = VTOI(dvp); VTOFUD(vp)->flag |= FN_PARENT_NID; + } else { + VTOFUD(vp)->flag &= ~FN_PARENT_NID; } } Modified: stable/12/sys/fs/fuse/fuse_vnops.c ============================================================================== --- stable/12/sys/fs/fuse/fuse_vnops.c Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/sys/fs/fuse/fuse_vnops.c Wed Oct 30 01:35:00 2019 (r354161) @@ -1526,11 +1526,10 @@ fuse_vnop_reclaim(struct vop_reclaim_args *ap) fuse_filehandle_close(vp, fufh, td, NULL); } - if ((!fuse_isdeadfs(vp)) && (fvdat->nlookup)) { + if (!fuse_isdeadfs(vp) && fvdat->nlookup > 0) { fuse_internal_forget_send(vnode_mount(vp), td, NULL, VTOI(vp), fvdat->nlookup); } - fuse_vnode_setparent(vp, NULL); cache_purge(vp); vfs_hash_remove(vp); vnode_destroy_vobject(vp); Modified: stable/12/tests/sys/fs/fusefs/create.cc ============================================================================== --- stable/12/tests/sys/fs/fusefs/create.cc Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/tests/sys/fs/fusefs/create.cc Wed Oct 30 01:35:00 2019 (r354161) @@ -204,7 +204,7 @@ TEST_F(Create, eexist) EXPECT_LOOKUP(FUSE_ROOT_ID, RELPATH) .WillOnce(Invoke(ReturnErrno(ENOENT))); expect_create(RELPATH, mode, ReturnErrno(EEXIST)); - EXPECT_NE(0, open(FULLPATH, O_CREAT | O_EXCL, mode)); + EXPECT_EQ(-1, open(FULLPATH, O_CREAT | O_EXCL, mode)); EXPECT_EQ(EEXIST, errno); } @@ -342,7 +342,7 @@ TEST_F(Create, eperm) .WillOnce(Invoke(ReturnErrno(ENOENT))); expect_create(RELPATH, mode, ReturnErrno(EPERM)); - EXPECT_NE(0, open(FULLPATH, O_CREAT | O_EXCL, mode)); + EXPECT_EQ(-1, open(FULLPATH, O_CREAT | O_EXCL, mode)); EXPECT_EQ(EPERM, errno); } Modified: stable/12/tests/sys/fs/fusefs/default_permissions.cc ============================================================================== --- stable/12/tests/sys/fs/fusefs/default_permissions.cc Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/tests/sys/fs/fusefs/default_permissions.cc Wed Oct 30 01:35:00 2019 (r354161) @@ -749,7 +749,7 @@ TEST_F(Open, eacces) expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755, UINT64_MAX, 1); expect_lookup(RELPATH, ino, S_IFREG | 0644, UINT64_MAX); - EXPECT_NE(0, open(FULLPATH, O_RDWR)); + EXPECT_EQ(-1, open(FULLPATH, O_RDWR)); EXPECT_EQ(EACCES, errno); } Modified: stable/12/tests/sys/fs/fusefs/io.cc ============================================================================== --- stable/12/tests/sys/fs/fusefs/io.cc Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/tests/sys/fs/fusefs/io.cc Wed Oct 30 01:35:00 2019 (r354161) @@ -108,11 +108,11 @@ int m_backing_fd, m_control_fd, m_test_fd; off_t m_filesize; bool m_direct_io; -Io(): m_backing_fd(-1), m_control_fd(-1), m_test_fd(-1), m_direct_io(false) {}; +Io(): m_backing_fd(-1), m_control_fd(-1), m_test_fd(-1), m_filesize(0), + m_direct_io(false) {}; void SetUp() { - m_filesize = 0; m_backing_fd = open("backing_file", O_RDWR | O_CREAT | O_TRUNC, 0644); if (m_backing_fd < 0) FAIL() << strerror(errno); Modified: stable/12/tests/sys/fs/fusefs/mknod.cc ============================================================================== --- stable/12/tests/sys/fs/fusefs/mknod.cc Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/tests/sys/fs/fusefs/mknod.cc Wed Oct 30 01:35:00 2019 (r354161) @@ -55,8 +55,11 @@ const static mode_t c_umask = 022; public: -virtual void SetUp() { +Mknod() { m_oldmask = umask(c_umask); +} + +virtual void SetUp() { if (geteuid() != 0) { GTEST_SKIP() << "Only root may use most mknod(2) variations"; } Modified: stable/12/tests/sys/fs/fusefs/opendir.cc ============================================================================== --- stable/12/tests/sys/fs/fusefs/opendir.cc Wed Oct 30 01:24:28 2019 (r354160) +++ stable/12/tests/sys/fs/fusefs/opendir.cc Wed Oct 30 01:35:00 2019 (r354161) @@ -103,7 +103,7 @@ TEST_F(Opendir, eperm) expect_lookup(RELPATH, ino); expect_opendir(ino, O_RDONLY, ReturnErrno(EPERM)); - EXPECT_NE(0, open(FULLPATH, O_DIRECTORY)); + EXPECT_EQ(-1, open(FULLPATH, O_DIRECTORY)); EXPECT_EQ(EPERM, errno); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201910300135.x9U1Z1lr001102>