From: Oliver Kurth Date: Fri, 15 Sep 2017 18:22:51 +0000 (-0700) Subject: Hgfs Linux Client: fix editor prompts for file changes X-Git-Tag: stable-10.2.0~649 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=21f3c28eb8313b438eba527d8682facdb38ffbe3;p=thirdparty%2Fopen-vm-tools.git Hgfs Linux Client: fix editor prompts for file changes 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. --- diff --git a/open-vm-tools/modules/linux/vmhgfs/fsutil.c b/open-vm-tools/modules/linux/vmhgfs/fsutil.c index 3b3c039e6..fb439231c 100644 --- a/open-vm-tools/modules/linux/vmhgfs/fsutil.c +++ b/open-vm-tools/modules/linux/vmhgfs/fsutil.c @@ -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) { diff --git a/open-vm-tools/modules/linux/vmhgfs/inode.c b/open-vm-tools/modules/linux/vmhgfs/inode.c index 92b0e8171..c6110e044 100644 --- a/open-vm-tools/modules/linux/vmhgfs/inode.c +++ b/open-vm-tools/modules/linux/vmhgfs/inode.c @@ -31,6 +31,7 @@ #include #endif #include +#include // 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; diff --git a/open-vm-tools/modules/linux/vmhgfs/vmhgfs_version.h b/open-vm-tools/modules/linux/vmhgfs/vmhgfs_version.h index 009f0eea2..0c89528c4 100644 --- a/open-vm-tools/modules/linux/vmhgfs/vmhgfs_version.h +++ b/open-vm-tools/modules/linux/vmhgfs/vmhgfs_version.h @@ -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_ */