svn commit: r347898 - in projects/fuse2: sys/fs/fuse tests/sys/fs/fusefs
Alan Somers
asomers at FreeBSD.org
Thu May 16 23:17:41 UTC 2019
Author: asomers
Date: Thu May 16 23:17:39 2019
New Revision: 347898
URL: https://svnweb.freebsd.org/changeset/base/347898
Log:
fusefs: forward UTIME_NOW to the server
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
Modified:
projects/fuse2/sys/fs/fuse/fuse_internal.c
projects/fuse2/tests/sys/fs/fusefs/setattr.cc
Modified: projects/fuse2/sys/fs/fuse/fuse_internal.c
==============================================================================
--- projects/fuse2/sys/fs/fuse/fuse_internal.c Thu May 16 22:50:04 2019 (r347897)
+++ projects/fuse2/sys/fs/fuse/fuse_internal.c Thu May 16 23:17:39 2019 (r347898)
@@ -834,11 +834,15 @@ int fuse_internal_setattr(struct vnode *vp, struct vat
fsai->atime = vap->va_atime.tv_sec;
fsai->atimensec = vap->va_atime.tv_nsec;
fsai->valid |= FATTR_ATIME;
+ if (vap->va_vaflags & VA_UTIMES_NULL)
+ fsai->valid |= FATTR_ATIME_NOW;
}
if (vap->va_mtime.tv_sec != VNOVAL) {
fsai->mtime = vap->va_mtime.tv_sec;
fsai->mtimensec = vap->va_mtime.tv_nsec;
fsai->valid |= FATTR_MTIME;
+ if (vap->va_vaflags & VA_UTIMES_NULL)
+ fsai->valid |= FATTR_MTIME_NOW;
}
if (vap->va_mode != (mode_t)VNOVAL) {
fsai->mode = vap->va_mode & ALLPERMS;
Modified: projects/fuse2/tests/sys/fs/fusefs/setattr.cc
==============================================================================
--- projects/fuse2/tests/sys/fs/fusefs/setattr.cc Thu May 16 22:50:04 2019 (r347897)
+++ projects/fuse2/tests/sys/fs/fusefs/setattr.cc Thu May 16 23:17:39 2019 (r347898)
@@ -661,9 +661,12 @@ TEST_F(Setattr, utimensat_mtime_only) {
<< strerror(errno);
}
-/* Set a file's mtime and atime to now */
-/* TODO: enable this test after updating protocol to version 7.9 */
-#if 0
+/*
+ * Set a file's mtime and atime to now
+ *
+ * The design of FreeBSD's VFS does not allow fusefs to set just one of atime
+ * or mtime to UTIME_NOW; it's both or neither.
+ */
TEST_F(Setattr, utimensat_utime_now) {
const char FULLPATH[] = "mountpoint/some_file.txt";
const char RELPATH[] = "some_file.txt";
@@ -689,6 +692,7 @@ TEST_F(Setattr, utimensat_utime_now) {
out->body.entry.attr.mode = S_IFREG | 0644;
out->body.entry.nodeid = ino;
out->body.entry.attr_valid = UINT64_MAX;
+ out->body.entry.entry_valid = UINT64_MAX;
out->body.entry.attr.atime = oldtimes[0].tv_sec;
out->body.entry.attr.atimensec = oldtimes[0].tv_nsec;
out->body.entry.attr.mtime = oldtimes[1].tv_sec;
@@ -723,7 +727,6 @@ TEST_F(Setattr, utimensat_utime_now) {
EXPECT_EQ(now[1].tv_sec, sb.st_mtim.tv_sec);
EXPECT_EQ(now[1].tv_nsec, sb.st_mtim.tv_nsec);
}
-#endif
/* On a read-only mount, no attributes may be changed */
TEST_F(RofsSetattr, erofs)
More information about the svn-src-projects
mailing list