From 5a0b9a2776715c31a8c0364674b34f13c75f3179 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sat, 20 Jul 2019 05:21:13 +0000 Subject: [PATCH 1/9] fusefs: fix warnings in the tests reported by GCC Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/Makefile | 2 ++ tests/sys/fs/fusefs/allow_other.cc | 6 +---- tests/sys/fs/fusefs/default_permissions.cc | 16 +++++++------ tests/sys/fs/fusefs/destroy.cc | 8 +++---- tests/sys/fs/fusefs/dev_fuse_poll.cc | 6 ++--- tests/sys/fs/fusefs/interrupt.cc | 6 ++--- tests/sys/fs/fusefs/io.cc | 10 ++++---- tests/sys/fs/fusefs/mockfs.cc | 2 +- tests/sys/fs/fusefs/mockfs.hh | 2 +- tests/sys/fs/fusefs/notify.cc | 4 ++-- tests/sys/fs/fusefs/opendir.cc | 2 +- tests/sys/fs/fusefs/read.cc | 4 ++-- tests/sys/fs/fusefs/readdir.cc | 28 +++++++++++----------- tests/sys/fs/fusefs/readlink.cc | 2 +- tests/sys/fs/fusefs/releasedir.cc | 6 ++--- tests/sys/fs/fusefs/setattr.cc | 17 +++++++------ tests/sys/fs/fusefs/statfs.cc | 6 ++--- tests/sys/fs/fusefs/write.cc | 22 ++++++++--------- tests/sys/fs/fusefs/xattr.cc | 18 +++++++++----- 19 files changed, 88 insertions(+), 79 deletions(-) diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index 1a4045e8f2f0..59f9dfa5aa7d 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -64,6 +64,8 @@ TEST_METADATA+= timeout=10 FUSEFS= ${SRCTOP}/sys/fs/fuse MOUNT= ${SRCTOP}/sbin/mount +# Suppress warnings that GCC generates for the libc++ and gtest headers. +CWARNFLAGS.gcc+= -Wno-placement-new -Wno-attributes -Wno-class-memaccess CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} CXXFLAGS+= -I${MOUNT} diff --git a/tests/sys/fs/fusefs/allow_other.cc b/tests/sys/fs/fusefs/allow_other.cc index 61ff5e9b5bfb..82b7b0907f94 100644 --- a/tests/sys/fs/fusefs/allow_other.cc +++ b/tests/sys/fs/fusefs/allow_other.cc @@ -131,8 +131,6 @@ TEST_F(AllowOther, creds) */ TEST_F(AllowOther, privilege_escalation) { - const static char FULLPATH[] = "mountpoint/some_file.txt"; - const static char RELPATH[] = "some_file.txt"; int fd1, status; const static uint64_t ino = 42; const static uint64_t fh = 100; @@ -220,8 +218,6 @@ TEST_F(NoAllowOther, disallowed) */ TEST_F(NoAllowOther, disallowed_beneath_root) { - const static char FULLPATH[] = "mountpoint/some_dir"; - const static char RELPATH[] = "some_dir"; const static char RELPATH2[] = "other_dir"; const static uint64_t ino = 42; const static uint64_t ino2 = 43; @@ -291,7 +287,7 @@ TEST_F(NoAllowOther, setextattr) ssize_t r; r = extattr_set_file(FULLPATH, ns, "foo", - (void*)value, value_len); + (const void*)value, value_len); if (r >= 0) { fprintf(stderr, "should've failed\n"); return(1); diff --git a/tests/sys/fs/fusefs/default_permissions.cc b/tests/sys/fs/fusefs/default_permissions.cc index 41ba7022d330..ee2a9644cf8a 100644 --- a/tests/sys/fs/fusefs/default_permissions.cc +++ b/tests/sys/fs/fusefs/default_permissions.cc @@ -231,7 +231,7 @@ static gid_t excluded_group() gid_t newgid, groups[ngroups]; getgrouplist(getlogin(), getegid(), groups, &ngroups); - for (newgid = 0; newgid >= 0; newgid++) { + for (newgid = 0; ; newgid++) { bool belongs = false; for (i = 0; i < ngroups; i++) { @@ -1090,7 +1090,8 @@ TEST_F(Setextattr, ok) expect_lookup(RELPATH, ino, S_IFREG | 0644, UINT64_MAX, geteuid()); expect_setxattr(0); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(value_len, r) << strerror(errno); } @@ -1106,8 +1107,8 @@ TEST_F(Setextattr, eacces) expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755, UINT64_MAX, 1); expect_lookup(RELPATH, ino, S_IFREG | 0644, UINT64_MAX, 0); - ASSERT_EQ(-1, - extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len)); + ASSERT_EQ(-1, extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len)); ASSERT_EQ(EACCES, errno); } @@ -1124,8 +1125,8 @@ TEST_F(Setextattr, system) expect_getattr(FUSE_ROOT_ID, S_IFDIR | 0755, UINT64_MAX, 1); expect_lookup(RELPATH, ino, S_IFREG | 0666, UINT64_MAX, geteuid()); - ASSERT_EQ(-1, - extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len)); + ASSERT_EQ(-1, extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len)); ASSERT_EQ(EPERM, errno); } @@ -1144,7 +1145,8 @@ TEST_F(Setextattr, user) expect_lookup(RELPATH, ino, S_IFREG | 0666, UINT64_MAX, 0); expect_setxattr(0); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(value_len, r) << strerror(errno); } diff --git a/tests/sys/fs/fusefs/destroy.cc b/tests/sys/fs/fusefs/destroy.cc index 2264ba4e1e8c..11df47418f6f 100644 --- a/tests/sys/fs/fusefs/destroy.cc +++ b/tests/sys/fs/fusefs/destroy.cc @@ -110,10 +110,10 @@ TEST_F(Death, unsent_operations) * One thread's operation will be sent to the daemon and block, and the * other's will be stuck in the message queue. */ - ASSERT_EQ(0, pthread_create(&th0, NULL, open_th, (void*)FULLPATH0)) - << strerror(errno); - ASSERT_EQ(0, pthread_create(&th1, NULL, open_th, (void*)FULLPATH1)) - << strerror(errno); + ASSERT_EQ(0, pthread_create(&th0, NULL, open_th, + __DECONST(void*, FULLPATH0))) << strerror(errno); + ASSERT_EQ(0, pthread_create(&th1, NULL, open_th, + __DECONST(void*, FULLPATH1))) << strerror(errno); /* Wait for the first thread to block */ sem_wait(&sem); diff --git a/tests/sys/fs/fusefs/dev_fuse_poll.cc b/tests/sys/fs/fusefs/dev_fuse_poll.cc index 85cb58f5975b..4ced6428d7c6 100644 --- a/tests/sys/fs/fusefs/dev_fuse_poll.cc +++ b/tests/sys/fs/fusefs/dev_fuse_poll.cc @@ -204,12 +204,12 @@ TEST_F(Kqueue, data) access("mountpoint/bar", F_OK); access("mountpoint/baz", F_OK); ASSERT_EQ(0, pthread_create(&th0, NULL, statter, - (void*)"mountpoint/foo")) << strerror(errno); + __DECONST(void*, "mountpoint/foo"))) << strerror(errno); EXPECT_EQ(0, sem_wait(&sem0)) << strerror(errno); ASSERT_EQ(0, pthread_create(&th1, NULL, statter, - (void*)"mountpoint/bar")) << strerror(errno); + __DECONST(void*, "mountpoint/bar"))) << strerror(errno); ASSERT_EQ(0, pthread_create(&th2, NULL, statter, - (void*)"mountpoint/baz")) << strerror(errno); + __DECONST(void*, "mountpoint/baz"))) << strerror(errno); nap(); // Allow th1 and th2 to send their ops to the daemon EXPECT_EQ(0, sem_post(&sem1)) << strerror(errno); diff --git a/tests/sys/fs/fusefs/interrupt.cc b/tests/sys/fs/fusefs/interrupt.cc index 9a2e55241dad..a62ca61f20cc 100644 --- a/tests/sys/fs/fusefs/interrupt.cc +++ b/tests/sys/fs/fusefs/interrupt.cc @@ -520,7 +520,8 @@ TEST_F(Intr, in_kernel_nonrestartable) setup_interruptor(self, true); - r = extattr_set_fd(fd1, ns, "foo", (void*)value, value_len); + r = extattr_set_fd(fd1, ns, "foo", (const void*)value, value_len); + EXPECT_NE(0, r); EXPECT_EQ(EINTR, errno); /* Unstick the daemon */ @@ -664,12 +665,11 @@ TEST_F(Intr, priority) Sequence seq; uint64_t ino1 = 43; uint64_t mkdir_unique; - pthread_t self, th0; + pthread_t th0; sem_t sem0, sem1; ASSERT_EQ(0, sem_init(&sem0, 0, 0)) << strerror(errno); ASSERT_EQ(0, sem_init(&sem1, 0, 0)) << strerror(errno); - self = pthread_self(); EXPECT_LOOKUP(FUSE_ROOT_ID, RELDIRPATH0) .WillOnce(Invoke(ReturnErrno(ENOENT))); diff --git a/tests/sys/fs/fusefs/io.cc b/tests/sys/fs/fusefs/io.cc index 12e2c67f2bde..0daffb8b7ad5 100644 --- a/tests/sys/fs/fusefs/io.cc +++ b/tests/sys/fs/fusefs/io.cc @@ -266,7 +266,7 @@ void do_mapread(ssize_t size, off_t offs) ASSERT_NE(p, MAP_FAILED) << strerror(errno); control_buf = malloc(size); - ASSERT_NE(NULL, control_buf) << strerror(errno); + ASSERT_NE(nullptr, control_buf) << strerror(errno); ASSERT_EQ(size, pread(m_control_fd, control_buf, size, offs)) << strerror(errno); @@ -283,9 +283,9 @@ void do_read(ssize_t size, off_t offs) ssize_t r; test_buf = malloc(size); - ASSERT_NE(NULL, test_buf) << strerror(errno); + ASSERT_NE(nullptr, test_buf) << strerror(errno); control_buf = malloc(size); - ASSERT_NE(NULL, control_buf) << strerror(errno); + ASSERT_NE(nullptr, control_buf) << strerror(errno); errno = 0; r = pread(m_test_fd, test_buf, size, offs); @@ -314,7 +314,7 @@ void do_mapwrite(ssize_t size, off_t offs) map_size = pg_offset + size; buf = (char*)malloc(size); - ASSERT_NE(NULL, buf) << strerror(errno); + ASSERT_NE(nullptr, buf) << strerror(errno); for (i=0; i < size; i++) buf[i] = random(); @@ -344,7 +344,7 @@ void do_write(ssize_t size, off_t offs) long i; buf = (char*)malloc(size); - ASSERT_NE(NULL, buf) << strerror(errno); + ASSERT_NE(nullptr, buf) << strerror(errno); for (i=0; i < size; i++) buf[i] = random(); diff --git a/tests/sys/fs/fusefs/mockfs.cc b/tests/sys/fs/fusefs/mockfs.cc index f992387d272e..fddfbd6d710b 100644 --- a/tests/sys/fs/fusefs/mockfs.cc +++ b/tests/sys/fs/fusefs/mockfs.cc @@ -564,7 +564,7 @@ int MockFS::notify_inval_inode(ino_t ino, off_t off, ssize_t len) return 0; } -int MockFS::notify_store(ino_t ino, off_t off, void* data, ssize_t size) +int MockFS::notify_store(ino_t ino, off_t off, const void* data, ssize_t size) { std::unique_ptr out(new mockfs_buf_out); diff --git a/tests/sys/fs/fusefs/mockfs.hh b/tests/sys/fs/fusefs/mockfs.hh index ccf3d915bdb5..977d7780ccb4 100644 --- a/tests/sys/fs/fusefs/mockfs.hh +++ b/tests/sys/fs/fusefs/mockfs.hh @@ -375,7 +375,7 @@ class MockFS { * @param data Pointer to the data to cache * @param len Size of data */ - int notify_store(ino_t ino, off_t off, void* data, ssize_t size); + int notify_store(ino_t ino, off_t off, const void* data, ssize_t size); /* * Request handler diff --git a/tests/sys/fs/fusefs/notify.cc b/tests/sys/fs/fusefs/notify.cc index b6e29a7d429c..30b59f21b4e1 100644 --- a/tests/sys/fs/fusefs/notify.cc +++ b/tests/sys/fs/fusefs/notify.cc @@ -129,7 +129,7 @@ struct store_args { ino_t nodeid; off_t offset; ssize_t size; - void* data; + const void* data; }; static void* inval_inode(void* arg) { @@ -433,7 +433,7 @@ TEST_F(Notify, DISABLED_store_with_blank_cache) sa.nodeid = ino; sa.offset = 0; sa.size = size1; - sa.data = (void*)CONTENTS1; + sa.data = (const void*)CONTENTS1; ASSERT_EQ(0, pthread_create(&th0, NULL, store, &sa)) << strerror(errno); pthread_join(th0, &thr0_value); EXPECT_EQ(0, (intptr_t)thr0_value); diff --git a/tests/sys/fs/fusefs/opendir.cc b/tests/sys/fs/fusefs/opendir.cc index 3cae8105040f..f970ab134e1e 100644 --- a/tests/sys/fs/fusefs/opendir.cc +++ b/tests/sys/fs/fusefs/opendir.cc @@ -151,5 +151,5 @@ TEST_F(Opendir, opendir) })); errno = 0; - EXPECT_NE(NULL, opendir(FULLPATH)) << strerror(errno); + EXPECT_NE(nullptr, opendir(FULLPATH)) << strerror(errno); } diff --git a/tests/sys/fs/fusefs/read.cc b/tests/sys/fs/fusefs/read.cc index ff1d6d41c319..bf0641738fca 100644 --- a/tests/sys/fs/fusefs/read.cc +++ b/tests/sys/fs/fusefs/read.cc @@ -765,7 +765,7 @@ TEST_F(Read, cache_block) const char *contents1 = CONTENTS0 + bufsize; contents = (char*)calloc(1, filesize); - ASSERT_NE(NULL, contents); + ASSERT_NE(nullptr, contents); memmove(contents, CONTENTS0, strlen(CONTENTS0)); expect_lookup(RELPATH, ino, filesize); @@ -880,7 +880,7 @@ TEST_P(ReadAhead, readahead) { off_t offs; contents = (char*)malloc(filesize); - ASSERT_NE(NULL, contents); + ASSERT_NE(nullptr, contents); memset(contents, 'X', filesize); rbuf = (char*)calloc(1, bufsize); diff --git a/tests/sys/fs/fusefs/readdir.cc b/tests/sys/fs/fusefs/readdir.cc index 81edccb8b2ef..db207790ed78 100644 --- a/tests/sys/fs/fusefs/readdir.cc +++ b/tests/sys/fs/fusefs/readdir.cc @@ -90,11 +90,11 @@ TEST_F(Readdir, dots) errno = 0; dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); errno = 0; de = readdir(dir); - ASSERT_NE(NULL, de) << strerror(errno); + ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(2ul, de->d_fileno); /* * fuse(4) doesn't actually set d_off, which is ok for now because @@ -107,14 +107,14 @@ TEST_F(Readdir, dots) errno = 0; de = readdir(dir); - ASSERT_NE(NULL, de) << strerror(errno); + ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(3ul, de->d_fileno); //EXPECT_EQ(3000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); EXPECT_EQ(1, de->d_namlen); EXPECT_EQ(0, strcmp(".", de->d_name)); - ASSERT_EQ(NULL, readdir(dir)); + ASSERT_EQ(nullptr, readdir(dir)); ASSERT_EQ(0, errno); leakdir(dir); @@ -141,11 +141,11 @@ TEST_F(Readdir, eio) errno = 0; dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); errno = 0; de = readdir(dir); - ASSERT_EQ(NULL, de); + ASSERT_EQ(nullptr, de); ASSERT_EQ(EIO, errno); leakdir(dir); @@ -259,9 +259,9 @@ TEST_F(Readdir, nodots) errno = 0; dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); errno = 0; - ASSERT_EQ(NULL, readdir(dir)); + ASSERT_EQ(nullptr, readdir(dir)); ASSERT_EQ(0, errno); leakdir(dir); @@ -318,12 +318,12 @@ TEST_F(Readdir, seekdir) errno = 0; dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); for (i=0; i < 128; i++) { errno = 0; de = readdir(dir); - ASSERT_NE(NULL, de) << strerror(errno); + ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(2 + (ino_t)i, de->d_fileno); } bookmark = telldir(dir); @@ -331,13 +331,13 @@ TEST_F(Readdir, seekdir) for (; i < 232; i++) { errno = 0; de = readdir(dir); - ASSERT_NE(NULL, de) << strerror(errno); + ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(2 + (ino_t)i, de->d_fileno); } seekdir(dir, bookmark); de = readdir(dir); - ASSERT_NE(NULL, de) << strerror(errno); + ASSERT_NE(nullptr, de) << strerror(errno); EXPECT_EQ(130ul, de->d_fileno); leakdir(dir); @@ -366,9 +366,9 @@ TEST_F(Readdir_7_8, nodots) errno = 0; dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); errno = 0; - ASSERT_EQ(NULL, readdir(dir)); + ASSERT_EQ(nullptr, readdir(dir)); ASSERT_EQ(0, errno); leakdir(dir); diff --git a/tests/sys/fs/fusefs/readlink.cc b/tests/sys/fs/fusefs/readlink.cc index 5fca720cc5f7..121c61b26ab6 100644 --- a/tests/sys/fs/fusefs/readlink.cc +++ b/tests/sys/fs/fusefs/readlink.cc @@ -113,7 +113,7 @@ TEST_F(PushSymlinksIn, readlink) out.header.len = sizeof(out.header) + strlen(dst) + 1; })); - ASSERT_NE(NULL, getcwd(wd, sizeof(wd))) << strerror(errno); + ASSERT_NE(nullptr, getcwd(wd, sizeof(wd))) << strerror(errno); len = snprintf(want, sizeof(want), "%s/mountpoint%s", wd, dst); ASSERT_LE(0, len) << strerror(errno); diff --git a/tests/sys/fs/fusefs/releasedir.cc b/tests/sys/fs/fusefs/releasedir.cc index e2b7fd3f1143..7c9ee6e88d3a 100644 --- a/tests/sys/fs/fusefs/releasedir.cc +++ b/tests/sys/fs/fusefs/releasedir.cc @@ -71,10 +71,10 @@ TEST_F(ReleaseDir, dup) expect_releasedir(ino, ReturnErrno(0)); dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); dir2 = fdopendir(dup(dirfd(dir))); - ASSERT_NE(NULL, dir2) << strerror(errno); + ASSERT_NE(nullptr, dir2) << strerror(errno); ASSERT_EQ(0, closedir(dir)) << strerror(errno); ASSERT_EQ(0, closedir(dir2)) << strerror(errno); @@ -92,7 +92,7 @@ TEST_F(ReleaseDir, ok) expect_releasedir(ino, ReturnErrno(0)); dir = opendir(FULLPATH); - ASSERT_NE(NULL, dir) << strerror(errno); + ASSERT_NE(nullptr, dir) << strerror(errno); ASSERT_EQ(0, closedir(dir)) << strerror(errno); } diff --git a/tests/sys/fs/fusefs/setattr.cc b/tests/sys/fs/fusefs/setattr.cc index fe82038c6aad..197f7ff33999 100644 --- a/tests/sys/fs/fusefs/setattr.cc +++ b/tests/sys/fs/fusefs/setattr.cc @@ -449,16 +449,16 @@ TEST_F(Setattr, truncate_discards_cached_data) { bool should_have_data = false; w0buf = malloc(w0_size); - ASSERT_NE(NULL, w0buf) << strerror(errno); + ASSERT_NE(nullptr, w0buf) << strerror(errno); memset(w0buf, 'X', w0_size); r0buf = malloc(r0_size); - ASSERT_NE(NULL, r0buf) << strerror(errno); + ASSERT_NE(nullptr, r0buf) << strerror(errno); r1buf = malloc(r1_size); - ASSERT_NE(NULL, r1buf) << strerror(errno); + ASSERT_NE(nullptr, r1buf) << strerror(errno); expected = malloc(r1_size); - ASSERT_NE(NULL, expected) << strerror(errno); + ASSERT_NE(nullptr, expected) << strerror(errno); memset(expected, 0, r1_size); expect_lookup(RELPATH, ino, mode, 0, 1); @@ -580,10 +580,12 @@ TEST_F(Setattr, utimensat) { return (in.header.opcode == FUSE_SETATTR && in.header.nodeid == ino && in.body.setattr.valid == valid && - in.body.setattr.atime == newtimes[0].tv_sec && + (time_t)in.body.setattr.atime == + newtimes[0].tv_sec && in.body.setattr.atimensec == newtimes[0].tv_nsec && - in.body.setattr.mtime == newtimes[1].tv_sec && + (time_t)in.body.setattr.mtime == + newtimes[1].tv_sec && in.body.setattr.mtimensec == newtimes[1].tv_nsec); }, Eq(true)), @@ -633,7 +635,8 @@ TEST_F(Setattr, utimensat_mtime_only) { return (in.header.opcode == FUSE_SETATTR && in.header.nodeid == ino && in.body.setattr.valid == valid && - in.body.setattr.mtime == newtimes[1].tv_sec && + (time_t)in.body.setattr.mtime == + newtimes[1].tv_sec && in.body.setattr.mtimensec == newtimes[1].tv_nsec); }, Eq(true)), diff --git a/tests/sys/fs/fusefs/statfs.cc b/tests/sys/fs/fusefs/statfs.cc index a97d131b085c..7a9635565355 100644 --- a/tests/sys/fs/fusefs/statfs.cc +++ b/tests/sys/fs/fusefs/statfs.cc @@ -67,7 +67,7 @@ TEST_F(Statfs, enotconn) m_mock->kill_daemon(); - ASSERT_NE(NULL, getcwd(mp, PATH_MAX)) << strerror(errno); + ASSERT_NE(nullptr, getcwd(mp, PATH_MAX)) << strerror(errno); strlcat(mp, "/mountpoint", PATH_MAX); ASSERT_EQ(0, statfs("mountpoint", &statbuf)) << strerror(errno); @@ -112,7 +112,7 @@ TEST_F(Statfs, enotconn_while_blocked) /* Just block until the daemon dies */ })); - ASSERT_NE(NULL, getcwd(mp, PATH_MAX)) << strerror(errno); + ASSERT_NE(nullptr, getcwd(mp, PATH_MAX)) << strerror(errno); strlcat(mp, "/mountpoint", PATH_MAX); ASSERT_EQ(0, pthread_create(&th0, NULL, statfs_th, (void*)&statbuf)) << strerror(errno); @@ -150,7 +150,7 @@ TEST_F(Statfs, ok) out.body.statfs.st.frsize = 1024; }))); - ASSERT_NE(NULL, getcwd(mp, PATH_MAX)) << strerror(errno); + ASSERT_NE(nullptr, getcwd(mp, PATH_MAX)) << strerror(errno); strlcat(mp, "/mountpoint", PATH_MAX); ASSERT_EQ(0, statfs("mountpoint", &statbuf)) << strerror(errno); EXPECT_EQ(1024ul, statbuf.f_bsize); diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc index 3641ae50fe24..8ddde2c222f6 100644 --- a/tests/sys/fs/fusefs/write.cc +++ b/tests/sys/fs/fusefs/write.cc @@ -226,7 +226,7 @@ TEST_F(AioWrite, DISABLED_aio_write) iocb.aio_nbytes = bufsize; iocb.aio_fildes = fd; - iocb.aio_buf = (void *)CONTENTS; + iocb.aio_buf = __DECONST(void *, CONTENTS); iocb.aio_offset = offset; iocb.aio_sigevent.sigev_notify = SIGEV_NONE; ASSERT_EQ(0, aio_write(&iocb)) << strerror(errno); @@ -286,9 +286,9 @@ TEST_F(Write, append_to_cached) int fd; oldcontents = (char*)calloc(1, oldsize); - ASSERT_NE(NULL, oldcontents) << strerror(errno); + ASSERT_NE(nullptr, oldcontents) << strerror(errno); oldbuf = (char*)malloc(oldsize); - ASSERT_NE(NULL, oldbuf) << strerror(errno); + ASSERT_NE(nullptr, oldbuf) << strerror(errno); expect_lookup(RELPATH, ino, oldsize); expect_open(ino, 0, 1); @@ -448,9 +448,9 @@ TEST_F(Write, direct_io_short_write_iov) fd = open(FULLPATH, O_WRONLY); EXPECT_LE(0, fd) << strerror(errno); - iov[0].iov_base = (void*)CONTENTS0; + iov[0].iov_base = __DECONST(void*, CONTENTS0); iov[0].iov_len = strlen(CONTENTS0); - iov[1].iov_base = (void*)CONTENTS1; + iov[1].iov_base = __DECONST(void*, CONTENTS1); iov[1].iov_len = strlen(CONTENTS1); ASSERT_EQ(size0, writev(fd, iov, 2)) << strerror(errno); leak(fd); @@ -540,9 +540,9 @@ TEST_F(Write, mmap) len = getpagesize(); zeros = calloc(1, len); - ASSERT_NE(NULL, zeros); + ASSERT_NE(nullptr, zeros); expected = calloc(1, len); - ASSERT_NE(NULL, expected); + ASSERT_NE(nullptr, expected); memmove((uint8_t*)expected + offset, CONTENTS, bufsize); expect_lookup(RELPATH, ino, len); @@ -655,7 +655,7 @@ TEST_F(Write, write_large) halfbufsize = m_mock->m_maxwrite; bufsize = halfbufsize * 2; contents = (int*)malloc(bufsize); - ASSERT_NE(NULL, contents); + ASSERT_NE(nullptr, contents); for (int i = 0; i < (int)bufsize / (int)sizeof(i); i++) { contents[i] = i; } @@ -758,10 +758,10 @@ TEST_F(WriteCluster, clustering) off_t filesize = 5 * bufsize; wbuf = malloc(bufsize); - ASSERT_NE(NULL, wbuf) << strerror(errno); + ASSERT_NE(nullptr, wbuf) << strerror(errno); memset(wbuf, 'X', bufsize); wbuf2x = malloc(2 * bufsize); - ASSERT_NE(NULL, wbuf2x) << strerror(errno); + ASSERT_NE(nullptr, wbuf2x) << strerror(errno); memset(wbuf2x, 'X', 2 * bufsize); expect_lookup(RELPATH, ino, filesize); @@ -805,7 +805,7 @@ TEST_F(WriteCluster, DISABLED_cluster_write_err) off_t filesize = 4 * bufsize; wbuf = malloc(bufsize); - ASSERT_NE(NULL, wbuf) << strerror(errno); + ASSERT_NE(nullptr, wbuf) << strerror(errno); memset(wbuf, 'X', bufsize); expect_lookup(RELPATH, ino, filesize); diff --git a/tests/sys/fs/fusefs/xattr.cc b/tests/sys/fs/fusefs/xattr.cc index bc60cd641be7..a7f24bc33a77 100644 --- a/tests/sys/fs/fusefs/xattr.cc +++ b/tests/sys/fs/fusefs/xattr.cc @@ -542,12 +542,14 @@ TEST_F(Setxattr, enosys) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 2); expect_setxattr(ino, "user.foo", value, ReturnErrno(ENOSYS)); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(-1, r); EXPECT_EQ(EOPNOTSUPP, errno); /* Subsequent attempts should not query the filesystem at all */ - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(-1, r); EXPECT_EQ(EOPNOTSUPP, errno); } @@ -567,7 +569,8 @@ TEST_F(Setxattr, enotsup) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); expect_setxattr(ino, "user.foo", value, ReturnErrno(ENOTSUP)); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(-1, r); EXPECT_EQ(ENOTSUP, errno); } @@ -586,7 +589,8 @@ TEST_F(Setxattr, user) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); expect_setxattr(ino, "user.foo", value, ReturnErrno(0)); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(value_len, r) << strerror(errno); } @@ -604,7 +608,8 @@ TEST_F(Setxattr, system) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); expect_setxattr(ino, "system.foo", value, ReturnErrno(0)); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(value_len, r) << strerror(errno); } @@ -629,7 +634,8 @@ TEST_F(RofsXattr, setextattr_erofs) expect_lookup(RELPATH, ino, S_IFREG | 0644, 0, 1); - r = extattr_set_file(FULLPATH, ns, "foo", (void*)value, value_len); + r = extattr_set_file(FULLPATH, ns, "foo", (const void*)value, + value_len); ASSERT_EQ(-1, r); EXPECT_EQ(EROFS, errno); } From 669a092af1d423a2f2ae924dcf875cab73125c13 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 28 Jul 2019 15:17:32 +0000 Subject: [PATCH 2/9] fusefs: fix panic when writing with O_DIRECT and using writeback cache When a fusefs file system is mounted using the writeback cache, the cache may still be bypassed by opening a file with O_DIRECT. When writing with O_DIRECT, the cache must be invalidated for the affected portion of the file. Fix some panics caused by inadvertently invalidating too much. Sponsored by: The FreeBSD Foundation --- sys/fs/fuse/fuse_io.c | 61 ++++++++++++++++- tests/sys/fs/fusefs/write.cc | 126 +++++++++++++++++++++++++++++++++++ 2 files changed, 184 insertions(+), 3 deletions(-) diff --git a/sys/fs/fuse/fuse_io.c b/sys/fs/fuse/fuse_io.c index 00dc62834afc..924d437c2fe3 100644 --- a/sys/fs/fuse/fuse_io.c +++ b/sys/fs/fuse/fuse_io.c @@ -119,9 +119,11 @@ SDT_PROVIDER_DECLARE(fusefs); */ SDT_PROBE_DEFINE2(fusefs, , io, trace, "int", "char*"); +static int +fuse_inval_buf_range(struct vnode *vp, off_t filesize, off_t start, off_t end); static void fuse_io_clear_suid_on_write(struct vnode *vp, struct ucred *cred, - struct thread *td); + struct thread *td); static int fuse_read_directbackend(struct vnode *vp, struct uio *uio, struct ucred *cred, struct fuse_filehandle *fufh); @@ -136,6 +138,58 @@ static int fuse_write_biobackend(struct vnode *vp, struct uio *uio, struct ucred *cred, struct fuse_filehandle *fufh, int ioflag, pid_t pid); +/* Invalidate a range of cached data, whether dirty of not */ +static int +fuse_inval_buf_range(struct vnode *vp, off_t filesize, off_t start, off_t end) +{ + struct buf *bp; + daddr_t left_lbn, end_lbn, right_lbn; + off_t new_filesize; + int iosize, left_on, right_on, right_blksize; + + iosize = fuse_iosize(vp); + left_lbn = start / iosize; + end_lbn = howmany(end, iosize); + left_on = start & (iosize - 1); + if (left_on != 0) { + bp = getblk(vp, left_lbn, iosize, PCATCH, 0, 0); + if ((bp->b_flags & B_CACHE) != 0 && bp->b_dirtyend >= left_on) { + /* + * Flush the dirty buffer, because we don't have a + * byte-granular way to record which parts of the + * buffer are valid. + */ + bwrite(bp); + if (bp->b_error) + return (bp->b_error); + } else { + brelse(bp); + } + } + right_on = end & (iosize - 1); + if (right_on != 0) { + right_lbn = end / iosize; + new_filesize = MAX(filesize, end); + right_blksize = MIN(iosize, new_filesize - iosize * right_lbn); + bp = getblk(vp, right_lbn, right_blksize, PCATCH, 0, 0); + if ((bp->b_flags & B_CACHE) != 0 && bp->b_dirtyoff < right_on) { + /* + * Flush the dirty buffer, because we don't have a + * byte-granular way to record which parts of the + * buffer are valid. + */ + bwrite(bp); + if (bp->b_error) + return (bp->b_error); + } else { + brelse(bp); + } + } + + v_inval_buf_range(vp, left_lbn, end_lbn, iosize); + return (0); +} + /* * FreeBSD clears the SUID and SGID bits on any write by a non-root user. */ @@ -236,7 +290,6 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, case UIO_WRITE: fuse_vnode_update(vp, FN_MTIMECHANGE | FN_CTIMECHANGE); if (directio) { - const int iosize = fuse_iosize(vp); off_t start, end, filesize; SDT_PROBE2(fusefs, , io, trace, 1, @@ -252,7 +305,9 @@ fuse_io_dispatch(struct vnode *vp, struct uio *uio, int ioflag, (IO_VMIO | IO_DIRECT), ("IO_DIRECT used for a cache flush?")); /* Invalidate the write cache when writing directly */ - v_inval_buf_range(vp, start, end, iosize); + err = fuse_inval_buf_range(vp, filesize, start, end); + if (err) + return (err); err = fuse_write_directbackend(vp, uio, cred, fufh, filesize, ioflag, false); } else { diff --git a/tests/sys/fs/fusefs/write.cc b/tests/sys/fs/fusefs/write.cc index 8ddde2c222f6..0f010d564824 100644 --- a/tests/sys/fs/fusefs/write.cc +++ b/tests/sys/fs/fusefs/write.cc @@ -950,6 +950,132 @@ TEST_F(WriteBackAsync, delay) /* Don't close the file because that would flush the cache */ } +/* + * A direct write should not evict dirty cached data from outside of its own + * byte range. + */ +TEST_F(WriteBackAsync, direct_io_ignores_unrelated_cached) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + const char CONTENTS0[] = "abcdefgh"; + const char CONTENTS1[] = "ijklmnop"; + uint64_t ino = 42; + int fd; + ssize_t bufsize = strlen(CONTENTS0) + 1; + ssize_t fsize = 2 * m_maxbcachebuf; + char readbuf[bufsize]; + void *zeros; + + zeros = calloc(1, m_maxbcachebuf); + ASSERT_NE(nullptr, zeros); + + expect_lookup(RELPATH, ino, fsize); + expect_open(ino, 0, 1); + expect_read(ino, 0, m_maxbcachebuf, m_maxbcachebuf, zeros); + FuseTest::expect_write(ino, m_maxbcachebuf, bufsize, bufsize, 0, 0, + CONTENTS1); + + fd = open(FULLPATH, O_RDWR); + EXPECT_LE(0, fd) << strerror(errno); + + // Cache first block with dirty data. This will entail first reading + // the existing data. + ASSERT_EQ(bufsize, pwrite(fd, CONTENTS0, bufsize, 0)) + << strerror(errno); + + // Write directly to second block + ASSERT_EQ(0, fcntl(fd, F_SETFL, O_DIRECT)) << strerror(errno); + ASSERT_EQ(bufsize, pwrite(fd, CONTENTS1, bufsize, m_maxbcachebuf)) + << strerror(errno); + + // Read from the first block again. Should be serviced by cache. + ASSERT_EQ(0, fcntl(fd, F_SETFL, 0)) << strerror(errno); + ASSERT_EQ(bufsize, pread(fd, readbuf, bufsize, 0)) << strerror(errno); + ASSERT_STREQ(readbuf, CONTENTS0); + + leak(fd); + free(zeros); +} + +/* + * If a direct io write partially overlaps one or two blocks of dirty cached + * data, No dirty data should be lost. Admittedly this is a weird test, + * because it would be unusual to use O_DIRECT and the writeback cache. + */ +TEST_F(WriteBackAsync, direct_io_partially_overlaps_cached_block) +{ + const char FULLPATH[] = "mountpoint/some_file.txt"; + const char RELPATH[] = "some_file.txt"; + uint64_t ino = 42; + int fd; + off_t bs = m_maxbcachebuf; + ssize_t fsize = 3 * bs; + void *readbuf, *zeros, *ones, *zeroones, *onezeros; + + readbuf = malloc(bs); + ASSERT_NE(nullptr, readbuf) << strerror(errno); + zeros = calloc(1, 3 * bs); + ASSERT_NE(nullptr, zeros); + ones = calloc(1, 2 * bs); + ASSERT_NE(nullptr, ones); + memset(ones, 1, 2 * bs); + zeroones = calloc(1, bs); + ASSERT_NE(nullptr, zeroones); + memset((uint8_t*)zeroones + bs / 2, 1, bs / 2); + onezeros = calloc(1, bs); + ASSERT_NE(nullptr, onezeros); + memset(onezeros, 1, bs / 2); + + expect_lookup(RELPATH, ino, fsize); + expect_open(ino, 0, 1); + + fd = open(FULLPATH, O_RDWR); + EXPECT_LE(0, fd) << strerror(errno); + + /* Cache first and third blocks with dirty data. */ + ASSERT_EQ(3 * bs, pwrite(fd, zeros, 3 * bs, 0)) << strerror(errno); + + /* + * Write directly to all three blocks. The partially written blocks + * will be flushed because they're dirty. + */ + FuseTest::expect_write(ino, 0, bs, bs, 0, 0, zeros); + FuseTest::expect_write(ino, 2 * bs, bs, bs, 0, 0, zeros); + /* The direct write is split in two because of the m_maxwrite value */ + FuseTest::expect_write(ino, bs / 2, bs, bs, 0, 0, ones); + FuseTest::expect_write(ino, 3 * bs / 2, bs, bs, 0, 0, ones); + ASSERT_EQ(0, fcntl(fd, F_SETFL, O_DIRECT)) << strerror(errno); + ASSERT_EQ(2 * bs, pwrite(fd, ones, 2 * bs, bs / 2)) << strerror(errno); + + /* + * Read from both the valid and invalid portions of the first and third + * blocks again. This will entail FUSE_READ operations because these + * blocks were invalidated by the direct write. + */ + expect_read(ino, 0, bs, bs, zeroones); + expect_read(ino, 2 * bs, bs, bs, onezeros); + ASSERT_EQ(0, fcntl(fd, F_SETFL, 0)) << strerror(errno); + ASSERT_EQ(bs / 2, pread(fd, readbuf, bs / 2, 0)) << strerror(errno); + EXPECT_EQ(0, memcmp(zeros, readbuf, bs / 2)); + ASSERT_EQ(bs / 2, pread(fd, readbuf, bs / 2, 5 * bs / 2)) + << strerror(errno); + EXPECT_EQ(0, memcmp(zeros, readbuf, bs / 2)); + ASSERT_EQ(bs / 2, pread(fd, readbuf, bs / 2, bs / 2)) + << strerror(errno); + EXPECT_EQ(0, memcmp(ones, readbuf, bs / 2)); + ASSERT_EQ(bs / 2, pread(fd, readbuf, bs / 2, 2 * bs)) + << strerror(errno); + EXPECT_EQ(0, memcmp(ones, readbuf, bs / 2)); + + leak(fd); + free(zeroones); + free(onezeros); + free(ones); + free(zeros); + free(readbuf); +} + /* * In WriteBack mode, writes may be cached beyond what the server thinks is the * EOF. In this case, a short read at EOF should _not_ cause fusefs to update From 06e1ffbca6e5e0f05df502f0dd41462003cee69b Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Sun, 28 Jul 2019 15:20:47 +0000 Subject: [PATCH 3/9] [skip ci] Add me to MAINTAINERS for fusefs Sponsored by: The FreeBSD Foundation --- MAINTAINERS | 1 + 1 file changed, 1 insertion(+) diff --git a/MAINTAINERS b/MAINTAINERS index 0e2c284e6a8c..2018e4acfb5a 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -53,6 +53,7 @@ contrib/pjdfstest asomers,ngie,pjd,#test Pre-commit review requested. etc/mail gshapiro Pre-commit review requested. Keep in sync with -STABLE. etc/sendmail gshapiro Pre-commit review requested. Keep in sync with -STABLE. fetch des Pre-commit review requested, email only. +fusefs(5) asomers Pre-commit review requested. geli pjd Pre-commit review requested (both sys/geom/eli/ and sbin/geom/class/eli/). isci(4) jimharris Pre-commit review requested. iwm(4) adrian Pre-commit review requested, send to freebsd-wireless@freebsd.org From f0c07f0ce8876adf27691b460887a3d15195839d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 30 Jul 2019 17:31:09 +0000 Subject: [PATCH 4/9] fusefs: nul-terminate some strings in the readdir test Reported by: GCC 8 Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/readdir.cc | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tests/sys/fs/fusefs/readdir.cc b/tests/sys/fs/fusefs/readdir.cc index db207790ed78..24373bebf1bb 100644 --- a/tests/sys/fs/fusefs/readdir.cc +++ b/tests/sys/fs/fusefs/readdir.cc @@ -70,19 +70,19 @@ TEST_F(Readdir, dots) struct dirent *de; vector ents(2); vector empty_ents(0); - const char *dot = "."; - const char *dotdot = ".."; + const char dot[] = "."; + const char dotdot[] = ".."; expect_lookup(RELPATH, ino); expect_opendir(ino); ents[0].d_fileno = 2; ents[0].d_off = 2000; - ents[0].d_namlen = strlen(dotdot); + ents[0].d_namlen = sizeof(dotdot); ents[0].d_type = DT_DIR; strncpy(ents[0].d_name, dotdot, ents[0].d_namlen); ents[1].d_fileno = 3; ents[1].d_off = 3000; - ents[1].d_namlen = strlen(dot); + ents[1].d_namlen = sizeof(dot); ents[1].d_type = DT_DIR; strncpy(ents[1].d_name, dot, ents[1].d_namlen); expect_readdir(ino, 0, ents); @@ -102,8 +102,8 @@ TEST_F(Readdir, dots) */ //EXPECT_EQ(2000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); - EXPECT_EQ(2, de->d_namlen); - EXPECT_EQ(0, strcmp("..", de->d_name)); + EXPECT_EQ(sizeof(dotdot), de->d_namlen); + EXPECT_EQ(0, strcmp(dotdot, de->d_name)); errno = 0; de = readdir(dir); @@ -111,8 +111,8 @@ TEST_F(Readdir, dots) EXPECT_EQ(3ul, de->d_fileno); //EXPECT_EQ(3000, de->d_off); EXPECT_EQ(DT_DIR, de->d_type); - EXPECT_EQ(1, de->d_namlen); - EXPECT_EQ(0, strcmp(".", de->d_name)); + EXPECT_EQ(sizeof(dot), de->d_namlen); + EXPECT_EQ(0, strcmp(dot, de->d_name)); ASSERT_EQ(nullptr, readdir(dir)); ASSERT_EQ(0, errno); From 9f13765e42bf1797ecd4918fde6c2b8ef26cd976 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 30 Jul 2019 19:47:45 +0000 Subject: [PATCH 5/9] fusefs: fix building tests with GCC 8 GCC 8 objected to including C++-only flags in CWARNFLAGS Sponsored by: The FreeBSD Foundation --- tests/sys/fs/fusefs/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sys/fs/fusefs/Makefile b/tests/sys/fs/fusefs/Makefile index 59f9dfa5aa7d..957608dde747 100644 --- a/tests/sys/fs/fusefs/Makefile +++ b/tests/sys/fs/fusefs/Makefile @@ -65,7 +65,7 @@ TEST_METADATA+= timeout=10 FUSEFS= ${SRCTOP}/sys/fs/fuse MOUNT= ${SRCTOP}/sbin/mount # Suppress warnings that GCC generates for the libc++ and gtest headers. -CWARNFLAGS.gcc+= -Wno-placement-new -Wno-attributes -Wno-class-memaccess +CXXWARNFLAGS.gcc+= -Wno-placement-new -Wno-attributes -Wno-class-memaccess CXXFLAGS+= -I${SRCTOP}/tests CXXFLAGS+= -I${FUSEFS} CXXFLAGS+= -I${MOUNT} From f093e49ae22825a15a11692a64a35174c74b643d Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 30 Jul 2019 19:55:55 +0000 Subject: [PATCH 6/9] Bump __FreeBSD_version r350437 presents a merge conflict with r350115, which raised __FreeBSD_version due to the addition of fusefs's intr/nointr mount options. Sponsored by: The FreeBSD Foundation --- sys/sys/param.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sys/sys/param.h b/sys/sys/param.h index 0c31c5a478ef..567857956a8a 100644 --- a/sys/sys/param.h +++ b/sys/sys/param.h @@ -60,7 +60,7 @@ * in the range 5 to 9. */ #undef __FreeBSD_version -#define __FreeBSD_version 1300038 /* Master, propagated to newvers */ +#define __FreeBSD_version 1300039 /* Master, propagated to newvers */ /* * __FreeBSD_kernel__ indicates that this system uses the kernel of FreeBSD, From db90284c3187f638dacb430683c3531b76d09cfc Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 31 Jul 2019 16:07:16 +0000 Subject: [PATCH 7/9] fusefs: proofread man pages Reported by: bcr, mandoc, textproc/igor Sponsored by: The FreeBSD Foundation --- sbin/mount_fusefs/mount_fusefs.8 | 58 ++++++++++++++++---------------- share/man/man5/fusefs.5 | 9 ++--- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/sbin/mount_fusefs/mount_fusefs.8 b/sbin/mount_fusefs/mount_fusefs.8 index a85ab11e7211..da3af56c1632 100644 --- a/sbin/mount_fusefs/mount_fusefs.8 +++ b/sbin/mount_fusefs/mount_fusefs.8 @@ -34,7 +34,7 @@ .\" .\" $FreeBSD$ .\" -.Dd July 18, 2019 +.Dd July 31, 2019 .Dt MOUNT_FUSEFS 8 .Os .Sh NAME @@ -113,27 +113,27 @@ Intended for use in scripts and the .Xr sudoers 5 file. .It Fl S , Ic --safe -Run in safe mode (i.e. reject invoking a filesystem daemon) +Run in safe mode (i.e., reject invoking a filesystem daemon). .It Fl v -Be verbose -.It Fl D, Ic --daemon Ar daemon +Be verbose. +.It Fl D , Ic --daemon Ar daemon Call the specified -.Ar daemon -.It Fl O, Ic --daemon_opts Ar opts +.Ar daemon . +.It Fl O , Ic --daemon_opts Ar opts Add .Ar opts -to the daemon's command line -.It Fl s, Ic --special Ar special +to the daemon's command line. +.It Fl s , Ic --special Ar special Use .Ar special -as special -.It Fl m, Ic --mountpath Ar node +as special. +.It Fl m , Ic --mountpath Ar node Mount on -.Ar node -.It Fl h, Ic --help -Show help -.It Fl V, Ic --version -Show version information +.Ar node . +.It Fl h , Ic --help +Show help. +.It Fl V , Ic --version +Show version information. .It Fl o Mount options are specified via .Fl o . @@ -144,12 +144,12 @@ by prefixing them with .It Cm allow_other Do not apply .Sx STRICT ACCESS POLICY . -Only root can use this option +Only root can use this option. .It Cm async I/O to the file system may be done asynchronously. -Writes may delayed and/or reordered. +Writes may be delayed and/or reordered. .It Cm default_permissions -Enable traditional (file mode based) permission checking in kernel +Enable traditional (file mode based) permission checking in kernel. .It Cm intr Allow signals to interrupt operations that are blocked waiting for a reply from the server. When this option is in use, system calls may fail with @@ -157,15 +157,15 @@ When this option is in use, system calls may fail with whenever a signal is received. .It Cm max_read Ns = Ns Ar n Limit size of read requests to -.Ar n +.Ar n . .It Cm neglect_shares -Do not refuse unmounting if there are secondary mounts +Do not refuse unmounting if there are secondary mounts. .It Cm private Refuse shared mounting of the daemon. This is the default behaviour, to allow sharing, expicitly use -.Fl o Cm noprivate +.Fl o Cm noprivate . .It Cm push_symlinks_in -Prefix absolute symlinks with the mountpoint +Prefix absolute symlinks with the mountpoint. .It Cm subtype Ns = Ns Ar fsname Suffix .Ar fsname @@ -187,11 +187,11 @@ However, there are some which do require in-kernel support. Currently the options supported by the kernel are: .Bl -tag -width indent .It Cm direct_io -Bypass the buffer cache system +Bypass the buffer cache system. .It Cm kernel_cache By default cached buffers of a given file are flushed at each .Xr open 2 . -This option disables this behaviour +This option disables this behaviour. .El .Sh DAEMON MOUNTS Usually users do not need to use @@ -214,7 +214,7 @@ only if the filesystem daemon has the same credentials (uid, real uid, gid, real gid) as the user. .Pp This is applied for Fuse mounts by default and only root can mount without -the strict access policy (i.e. the +the strict access policy (i.e., the .Cm allow_other mount option). .Pp @@ -226,7 +226,7 @@ Users might opt to willingly relax strict access policy (as far they are concerned) by doing their own secondary mount (See .Sx SHARED MOUNTS ) . .Sh SHARED MOUNTS -A Fuse daemon can be shared (i.e. mounted multiple times). +A Fuse daemon can be shared (i.e., mounted multiple times). When doing the first (primary) mount, the spawner and the mounter of the daemon must have the same uid, or the mounter should be the superuser. .Pp @@ -245,7 +245,7 @@ is used or not. .Pp The device name of a secondary mount is the device name of the corresponding primary mount, followed by a '#' character and the index of the secondary -mount; e.g. +mount; e.g., .Pa /dev/fuse0#3 . .Sh SECURITY System administrators might want to use a custom mount policy (ie., one going @@ -259,7 +259,7 @@ However, given that is capable of invoking an arbitrary program, one must be careful when doing this. .Nm is designed in a way such that it makes that easy. -For this purpose, there are options which disable certain risky features (i.e. +For this purpose, there are options which disable certain risky features ( .Fl S and .Fl A ) , @@ -362,7 +362,7 @@ does not call any external utility and also provides a hacky was written as the part of the .Fx implementation of the Fuse userspace filesystem framework (see -.Xr https://github.com/libfuse/libfuse ) +.Lk https://github.com/libfuse/libfuse ) and first appeared in the .Pa sysutils/fusefs-kmod port, supporting diff --git a/share/man/man5/fusefs.5 b/share/man/man5/fusefs.5 index 16d4c5248bc7..24858b2ac4e7 100644 --- a/share/man/man5/fusefs.5 +++ b/share/man/man5/fusefs.5 @@ -28,7 +28,7 @@ .\" SUCH DAMAGE. .\" .\" $FreeBSD$ -.Dd June 27, 2019 +.Dd July 31, 2019 .Dt FUSEFS 5 .Os .Sh NAME @@ -60,7 +60,7 @@ Finally, the API is portable. Many daemons can run on multiple operating systems with minimal modifications. .Sh SYSCTL VARIABLES -The following +The following .Xr sysctl 8 variables are available: .Bl -tag -width indent @@ -95,12 +95,13 @@ Total number of lookup cache misses. Current number of allocated FUSE vnodes. .It Va vfs.fusefs.stats.ticket_count Current number of allocated FUSE tickets, which is roughly equal to the number -number of FUSE operations currently being processed by daemons. +of FUSE operations currently being processed by daemons. .\" Undocumented sysctls .\" ==================== .\" vfs.fusefs.enforce_dev_perms: I don't understand it well enough. .\" vfs.fusefs.iov_credit: I don't understand it well enough .\" vfs.fusefs.iov_permanent_bufsize: I don't understand it well enough +.El .Sh SEE ALSO .Xr mount_fusefs 8 .Sh HISTORY @@ -109,7 +110,7 @@ The driver was written as the part of the .Fx implementation of the FUSE userspace file system framework (see -.Xr https://github.com/libfuse/libfuse ) +.Lk https://github.com/libfuse/libfuse ) and first appeared in the .Pa sysutils/fusefs-kmod port, supporting From 508abc9494974c0a8a1f4ed40dc8312f17377ad3 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Wed, 31 Jul 2019 21:48:35 +0000 Subject: [PATCH 8/9] fusefs: fix the build after r350446 fuse needs to include an additional header after r350446 Sponsored by: The FreeBSD Foundation --- sys/fs/fuse/fuse_internal.h | 1 + 1 file changed, 1 insertion(+) diff --git a/sys/fs/fuse/fuse_internal.h b/sys/fs/fuse/fuse_internal.h index 88eff7b3224c..85581f3c29c5 100644 --- a/sys/fs/fuse/fuse_internal.h +++ b/sys/fs/fuse/fuse_internal.h @@ -67,6 +67,7 @@ #include #include +#include #include #include #include From 427d205cb5924ed4e06f458dfac1af969034a786 Mon Sep 17 00:00:00 2001 From: Alan Somers Date: Tue, 6 Aug 2019 00:50:25 +0000 Subject: [PATCH 9/9] fusefs: remove superfluous counter_u64_zero Reported by: glebius Sponsored by: The FreeBSD Foundation --- sys/fs/fuse/fuse_file.c | 1 - sys/fs/fuse/fuse_internal.c | 2 -- sys/fs/fuse/fuse_ipc.c | 1 - sys/fs/fuse/fuse_node.c | 1 - 4 files changed, 5 deletions(-) diff --git a/sys/fs/fuse/fuse_file.c b/sys/fs/fuse/fuse_file.c index 050de95ec3c1..f9b0c781f49a 100644 --- a/sys/fs/fuse/fuse_file.c +++ b/sys/fs/fuse/fuse_file.c @@ -367,7 +367,6 @@ void fuse_file_init(void) { fuse_fh_count = counter_u64_alloc(M_WAITOK); - counter_u64_zero(fuse_fh_count); } void diff --git a/sys/fs/fuse/fuse_internal.c b/sys/fs/fuse/fuse_internal.c index 39500ea8e37f..5301e4cf9cf5 100644 --- a/sys/fs/fuse/fuse_internal.c +++ b/sys/fs/fuse/fuse_internal.c @@ -1205,9 +1205,7 @@ void fuse_internal_init(void) { fuse_lookup_cache_misses = counter_u64_alloc(M_WAITOK); - counter_u64_zero(fuse_lookup_cache_misses); fuse_lookup_cache_hits = counter_u64_alloc(M_WAITOK); - counter_u64_zero(fuse_lookup_cache_hits); } void diff --git a/sys/fs/fuse/fuse_ipc.c b/sys/fs/fuse/fuse_ipc.c index a7e89337bd0c..514f7857faf5 100644 --- a/sys/fs/fuse/fuse_ipc.c +++ b/sys/fs/fuse/fuse_ipc.c @@ -1087,7 +1087,6 @@ fuse_ipc_init(void) fticket_ctor, fticket_dtor, fticket_init, fticket_fini, UMA_ALIGN_PTR, 0); fuse_ticket_count = counter_u64_alloc(M_WAITOK); - counter_u64_zero(fuse_ticket_count); } void diff --git a/sys/fs/fuse/fuse_node.c b/sys/fs/fuse/fuse_node.c index 3be9828faf4d..2cfe5881d233 100644 --- a/sys/fs/fuse/fuse_node.c +++ b/sys/fs/fuse/fuse_node.c @@ -491,7 +491,6 @@ void fuse_node_init(void) { fuse_node_count = counter_u64_alloc(M_WAITOK); - counter_u64_zero(fuse_node_count); } void