Blame SOURCES/open-vm-tools-10.0.5-mount-point-bz1406483.patch

0e2628
--- lib/syncDriver/syncDriverLinux.c.orig	2017-01-30 14:11:08.001633000 -0800
0e2628
+++ lib/syncDriver/syncDriverLinux.c	2017-01-30 14:12:24.000488000 -0800
0e2628
@@ -30,6 +30,8 @@
0e2628
 #include <unistd.h>
0e2628
 #include <linux/fs.h>
0e2628
 #include <sys/ioctl.h>
0e2628
+#include <sys/types.h>
0e2628
+#include <sys/stat.h>
0e2628
 #include "debug.h"
0e2628
 #include "dynbuf.h"
0e2628
 #include "syncDriverInt.h"
0e2628
@@ -170,12 +172,21 @@
0e2628
     */
0e2628
    while (paths != NULL) {
0e2628
       int fd;
0e2628
+      struct stat sbuf;
0e2628
       const char *path = paths->data;
0e2628
       Debug(LGPFX "opening path '%s'.\n", path);
0e2628
       paths = g_slist_next(paths);
0e2628
       fd = open(path, O_RDONLY);
0e2628
       if (fd == -1) {
0e2628
          switch (errno) {
0e2628
+         case ENOENT:
0e2628
+            /*
0e2628
+             * We sometimes get stale mountpoints or special mountpoints
0e2628
+             * created by the docker engine.
0e2628
+             */
0e2628
+            Debug(LGPFX "cannot find the directory '%s'.\n", path);
0e2628
+            continue;
0e2628
+
0e2628
          case EACCES:
0e2628
             /*
0e2628
              * We sometimes get access errors to virtual filesystems mounted
0e2628
@@ -201,6 +212,20 @@
0e2628
          }
0e2628
       }
0e2628
 
0e2628
+      if (fstat(fd, &sbuf) == -1) {
0e2628
+         close(fd);
0e2628
+         Debug(LGPFX "failed to stat '%s': %d (%s)\n",
0e2628
+               path, errno, strerror(errno));
0e2628
+         err = SD_ERROR;
0e2628
+         goto exit;
0e2628
+      }
0e2628
+
0e2628
+      if (!S_ISDIR(sbuf.st_mode)) {
0e2628
+         close(fd);
0e2628
+         Debug(LGPFX "Skipping a non-directory path '%s'.\n", path);
0e2628
+         continue;
0e2628
+      }
0e2628
+
0e2628
       Debug(LGPFX "freezing path '%s' (fd=%d).\n", path, fd);
0e2628
       if (ioctl(fd, FIFREEZE) == -1) {
0e2628
          int ioctlerr = errno;