]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
lib/file: remove some now unnecessary COS entanglements
authorVMware, Inc <>
Mon, 22 Mar 2010 19:12:08 +0000 (12:12 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 22 Mar 2010 19:12:08 +0000 (12:12 -0700)
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 <mvanzin@vmware.com>
open-vm-tools/lib/file/fileLockPosix.c
open-vm-tools/lib/include/fileLock.h

index ccbf6c184150edcdabe5147a05f2090c858da665..4f608a5a409aebbcfbf1edf48b4ed37c5fc803f5 100644 (file)
 #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);
index fe4eea93dfba82bf1cd0f0df766d710aa9af3d07..865908d129602cebf85ab47d756db52614d18b3a 100644 (file)
 
 #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);