From: VMware, Inc <> Date: Tue, 22 Nov 2011 00:01:20 +0000 (-0800) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2011.11.20-535097~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=6c197b8e5eccf32bfee0e2452d8926968182aada;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/fileIO.c b/open-vm-tools/lib/file/fileIO.c index 07690ebbb..571956608 100644 --- a/open-vm-tools/lib/file/fileIO.c +++ b/open-vm-tools/lib/file/fileIO.c @@ -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); diff --git a/open-vm-tools/lib/include/cpuid_info.h b/open-vm-tools/lib/include/cpuid_info.h index 9dc456e45..09bd74f21 100644 --- a/open-vm-tools/lib/include/cpuid_info.h +++ b/open-vm-tools/lib/include/cpuid_info.h @@ -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 diff --git a/open-vm-tools/lib/lock/ulRec.c b/open-vm-tools/lib/lock/ulRec.c index 51bdd4ad3..adaee56d6 100644 --- a/open-vm-tools/lib/lock/ulRec.c +++ b/open-vm-tools/lib/lock/ulRec.c @@ -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__); }