From: VMware, Inc <> Date: Thu, 27 Oct 2011 18:40:36 +0000 (-0700) Subject: vmbackup: couple of fixes to Linux freeze ioctl support. X-Git-Tag: 2011.10.26-514583~23 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=dc92050927cf937dff716ff54f4e857d05939551;p=thirdparty%2Fopen-vm-tools.git vmbackup: couple of fixes to Linux freeze ioctl support. . 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 --- diff --git a/open-vm-tools/lib/syncDriver/syncDriverLinux.c b/open-vm-tools/lib/syncDriver/syncDriverLinux.c index 7cfa24a9b..7dfae425e 100644 --- a/open-vm-tools/lib/syncDriver/syncDriverLinux.c +++ b/open-vm-tools/lib/syncDriver/syncDriverLinux.c @@ -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;