--- vmhgfs-fuse/main.c.orig 2016-09-13 17:42:20.000238000 -0700 +++ vmhgfs-fuse/main.c 2016-09-13 17:51:04.001947000 -0700 @@ -495,7 +495,9 @@ } res = HgfsDelete(abspath, HGFS_OP_DELETE_FILE); - HgfsInvalidateAttrCache(abspath); + if (res == 0) { + HgfsInvalidateAttrCache(abspath); + } exit: LOG(4, ("Exit(%d)\n", res)); @@ -533,7 +535,9 @@ } res = HgfsDelete(abspath, HGFS_OP_DELETE_DIR); - HgfsInvalidateAttrCache(abspath); + if (res == 0) { + HgfsInvalidateAttrCache(abspath); + } exit: LOG(4, ("Exit(%d)\n", res)); @@ -621,7 +625,10 @@ } res = HgfsRename(absfrom, absto); - HgfsInvalidateAttrCache(absfrom); + if (res == 0) { + HgfsInvalidateAttrCache(absfrom); + HgfsInvalidateAttrCache(absto); + } exit: LOG(4, ("Exit(%d)\n", res)); @@ -1136,7 +1143,14 @@ } res = HgfsWrite(fi, buf, size, offset); - HgfsInvalidateAttrCache(abspath); + if (res >= 0) { + /* + * Positive result indicates the number of bytes written. + * For zero bytes and no error, we still purge the cache + * this could effect the attributes. + */ + HgfsInvalidateAttrCache(abspath); + } exit: LOG(4, ("Exit(%d)\n", res)); --- vmhgfs-fuse/cache.c.orig 2016-09-13 17:43:28.000010000 -0700 +++ vmhgfs-fuse/cache.c 2016-09-13 17:45:56.000322000 -0700 @@ -25,7 +25,13 @@ #if !defined(__FreeBSD__) && !defined(__SOLARIS__) #include #endif -#define CACHE_TIMEOUT 5 + +/* + * We make the default attribute cache timeout 1 second which is the same + * as the FUSE driver. + * This can be overridden with the mount option attr_timeout=T + */ +#define CACHE_TIMEOUT HGFS_DEFAULT_TTL #define CACHE_PURGE_TIME 10 #define CACHE_PURGE_SLEEP_TIME 30 #define HASH_THRESHOLD_SIZE (2046 * 4) --- vmhgfs-fuse/module.h.orig 2016-09-13 17:49:17.000083000 -0700 +++ vmhgfs-fuse/module.h 2016-09-13 17:49:44.000108000 -0700 @@ -34,7 +34,7 @@ #include "vm_assert.h" #include "cpName.h" #include "cpNameLite.h" -#include "hgfsUtil.h" +#include "hgfsDevLinux.h" #include "request.h" #include "fsutil.h" #include "filesystem.h" --- vmhgfs-fuse/file.c.orig 2016-09-13 17:51:36.003169000 -0700 +++ vmhgfs-fuse/file.c 2016-09-13 17:53:21.000104000 -0700 @@ -859,6 +859,7 @@ const char *buffer = buf; loff_t curOffset = offset; size_t nextCount, remainingCount = count; + ssize_t bytesWritten = 0; ASSERT(NULL != buf); ASSERT(NULL != fi); @@ -875,6 +876,7 @@ result = HgfsDoWrite(fi->fh, buffer, nextCount, curOffset); if (result < 0) { + bytesWritten = result; LOG(4, ("Error: DoWrite -> %d\n", result)); goto out; } @@ -884,9 +886,11 @@ } while ((result > 0) && (remainingCount > 0)); + bytesWritten = count - remainingCount; + out: - LOG(6, ("Exit(0x%"FMTSZ"x)\n", count - remainingCount)); - return (count - remainingCount); + LOG(6, ("Exit(0x%"FMTSZ"x)\n", bytesWritten)); + return bytesWritten; }