]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Hgfs Linux Client: fix editor prompts for file changes
authorOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:51 +0000 (11:22 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 15 Sep 2017 18:22:51 +0000 (11:22 -0700)
 When using some editors such as gedit to modify files on the HGFS
 shares the editor can become confused thinking that the file has
 been modified remotely and therefore needs to refresh the contents.
 This occurs due to the file's modify and change times being updated
 after the last writes from the editor and the modify/change times
 in the inode not being updated immediately.

open-vm-tools/modules/linux/vmhgfs/fsutil.c
open-vm-tools/modules/linux/vmhgfs/inode.c
open-vm-tools/modules/linux/vmhgfs/vmhgfs_version.h

index 3b3c039e6880c93469ebb88daff0dd07e9e858a4..fb439231c3fcba3e0fae9b30538cc574edd193e9 100644 (file)
@@ -1041,6 +1041,9 @@ HgfsChangeFileAttributes(struct inode *inode,          // IN/OUT: Inode
    if (attr->mask & HGFS_ATTR_VALID_WRITE_TIME) {
       HGFS_DECLARE_TIME(newTime);
       HGFS_SET_TIME(newTime, attr->writeTime);
+      LOG(4, (KERN_DEBUG "VMware hgfs: %s: server mod "
+               "time: %ld:%lu, inode mod time: %ld:%lu\n", __func__,
+               HGFS_PRINT_TIME(newTime), HGFS_PRINT_TIME(inode->i_mtime)));
       if (hgfs_timespec_compare(&newTime, &inode->i_mtime) > 0 &&
           iinfo->numWbPages == 0 &&
           isSafeToChange) {
index 92b0e8171951feabd935ae1db42db18a7cf460bf..c6110e044c99b6f08187b45bf982f2c941230baa 100644 (file)
@@ -31,6 +31,7 @@
 #include <linux/namei.h>
 #endif
 #include <linux/highmem.h>
+#include <linux/time.h> // for current_fs_time
 
 #include "compat_cred.h"
 #include "compat_dcache.h"
@@ -1599,6 +1600,28 @@ retry:
               "%d\n", result));
    }
 
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
+   if (result == 0) {
+      /*
+       * We force revalidate to go get the file info as soon as needed.
+       * We only add this fix, borrowed from CIFS, for newer versions
+       * of the kernel which have the current_fs_time function.
+       * For details see bug 1613734 but here is a short summary.
+       * This addresses issues in editors such as gedit which use
+       * rename when saving the updated contents of a file.
+       * If we don't force the revalidation here, then the dentry
+       * will randomly age over some time which will then pick up the
+       * file's new timestamps from the server at that time.
+       * This delay will cause the editor to think the file has been modified
+       * underneath it and prompt the user if they want to reload the file.
+       */
+      HgfsDentryAgeForce(oldDentry);
+      HgfsDentryAgeForce(newDentry);
+      oldDir->i_ctime = oldDir->i_mtime = newDir->i_ctime =
+         newDir->i_mtime = current_fs_time(oldDir->i_sb);
+   }
+#endif // LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 32)
+
 out:
    HgfsFreeRequest(req);
    return result;
index 009f0eea21118c891d3e276a1b84dd457da6b81c..0c89528c4d66ee66fdf9fb2897cec27da7b00d3a 100644 (file)
@@ -25,8 +25,8 @@
 #ifndef _VMHGFS_VERSION_H_
 #define _VMHGFS_VERSION_H_
 
-#define VMHGFS_DRIVER_VERSION          2.0.19.0
-#define VMHGFS_DRIVER_VERSION_COMMAS   2,0,19,0
-#define VMHGFS_DRIVER_VERSION_STRING   "2.0.19.0"
+#define VMHGFS_DRIVER_VERSION          2.0.20.0
+#define VMHGFS_DRIVER_VERSION_COMMAS   2,0,20,0
+#define VMHGFS_DRIVER_VERSION_STRING   "2.0.20.0"
 
 #endif /* _VMHGFS_VERSION_H_ */