aboutsummaryrefslogtreecommitdiff
path: root/tests/sys/fs/fusefs/setattr.cc
Commit message (Collapse)AuthorAgeFilesLines
* fusefs: prefer new/delete over malloc/freeAlan Somers2024-01-171-14/+9
| | | | | | MFC after: 2 weeks Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D43464
* Remove $FreeBSD$: two-line .h patternWarner Losh2023-08-161-2/+0
| | | | Remove /^\s*\*\n \*\s+\$FreeBSD\$$\n/
* spdx: The BSD-2-Clause-FreeBSD identifier is obsolete, drop -FreeBSDWarner Losh2023-05-121-1/+1
| | | | | | | | | The SPDX folks have obsoleted the BSD-2-Clause-FreeBSD identifier. Catch up to that fact and revert to their recommended match of BSD-2-Clause. Discussed with: pfg MFC After: 3 days Sponsored by: Netflix
* fusefs: fix a buffer overflow in the testsAlan Somers2023-02-221-0/+1
| | | | | | | | | | The actual overflow occured in the ReadAhead.readahead test. Surprisingly it has never segfaulted or resulted in any bad behavior. MFC after: 1 week Sponsored by: Axcient Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D38718
* fusefs: respect RLIMIT_FSIZE during truncateAlan Somers2022-09-251-1/+43
| | | | | | | PR: 164793 MFC after: 2 weeks Reviewed by: kib Differential Revision: https://reviews.freebsd.org/D36703
* Explicitly include semaphore.h for struct _sem in fusefs setattr testDimitry Andric2022-02-061-0/+1
| | | | | | | | | | | | | | | In libc++'s __threading_support header the semaphore.h header was implicitly included, but from version 14 onwards, this is no longer the case, resulting in compile errors: tests/sys/fs/fusefs/setattr.cc:740:8: error: variable has incomplete type 'sem_t' (aka '_sem') sem_t sem; ^ tests/sys/fs/fusefs/utils.hh:33:8: note: forward declaration of '_sem' struct _sem; ^ MFC after: 3 days
* fusefs: correctly handle an inode that changes file typesAlan Somers2021-12-071-0/+47
| | | | | | | | | | | | | | | | | | | | | | | Correctly handle the situation where a FUSE server unlinks a file, then creates a new file of a different type but with the same inode number. Previously fuse_vnop_lookup in this situation would return EAGAIN. But since it didn't call vgone(), the vnode couldn't be reused right away. Fix this by immediately calling vgone() and reallocating a new vnode. This problem can occur in three code paths, during VOP_LOOKUP, VOP_SETATTR, or following FUSE_GETATTR, which usually happens during VOP_GETATTR but can occur during other vops, too. Note that the correct response actually doesn't depend on whether the entry cache has expired. In fact, during VOP_LOOKUP, we can't even tell. Either it has expired already, or else the vnode got reclaimed by vnlru. Also, correct the error code during the VOP_SETATTR path. PR: 258022 Reported by: chogata@moosefs.pro MFC after: 2 weeks Reviewed by: pfg Differential Revision: https://reviews.freebsd.org/D33283
* tests: fusefs: silence remaining unsigned/signed comparison warningsKyle Evans2020-01-101-3/+3
| | | | | | | | | | External GCC turns these into errors; cast to long to silence them. Reviewed by: asomers Differential Revision: https://reviews.freebsd.org/D23127 Notes: svn path=/head/; revision=356614
* fusefs: coverity cleanup in the testsAlan Somers2019-09-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Address the following defects reported by Coverity: * Structurally dead code (CID 1404366): set m_quit before FAIL, not after * Unchecked return value of sysctlbyname (CID 1404321) * Unchecked return value of stat(2) (CID 1404471) * Unchecked return value of open(2) (CID 1404402, 1404529) * Unchecked return value of dup(2) (CID 1404478) * Buffer overflows. These are all false positives caused by the fact that Coverity thinks I'm using a buffer to store strings, when in fact I'm really just using it to store a byte array that happens to be initialized with a string. I'm changing the type from char to uint8_t in the hopes that it will placate Coverity. (CID 1404338, 1404350, 1404367, 1404376, 1404379, 1404381, 1404388, 1404403, 1404425, 1404433, 1404434, 1404474, 1404480, 1404484, 1404503, 1404505) * False positive file descriptor leak. I'm going to try to fix this with Coverity modeling, but I'll also change an EXPECT to ASSERT so we don't perform meaningless assertions after the failure. (CID 1404320, 1404324, 1404440, 1404445). * Unannotated file descriptor leak. This will be followed up by a Coverity modeling change. (CID 1404326, 1404334, 1404336, 1404357, 1404361, 1404372, 1404391, 1404395, 1404409, 1404430, 1404448, 1404451, 1404455, 1404457, 1404458, 1404460) * Uninitialized variables in C++ constructors (CID 1404327, 1404346). In the case of m_maxphys, this actually led to part of the FUSE_INIT's response being set to stack garbage during the WriteCluster::clustering test. * Uninitialized sun_len field in struct sockaddr_un (CID 1404330, 1404371, 1404429). Reported by: Coverity Reviewed by: emaste MFC after: 3 days Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D21457 Notes: svn path=/head/; revision=351963
* fusefs: add SVN Keywords to the test filesAlan Somers2019-08-131-0/+2
| | | | | | | | | | Reported by: SVN pre-commit hooks MFC after: 15 days MFC-With: r350665 Sponsored by: The FreeBSD Foundation Notes: svn path=/head/; revision=350990
* fusefs: fix warnings in the tests reported by GCCAlan Somers2019-07-201-7/+10
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=350163
* fusefs: annotate deliberate file descriptor leaks in the testsAlan Somers2019-06-261-2/+2
| | | | | | | | | | | | | | closing a file descriptor causes FUSE activity that is superfluous to the purpose of most tests, but would nonetheless require matching expectations. Rather than do that, most tests deliberately leak file descriptors instead. This commit moves the leakage from each test into two trivial functions: leak and leakdir. Hopefully Coverity will only complain about those functions and not all of their callers. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=349440
* fusefs: implement protocol 7.23's FUSE_WRITEBACK_CACHE optionAlan Somers2019-06-261-9/+2
| | | | | | | | | | | | | | | | | | | | | | As of protocol 7.23, fuse file systems can specify their cache behavior on a per-mountpoint basis. If they set FUSE_WRITEBACK_CACHE in fuse_init_out.flags, then they'll get the writeback cache. If not, then they'll get the writethrough cache. If they set FOPEN_DIRECT_IO in every FUSE_OPEN response, then they'll get no cache at all. The old vfs.fusefs.data_cache_mode sysctl is ignored for servers that use protocol 7.23 or later. However, it's retained for older servers, especially for those running in jails that lack access to the new protocol. This commit also fixes two other minor test bugs: * WriteCluster:SetUp was using an uninitialized variable. * Read.direct_io_pread wasn't verifying that the cache was actually bypassed. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=349431
* fusefs: delete obsolete comments in the testsAlan Somers2019-06-261-9/+0
| | | | | | | | | | | | I originally thought that the kernel would be responsible for ctime in protocol 7.23. But now I realize that's not the case. The server is responsible for ctime. The kernel only sets it when there are dirty writes cached, because that's when the server can't. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=349398
* fusefs: prefer FUSE_ROOT_ID to literal 1 in the testsAlan Somers2019-05-311-14/+14
| | | | | | | Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348469
* fusefs: make the tests more cplusplusyAlan Somers2019-05-271-214/+218
| | | | | | | | | | | | * Prefer std::unique_ptr to raw pointers * Prefer pass-by-reference to pass-by-pointer * Prefer static_cast to C-style cast, unless it's too much typing Reported by: ngie Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348307
* fusefs: more build fixesAlan Somers2019-05-261-3/+3
| | | | | | | | | | | | | | * Fix printf format strings on 32-bit OSes * Fix -Wclass-memaccess violation on GCC-8 caused by using memset on an object of non-trivial type. * Fix memory leak in MockFS::init * Fix -Wcast-align error on i386 in expect_readdir * Fix some heterogenous comparison errors on 32-bit OSes. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=348285
* fusefs: forward UTIME_NOW to the serverAlan Somers2019-05-161-4/+7
| | | | | | | | | | | | | If a user sets both atime and mtime to UTIME_NOW when calling a syscall like utimensat(2), allow the server to choose what "now" means. Due to the design of FreeBSD's VFS, it's not possible to do this for just one of atime or mtime; it's all or none. PR: 237181 Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=347898
* fusefs: Upgrade FUSE protocol to version 7.9.Alan Somers2019-05-161-0/+42
| | | | | | | | | | | This commit upgrades the FUSE API to protocol 7.9 and adds unit tests for backwards compatibility with servers built for version 7.8. It doesn't implement any of 7.9's new features yet. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=347814
* fusefs: updated cached attributes during VOP_LINK.Alan Somers2019-05-081-0/+64
| | | | | | | | | | | | | FUSE_LINK returns a new set of attributes. fusefs should cache them just like it does during other VOPs. This is not only a matter of performance but of correctness too; without caching the new attributes the vnode's nlink value would be out-of-date. Reported by: pjdfstest Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=347358
* Fix bug in vtruncbuf introduced by r346162Alan Somers2019-04-231-16/+44
| | | | | | | | | | | | | | | r346162 factored out v_inval_buf_range from vtruncbuf, but it made an error in the interface between the two. The result was a failure to remove buffers past the first. Surprisingly, I couldn't reproduce the failure with file systems other than fuse. Also, modify fusefs's truncate_discards_cached_data test to catch this bug. PR: 346162 Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=346606
* fusefs: add a test for setattr with UTIME_NOWAlan Somers2019-04-111-0/+64
| | | | | | | | | | The test is disabled ATM; it requires protocol version 7.9. PR: 237181 Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=346140
* fusefs: various cleanupsAlan Somers2019-04-101-2/+27
| | | | | | | | | | | | | | | | * Eliminate fuse_access_param. Whatever it was supposed to do, it seems like it was never complete. The only real function it ever seems to have had was a minor performance optimization, which I've already eliminated. * Make extended attribute operations obey the allow_other mount option. * Allow unprivileged access to the SYSTEM extattr namespace when -o default_permissions is not in use. * Disallow setextattr and deleteextattr on read-only mounts. * Add tests for a few more error cases. Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=346101
* fusefs: WIP supporting -o default_permissionsAlan Somers2019-04-101-0/+2
| | | | | | | | | | | | | | | | | | | Normally all permission checking is done in the fuse server. But when -o default_permissions is used, it should be done in the kernel instead. This commit adds appropriate permission checks through fusefs when -o default_permissions is used. However, sticky bit checks aren't working yet. I'll handle those in a follow-up commit. There are no checks for file flags, because those aren't supported by our version of the FUSE protocol. Nor is there any support for ACLs, though that could be added if there were any demand. PR: 216391 Reported by: hiyorin@gmail.com Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=346088
* fusefs: cache file attributesAlan Somers2019-04-081-70/+3
| | | | | | | | | | | | | | | | | FUSE_LOOKUP, FUSE_GETATTR, FUSE_SETATTR, FUSE_MKDIR, FUSE_LINK, FUSE_SYMLINK, FUSE_MKNOD, and FUSE_CREATE all return file attributes with a cache validity period. fusefs will now cache the attributes, if the server returns a non-zero cache validity period. This change does _not_ implement finite attr cache timeouts. That will follow as part of PR 235773. PR: 235775 Reported by: cem Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=346043
* fusefs: during ftruncate, discard cached data past truncation pointAlan Somers2019-04-031-0/+110
| | | | | | | | | | | | | During truncate, fusefs was discarding entire cached blocks, but it wasn't zeroing out the unused portion of a final partial block. This resulted in reads returning stale data. PR: 233783 Reported by: fsx Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=345823
* fusefs: adapt the tests to the fuse => fusefs renameAlan Somers2019-03-211-0/+512
Sponsored by: The FreeBSD Foundation Notes: svn path=/projects/fuse2/; revision=345356