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