]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file: FileIO_AtomicUpdateEx ASSERT
authorOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:18 +0000 (14:21 -0700)
committerOliver Kurth <okurth@vmware.com>
Mon, 23 Oct 2017 21:21:18 +0000 (14:21 -0700)
ASSERT(File_IsSameFile(dirName, dstDirName)) fired when NFS went
down at just the right moment.  It was not obvious that the ASSERT
fired due to an NFS failure.

File_IsSameFile correctly returns errno upon failure.  Check the
errno value to properly detect and return an error.

open-vm-tools/lib/file/fileIO.c

index 1c3657235253b4e985f495a5b27b774e4e253c4a..b053ed2328093a08ca51c3ddb79d635f37e86994 100644 (file)
@@ -854,6 +854,7 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
       char *fileName = NULL;
       char *dstDirName = NULL;
       char *dstFileName = NULL;
+      Bool isSame;
 
       currPath = File_FullPath(FileIO_Filename(currFD));
       if (currPath == NULL) {
@@ -875,10 +876,19 @@ FileIO_AtomicUpdateEx(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
       File_GetPathName(currPath, &dstDirName, &dstFileName);
 
       ASSERT(dirName != NULL);
-      ASSERT(fileName && *fileName);
+      ASSERT(fileName != NULL && *fileName != '\0');
       ASSERT(dstDirName != NULL);
-      ASSERT(dstFileName && *dstFileName);
-      ASSERT(File_IsSameFile(dirName, dstDirName));
+      ASSERT(dstFileName != NULL && *dstFileName != '\0');
+
+      errno = 0;
+      isSame = File_IsSameFile(dirName, dstDirName);
+      if (errno == 0) {
+         ASSERT(isSame);
+      } else {
+         savedErrno = errno;
+         Log("%s: File_IsSameFile failed (errno = %d).\n", __FUNCTION__, errno);
+         goto swapdone;
+      }
 
       args = Util_SafeCalloc(1, sizeof *args);
       args->fd = currFD->posix;
@@ -1027,7 +1037,7 @@ swapdone:
  *
  * FileIO_AtomicUpdate --
  *
- *      Wrapper around FileIO_AtomicUpdateEx that derfaults 'renameOnNFS' to
+ *      Wrapper around FileIO_AtomicUpdateEx that defaults 'renameOnNFS' to
  *      TRUE.
  *
  * Results: