]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Tue, 22 Nov 2011 00:01:20 +0000 (16:01 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 22 Nov 2011 00:01:20 +0000 (16:01 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/file/fileIO.c
open-vm-tools/lib/include/cpuid_info.h
open-vm-tools/lib/lock/ulRec.c

index 07690ebbb83c5609f527ea1c2cfcc12f7dc83afc..5719566083b8ad6cfd7b365c16c2d4f6c825387c 100644 (file)
@@ -641,6 +641,7 @@ FileIO_AtomicTempFile(FileIODescriptor *fileFD,  // IN:
    int permissions;
    FileIOResult status;
 #if !defined(_WIN32)
+   int ret;
    struct stat stbuf;
 #endif
 
@@ -665,16 +666,22 @@ FileIO_AtomicTempFile(FileIODescriptor *fileFD,  // IN:
       goto bail;
    }
    permissions = stbuf.st_mode;
-   Posix_Unlink(tempPath);
+
+   /* Do a "cleanup" unlink in case some previous process left a temp file around */
+   ret = Posix_Unlink(tempPath);
+   if (ret != 0 && errno != ENOENT) { /* ENOENT is expected, file should not exist */
+      Log("%s: Failed to unlink temporary file, errno: %d\n",
+          __FUNCTION__, errno);
+      /* Fall through; FileIO_Create will report the actual error */
+   }
 #endif
 
    status = FileIO_Create(tempFD, tempPath,
                           FILEIO_ACCESS_READ | FILEIO_ACCESS_WRITE,
-                          FILEIO_OPEN_CREATE, permissions);
+                          FILEIO_OPEN_CREATE_SAFE, permissions);
    if (!FileIO_IsSuccess(status)) {
-      Log("%s: Failed to create temporary file\n", __FUNCTION__);
-      ASSERT_BUG_DEBUGONLY(615124, errno != EBUSY);
-      ASSERT(!vmx86_server); // For APD, hosted can fall-back and write directly
+      Log("%s: Failed to create temporary file, err: %d\n", __FUNCTION__,
+          Err_Errno());
       goto bail;
    }
 
@@ -704,12 +711,18 @@ FileIO_AtomicTempFile(FileIODescriptor *fileFD,  // IN:
    return FILEIO_SUCCESS;
 
 bail:
+   ASSERT(!FileIO_IsSuccess(status));
    if (FileIO_IsValid(tempFD)) {
       FileIO_Close(tempFD);
 #if defined(_WIN32)
       File_UnlinkIfExists(tempPath);
 #else
-      Posix_Unlink(tempPath);
+      ret = Posix_Unlink(tempPath);
+      if (ret != 0) {
+         Log("%s: Failed to clean up temporary file, errno: %d\n",
+             __FUNCTION__, errno);
+      }
+      ASSERT(ret == 0);
 #endif
    }
    Unicode_Free(tempPath);
index 9dc456e45060a21bc75150f5b2447bc68c7b8cb3..09bd74f215ee35cd66c976b4f350ac92ef141160 100644 (file)
@@ -92,86 +92,4 @@ CPUIDSummary_RegsFromCpuid0(CPUID0* id0In,
    return id0Out;
 }
 
-
-/*
- *----------------------------------------------------------------------
- *
- * CPUIDSummary_SafeToUseMC0_CTL --
- *
- *      Determines whether it is safe to write to the MCE control
- *      register MC0_CTL.
- *      Known safe:     P4, All AMD, all family 6 model > 0x1a, except core/atom
- *      Don't know:     P2, P3
- *
- * Results:
- *      True iff it is known to be safe.
- *
- * Side effects:
- *      None.
- *
- *----------------------------------------------------------------------
- */
-static INLINE Bool
-CPUIDSummary_SafeToUseMC0_CTL(CPUIDSummary* cpuidSummary)
-{
-   CPUIDRegs id0;
-
-   CPUIDSummary_RegsFromCpuid0(&cpuidSummary->id0, &id0);   
-   return CPUID_IsVendorAMD(&id0) ||
-      (CPUID_IsVendorIntel(&id0) &&
-       (CPUID_FAMILY_IS_PENTIUM4(cpuidSummary->id1.version) ||
-        (CPUID_FAMILY_IS_P6(cpuidSummary->id1.version) &&
-         (CPUID_EFFECTIVE_MODEL(cpuidSummary->id1.version) ==
-            CPUID_MODEL_NEHALEM_1A ||
-          CPUID_EFFECTIVE_MODEL(cpuidSummary->id1.version) >=
-            CPUID_MODEL_NEHALEM_1E))));
-}
-
-
-/* The following functions return the number of cores per package
-   and set *numThreadsPerCore to the number of hardware threads per core. */ 
-static INLINE uint32
-CPUIDSummary_VIACoresPerPackage(CPUIDSummary *cpuid,
-                                uint32 *numThreadsPerCore)
-{
-   (void) cpuid;
-   *numThreadsPerCore = 1;
-   return 1;
-}
-
-static INLINE uint32 
-CPUIDSummary_AMDCoresPerPackage(CPUIDSummary *cpuid,
-                                uint32 *numThreadsPerCore)
-{
-   uint32 version = cpuid->id1.version, numEntries = cpuid->id80.numEntries;
-   *numThreadsPerCore = 1;
-   return CPUID_FAMILY_IS_K8STAR(version) && numEntries >= 0x80000008 ?
-             CPUID_AMDCoresPerPackage(cpuid->id88.ecx) : 1;
-}
-
-static INLINE uint32
-CPUIDSummary_IntelCoresPerPackage(CPUIDSummary *cpuid,
-                                  uint32 *numThreadsPerCore)
-{
-   uint32 numCoresPerPackage;
-   
-   *numThreadsPerCore = numCoresPerPackage = 1;
-   /*
-    * Multi-core processors have the HT feature bit set even if they don't
-    * support HT.  The reported number of HT is the total, not per core.
-    */
-   if (CPUID_ISSET(1, EDX, HTT, cpuid->id1.edxFeatures)) {
-      *numThreadsPerCore = CPUID_GET(1, EBX, LCPU_COUNT, cpuid->id1.ebx);
-       if (cpuid->id0.numEntries >= 4) {
-         numCoresPerPackage =
-            CPUID_IntelCoresPerPackage(__GET_EAX_FROM_CPUID4(0));
-#ifdef ASSERT
-         ASSERT(*numThreadsPerCore % numCoresPerPackage == 0);
-#endif
-         *numThreadsPerCore /= numCoresPerPackage;
-      }
-   }
-   return numCoresPerPackage;
-}
-
 #endif
index 51bdd4ad31dc80d223d3aff5211c82db66de5b57..adaee56d6c32e79b2235a1f63198c2f80188c770 100644 (file)
@@ -603,13 +603,9 @@ MXUser_ReleaseRecLock(MXUserRecLock *lock)  // IN/OUT:
       MXRecLockRelease(&lock->recursiveLock);
    }
 
-   /*
-    * Don't screw up the reference count! When this is the last reference
-    * the lock will self destruct on a release if it is the last "hold"
-    * of the lock.
-    */
-
-   MXUserCondDestroyRecLock(lock);
+   if (Atomic_FetchAndDec(&lock->refCount) == 1) {
+      Panic("%s: Zero reference count upon exit\n", __FUNCTION__);
+   }
 }
 
 
@@ -653,8 +649,7 @@ MXUser_TryAcquireRecLock(MXUserRecLock *lock)  // IN/OUT:
       MXUserStats *stats;
 
       if (MXUserTryAcquireFail(lock->header.name)) {
-         success = FALSE;
-         goto bail;
+         return FALSE;
       }
 
       success = MXRecLockTryAcquire(&lock->recursiveLock);
@@ -671,8 +666,6 @@ MXUser_TryAcquireRecLock(MXUserRecLock *lock)  // IN/OUT:
       }
    }
 
-bail:
-
    if (Atomic_FetchAndDec(&lock->refCount) == 1) {
       Panic("%s: Zero reference count upon exit\n", __FUNCTION__);
    }