From: VMware, Inc <> Date: Thu, 22 Dec 2011 00:19:41 +0000 (-0800) Subject: syncDriver: do not use stale errno on Linux X-Git-Tag: 2011.12.20-562307~42 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8337c4fac0de11cdaa5235abce946eddd4ec2989;p=thirdparty%2Fopen-vm-tools.git syncDriver: do not use stale errno on Linux close() may clobber errno so cache it immediately after calling ioctl(fd, FIFREEZE) instead of it directly later. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/syncDriver/syncDriverLinux.c b/open-vm-tools/lib/syncDriver/syncDriverLinux.c index 7dfae425e..af785795d 100644 --- a/open-vm-tools/lib/syncDriver/syncDriverLinux.c +++ b/open-vm-tools/lib/syncDriver/syncDriverLinux.c @@ -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; }