From: VMware, Inc <> Date: Mon, 22 Mar 2010 19:12:08 +0000 (-0700) Subject: lib/file: remove some now unnecessary COS entanglements X-Git-Tag: 2010.03.20-243334~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d17d52c33e774b3fdea4aeadfb3413a900c5755b;p=thirdparty%2Fopen-vm-tools.git lib/file: remove some now unnecessary COS entanglements With the demise of COS there is no longer a need to deal with magic pid initializations for file locking. Remove a great deal of stale code. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/fileLockPosix.c b/open-vm-tools/lib/file/fileLockPosix.c index ccbf6c184..4f608a5a4 100644 --- a/open-vm-tools/lib/file/fileLockPosix.c +++ b/open-vm-tools/lib/file/fileLockPosix.c @@ -55,39 +55,15 @@ #include "localconfig.h" #include "hostinfo.h" #include "su.h" +#include "hostType.h" #include "unicodeOperations.h" -#if defined(VMX86_SERVER) -#include "hostType.h" -/* - * UserWorlds have to handle file locking slightly differently than COS - * applications, as they are in a different pid space. The problem is that - * if a UserWorld tries to write its UserWorld pid to a lock file, a COS - * program will think the lock file is stale, as that pid won't be valid on - * the COS. Luckily, every UW is attached to a COS proxy, so, for the - * purposes of this file, the UW can use its COS proxy's pid as its pid when - * locking files. This way, if a COS app looks up the proxy pid, it will be - * valid and the COS app will wait for the lock. - */ -#include "uwvmk.h" -#endif - #define LOGLEVEL_MODULE main #include "loglevel_user.h" #define DEVICE_LOCK_DIR "/var/lock" -/* - * Parameters used by the file library. - */ -typedef struct FileLockOptions { - int lockerPid; - Bool userWorld; -} FileLockOptions; - -static FileLockOptions fileLockOptions = { 0, FALSE }; - /* * XXX * Most of these warnings must be turned back into Msg_Appends, or the @@ -97,30 +73,6 @@ static FileLockOptions fileLockOptions = { 0, FALSE }; * into the log file. */ -/* - *---------------------------------------------------------------------- - * - * FileLock_Init -- - * - * Initialize the file locking library. - * - * Results: - * None. - * - * Side effects: - * Allows the user to enable locking on random file systems. - * - *---------------------------------------------------------------------- - */ - -void -FileLock_Init(int lockerPid, // IN: - Bool userWorld) // IN: -{ - fileLockOptions.lockerPid = lockerPid; - fileLockOptions.userWorld = userWorld; -} - #if !defined(__FreeBSD__) && !defined(sun) /* *---------------------------------------------------------------------- @@ -147,12 +99,14 @@ IsLinkingAvailable(const char *fileName) // IN: ASSERT(fileName); -#if defined(VMX86_SERVER) - // Never supported on VMvisor - if (HostType_OSIsPureVMK()) { + /* + * Don't use linking on ESX/VMFS... the overheads are expensive and this + * path really isn't used. + */ + + if (HostType_OSIsVMK()) { return FALSE; } -#endif status = statfs(fileName, &buf); @@ -194,7 +148,6 @@ IsLinkingAvailable(const char *fileName) // IN: case TMPFS_SUPER_MAGIC: case JFS_SUPER_MAGIC: return TRUE; // these are known to work - case VMFS_SUPER_MAGIC: case SMB_SUPER_MAGIC: case MSDOS_SUPER_MAGIC: return FALSE; @@ -212,45 +165,6 @@ IsLinkingAvailable(const char *fileName) // IN: } -/* - *--------------------------------------------------------------------------- - * - * FileLockGetPid -- - * - * Returns the pid of the main thread if we're running in a - * multithreaded process, otherwise return the result of getpid(). - * - * Results: - * a pid. - * - * Side effects: - * None. - * - *--------------------------------------------------------------------------- - */ - -static int -FileLockGetPid(void) -{ -#if defined(VMX86_SERVER) - /* - * For a UserWorld, we want to get this cartel's proxy's cos pid. - */ - if (fileLockOptions.userWorld) { - int pid, err; - - err = VMKernel_GetLockPid(&pid); - ASSERT_NOT_IMPLEMENTED(err == 0); - - return pid; - } -#endif - - return fileLockOptions.lockerPid > 0 ? - fileLockOptions.lockerPid : (int) getpid(); -} - - /* *---------------------------------------------------------------------- * @@ -401,12 +315,6 @@ FileLockIsValidProcess(int pid) // IN: int err; Bool ret; -#if defined(VMX86_SERVER) - if (fileLockOptions.userWorld) { - return (VMKernel_IsLockPidAlive(pid) == 0) ? TRUE : FALSE; - } -#endif - uid = Id_BeginSuperUser(); err = (kill(pid, 0) == -1) ? errno : 0; Id_EndSuperUser(uid); @@ -571,14 +479,14 @@ FileLock_LockDevice(const char *deviceName) // IN: deviceName); lockFileLink = Str_SafeAsprintf(NULL, "%s/LTMP..%s.t%05d", DEVICE_LOCK_DIR, - deviceName, FileLockGetPid()); + deviceName, getpid()); LOG(1, ("Requesting lock %s (temp = %s).\n", lockFileName, lockFileLink)); hostID = FileLockGetMachineID(); Str_Sprintf(uniqueID, sizeof uniqueID, "%d %s\n", - FileLockGetPid(), hostID); + getpid(), hostID); while ((status = FileLockCreateLockFile(lockFileName, lockFileLink, uniqueID)) == 0) { @@ -1064,7 +972,7 @@ FileLockWriteFile(FILELOCK_FILE_HANDLE handle, // IN: char * FileLockGetExecutionID(void) { - return Str_SafeAsprintf(NULL, "%d", FileLockGetPid()); + return Str_SafeAsprintf(NULL, "%d", getpid()); } @@ -1178,7 +1086,7 @@ FileLock_Lock(ConstUnicode filePath, // IN: } Str_Sprintf(creationTimeString, sizeof creationTimeString, "%"FMT64"u", - ProcessCreationTime(FileLockGetPid())); + ProcessCreationTime(getpid())); lockToken = FileLockIntrinsic(normalizedPath, !readOnly, msecMaxWaitTime, creationTimeString, err); diff --git a/open-vm-tools/lib/include/fileLock.h b/open-vm-tools/lib/include/fileLock.h index fe4eea93d..865908d12 100644 --- a/open-vm-tools/lib/include/fileLock.h +++ b/open-vm-tools/lib/include/fileLock.h @@ -30,13 +30,6 @@ #include "unicodeTypes.h" -#if !defined(_WIN32) -/* - * Set the file type config variables for linux. - */ -EXTERN void FileLock_Init(int lockerPid, Bool userWorld); -#endif - // Horrible hack that exists to please VMX; should be removed ASAP EXTERN int FileLock_DeleteFileVMX(ConstUnicode filePath);