From: Oliver Kurth Date: Fri, 2 Nov 2018 22:28:18 +0000 (-0700) Subject: Hgfs FUSE Client: fix attribute caching of folders X-Git-Tag: stable-11.0.0~346 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=68f58daeceebe0d879fcbeca1d21e845bd1289e8;p=thirdparty%2Fopen-vm-tools.git Hgfs FUSE Client: fix attribute caching of folders When a directory is invalidated from the cache due to any change such as a rename then any cached children of that parent folder should be invalidated also. Otherwise the cache holds stale information leading to incorrect behavior and failing applications. --- diff --git a/open-vm-tools/vmhgfs-fuse/cache.c b/open-vm-tools/vmhgfs-fuse/cache.c index 5e3259f6e..db89bedc6 100644 --- a/open-vm-tools/vmhgfs-fuse/cache.c +++ b/open-vm-tools/vmhgfs-fuse/cache.c @@ -55,6 +55,7 @@ struct HgfsAttrCache attrList; /*Lock for accessing the attribute cache*/ static pthread_mutex_t HgfsAttrCacheLock = PTHREAD_MUTEX_INITIALIZER; +static void HgfsInvalidateParentsChildren(const char* parent); /* * Lists are used to manage attribute cache in Solaris and FreeBSD, @@ -414,10 +415,55 @@ HgfsInvalidateAttrCache(const char* path) //IN: Path to file tmp = (HgfsAttrCache *)g_hash_table_lookup(g_hash_table, path); if (tmp != NULL) { tmp->changeTime = 0; + if (tmp->attr.type == HGFS_FILE_TYPE_DIRECTORY) { + HgfsInvalidateParentsChildren(tmp->path); + } } pthread_mutex_unlock(&HgfsAttrCacheLock); } + +/* + *---------------------------------------------------------------------- + * + * HgfsInvalidateParentsChildren + * + * This routine is called by the general function to invalidate a cache + * entry. If the entry is a directory this function is called to invalidate + * any cached children. + * + * Results: + * None + * + * Side effects: + * None + * + *---------------------------------------------------------------------- + */ + +static void +HgfsInvalidateParentsChildren(const char* parent) //IN: parent +{ + gpointer key, value; + GHashTableIter iter; + size_t parentLen = Str_Strlen(parent, PATH_MAX); + + LOG(4, ("Invalidating cache children for parent = %s\n", + parent)); + + g_hash_table_iter_init(&iter, g_hash_table); + + while (g_hash_table_iter_next(&iter, &key, &value)) { + HgfsAttrCache *child = (HgfsAttrCache *)value; + + if (Str_Strncasecmp(parent, child->path, parentLen) == 0) { + LOG(10, ("Invalidating cache child = %s\n", child->path)); + child->changeTime = 0; + } + } +} + + /* *---------------------------------------------------------------------- * diff --git a/open-vm-tools/vmhgfs-fuse/file.c b/open-vm-tools/vmhgfs-fuse/file.c index 389ebba88..b0744ff76 100644 --- a/open-vm-tools/vmhgfs-fuse/file.c +++ b/open-vm-tools/vmhgfs-fuse/file.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013,2017 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -1068,7 +1068,7 @@ retry: } break; default: - LOG(4, ("failed with result %d\n", result)); + LOG(4, ("Server protocol result %d\n", result)); } break; default: diff --git a/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h b/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h index 4a3dd6972..bb3d38bdf 100644 --- a/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h +++ b/open-vm-tools/vmhgfs-fuse/vmhgfs_version.h @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2013,2017 VMware, Inc. All rights reserved. + * Copyright (C) 2013,2018 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -25,8 +25,8 @@ #ifndef _VMHGFS_VERSION_H_ #define _VMHGFS_VERSION_H_ -#define VMHGFS_DRIVER_VERSION 1.6.6.0 -#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,6,0 -#define VMHGFS_DRIVER_VERSION_STRING "1.6.6.0" +#define VMHGFS_DRIVER_VERSION 1.6.7.0 +#define VMHGFS_DRIVER_VERSION_COMMAS 1,6,7,0 +#define VMHGFS_DRIVER_VERSION_STRING "1.6.7.0" #endif /* _VMHGFS_VERSION_H_ */