]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
vmbackup: couple of fixes to Linux freeze ioctl support.
authorVMware, Inc <>
Thu, 27 Oct 2011 18:40:36 +0000 (11:40 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 27 Oct 2011 18:40:36 +0000 (11:40 -0700)
. The sync driver code may get EIO and EACCES when trying to freeze
filesystems. The first happens on our HGFS mount, if HGFS is not
enabled on the host. The second, if a user has some filesystem
mounted with "700" permissions, so our code can't access it.
Just ignore those cases and keep going, freezing what we can.

. The error handler wasn't properly unfreezing frozen filesystems,
resulting in potentially unusable VMs if something went wrong.

Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/syncDriver/syncDriverLinux.c

index 7cfa24a9be394ab561d51414e4cf3dec7db315d4..7dfae425eb0cf2a49a8a933e30c9a2a0c12c7bc0 100644 (file)
@@ -155,11 +155,34 @@ LinuxDriver_Freeze(const char *paths,
     */
    while ((path = StrUtil_GetNextToken(&index, paths, ":")) != NULL) {
       fd = open(path, O_RDONLY);
-      free(path);
-
       if (fd == -1) {
-         err = SD_ERROR;
-         break;
+         switch (errno) {
+         case EACCES:
+            /*
+             * We sometimes get access errors to virtual filesystems mounted
+             * as users with permission 700, so just ignore these.
+             */
+            Debug(LGPFX "cannot access mounted directory '%s'.\n", path);
+            free(path);
+            continue;
+
+         case EIO:
+            /*
+             * A mounted HGFS filesystem with the backend disabled will give
+             * us these; probably could use a better way to detect HFGS, but
+             * this should be enough. Just skip.
+             */
+            Debug(LGPFX "I/O error reading directory '%s'.\n", path);
+            free(path);
+            continue;
+
+         default:
+            Debug(LGPFX "failed to open '%s': %d (%s)\n",
+                  path, errno, strerror(errno));
+            err = SD_ERROR;
+            free(path);
+            goto exit;
+         }
       }
 
       if (ioctl(fd, FIFREEZE) == -1) {
@@ -187,13 +210,14 @@ LinuxDriver_Freeze(const char *paths,
       first = FALSE;
    }
 
+exit:
+   sync->fds = DynBuf_Detach(&fds);
+   sync->fdCnt = count;
+
    if (err != SD_SUCCESS) {
       LinuxFiThaw(&sync->driver);
       LinuxFiClose(&sync->driver);
-      DynBuf_Destroy(&fds);
    } else {
-      sync->fds = DynBuf_Detach(&fds);
-      sync->fdCnt = count;
       *handle = &sync->driver;
    }
    return err;