main: improve UTIME_NOW special-casing

FUSE never passes FUSE_SET_ATTR_ATIME_NOW without also passing
FUSE_SET_ATTR_ATIME. Since FUSE_SET_ATTR_ATIME_NOW was only checked if
FUSE_SET_ATTR_ATIME was not set, it would never be triggered.

Note that this is an *improvement*, not a *fix*, because FUSE always
passes the current time in st_atim whenever it sets
FUSE_SET_ATTR_ATIME_NOW. As a result, the previous code works properly,
but it does so differently from the way it was intended to.

(All of the above descriptions of st_atim handling also applies to
st_mtim.)
This commit is contained in:
cptpcrd 2021-04-13 20:58:48 -04:00
parent d23dbe914d
commit defd480c0e

16
main.c
View File

@ -3950,14 +3950,18 @@ ovl_setattr (fuse_req_t req, fuse_ino_t ino, struct stat *attr, int to_set, stru
times[0].tv_nsec = UTIME_OMIT;
times[1].tv_nsec = UTIME_OMIT;
if (to_set & FUSE_SET_ATTR_ATIME)
times[0] = attr->st_atim;
else if (to_set & FUSE_SET_ATTR_ATIME_NOW)
times[0].tv_nsec = UTIME_NOW;
{
times[0] = attr->st_atim;
if (to_set & FUSE_SET_ATTR_ATIME_NOW)
times[0].tv_nsec = UTIME_NOW;
}
if (to_set & FUSE_SET_ATTR_MTIME)
times[1] = attr->st_mtim;
else if (to_set & FUSE_SET_ATTR_MTIME_NOW)
times[1].tv_nsec = UTIME_NOW;
{
times[1] = attr->st_mtim;
if (to_set & FUSE_SET_ATTR_MTIME_NOW)
times[1].tv_nsec = UTIME_NOW;
}
if (times[0].tv_nsec != UTIME_OMIT || times[1].tv_nsec != UTIME_OMIT)
{