]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
syncDriver: do not use stale errno on Linux
authorVMware, Inc <>
Thu, 22 Dec 2011 00:19:41 +0000 (16:19 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 22 Dec 2011 00:19:41 +0000 (16:19 -0800)
close() may clobber errno so cache it immediately after calling
ioctl(fd, FIFREEZE) instead of it directly later.

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

index 7dfae425eb0cf2a49a8a933e30c9a2a0c12c7bc0..af785795d255f6e0e3a0cdfa894dceaa7cc0b582 100644 (file)
@@ -186,6 +186,7 @@ LinuxDriver_Freeze(const char *paths,
       }
 
       if (ioctl(fd, FIFREEZE) == -1) {
+         int ioctlerr = errno;
          /*
           * If the ioctl does not exist, Linux will return ENOTTY. If it's not
           * supported on the device, we get EOPNOTSUPP. Ignore the latter,
@@ -193,8 +194,8 @@ LinuxDriver_Freeze(const char *paths,
           * Linux fs drivers may not have been hooked up in the running kernel.
           */
          close(fd);
-         if (errno != EOPNOTSUPP) {
-            Debug(LGPFX "ioctl failed: %d (%s)\n", errno, strerror(errno));
+         if (ioctlerr != EOPNOTSUPP) {
+            Debug(LGPFX "ioctl failed: %d (%s)\n", ioctlerr, strerror(ioctlerr));
             err = first ? SD_UNAVAILABLE : SD_ERROR;
             break;
          }