#ifndef LIB_EXPORT_HH
#define LIB_EXPORT_HH
-#ifdef _WIN32
- #ifdef LIB_EXPORT_SOURCE
- #define LIB_EXPORT __declspec(dllexport)
- #else
- #define LIB_EXPORT __declspec(dllimport)
- #endif
-
- #ifdef LIB_EXPORT_WUI_SOURCE
- #define LIB_EXPORT_WUI __declspec(dllexport)
- #else
- #define LIB_EXPORT_WUI __declspec(dllimport)
- #endif
+#include "vm_api.h"
- #ifdef VMSTRING_EXPORT_SOURCE
- #define VMSTRING_EXPORT __declspec(dllexport)
- #else
- #define VMSTRING_EXPORT __declspec(dllimport)
- #endif
-#else
- #define LIB_EXPORT
- #define LIB_EXPORT_WUI
- #define VMSTRING_EXPORT
-#endif // WIN32
+#ifdef LIB_EXPORT_SOURCE
+ #define LIB_EXPORT VMW_EXPORT
+#else
+ #define LIB_EXPORT VMW_IMPORT
+#endif
+
+#ifdef LIB_EXPORT_WUI_SOURCE
+ #define LIB_EXPORT_WUI VMW_EXPORT
+#else
+ #define LIB_EXPORT_WUI VMW_IMPORT
+#endif
+
+#ifdef VMSTRING_EXPORT_SOURCE
+ #define VMSTRING_EXPORT VMW_EXPORT
+#else
+ #define VMSTRING_EXPORT VMW_IMPORT
+#endif
#endif // LIB_EXPORT_HH
Bool StrUtil_StrToUint(uint32 *out, const char *str);
Bool StrUtil_StrToInt64(int64 *out, const char *str);
Bool StrUtil_StrToSizet(size_t *out, const char *str);
+Bool StrUtil_StrToDouble(double *out, const char *str);
Bool StrUtil_CapacityToSectorType(SectorType *out, const char *str,
unsigned int bytes);
char * StrUtil_FormatSizeInBytesUnlocalized(uint64 size);
--- /dev/null
+/*********************************************************
+ * Copyright (C) 2010 VMware, Inc. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ *
+ * vm_api.h --
+ *
+ * Import/export macro definitions.
+ */
+
+
+#ifndef VM_API_H
+#define VM_API_H
+
+/*
+ * DLL/DSO import/export macros.
+ *
+ * These macros can be used by libraries to automatically export/import symbols.
+ * The general approach is:
+ *
+ * 1) libfoo defines a macro, say FOO_COMPILING_DYNAMIC,
+ * in its Makefile/Scons file.
+ *
+ * 2) libfoo has the following code in a header file, e.g. foo/config.h, that is
+ * included by all headers that export/import symbols:
+ * #include <vm_api.h>
+ * #ifdef FOO_COMPILING_DYNAMIC
+ * # define FOO_API VMW_EXPORT
+ * #else
+ * # define FOO_API VMW_IMPORT
+ * #endif // FOO_COMPILING_DYNAMIC
+ *
+ * For example:
+ * // In a file named FooObject.h
+ * #ifndef FOO_OBJECT_H
+ * #define FOO_OBJECT_H
+ *
+ * #include <foo/config.h>
+ *
+ * class FOO_API FooObject { };
+ * FOO_API FooObject *GetFooObject();
+
+ * #endif // FOO_OBJECT_H
+ *
+ * 3) libfoo can now use FOO_API for all symbols it would like to export,
+ * which resolves to VMW_EXPORT, while compiling libfoo as a dynamic shared
+ * library.
+ *
+ * 4) Whenever a client of libfoo includes its headers, these symbols will be
+ * marked with VMW_IMPORT, since FOO_COMPILING_DYNAMIC is not defined for
+ * the client.
+ *
+ * NOTE: By default, symbols are hidden when compiling with MSC and exported
+ * when compiling with GCC. Thus, it's best to compile with GCC's
+ * -fvisibility=hidden and -fvisibility-inlines-hidden flags, so that only
+ * symbols explicitly marked with VMW_EXPORT are exported. Also note that
+ * these flags, as well as the attributes, are available in GCC 4 and later.
+ */
+#ifdef _MSC_VER
+# define VMW_IMPORT __declspec(dllimport)
+# define VMW_EXPORT __declspec(dllexport)
+#elif defined __GNUC__ && __GNUC__ >= 4 /* !_MSC_VER */
+# define VMW_IMPORT
+# define VMW_EXPORT __attribute__ ((visibility ("default")))
+#else
+# define VMW_IMPORT
+# define VMW_EXPORT
+#endif /* _MSC_VER */
+
+
+#endif /* VM_API_H */
#define VCB_FILE_VERSION 4,0,0,0
#define VIM_VERSION "5.0.0"
#define VPX_VERSION "5.0.0"
+#define VPX_RELEASE_UPDATE "0" /* 0 = Pre-release/GA, 1 = Update 1 */
#define SVA_VERSION "1.0.0"
#define WBC_VERSION "5.0.0"
#define SDK_VERSION "4.1.0"
#define USB_ARBITRATOR_VERSION_MAJOR 8
#define USB_ARBITRATOR_VERSION_MINOR 2
-#define USB_ARBITRATOR_VERSION_Z 4
+#define USB_ARBITRATOR_VERSION_Z 6
#define USB_ARBITRATOR_VERSION_BASE USB_ARBITRATOR_VERSION_MAJOR.\
USB_ARBITRATOR_VERSION_MINOR
* USB Arbitrator Component version. This version is used by the linux
* installer. See USB_ARBITRATOR_COMPONENT_VERSION_NUMBER in mk/defs-onetime.mk
*/
-#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.2.4"
+#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "8.2.6"
#ifdef VMX86_VPX
#define VIM_API_TYPE "VirtualCenter"
# if defined(__APPLE__)
# define PRODUCT_LICENSE_VERSION "3.0"
# else
-# define PRODUCT_LICENSE_VERSION "7.0+"
+# define PRODUCT_LICENSE_VERSION "8.0+"
# endif
# elif defined(VMX86_VPX)
# define PRODUCT_LICENSE_VERSION "5.0"
*out = (unsigned int)val;
return TRUE;
}
-
+
/*
*-----------------------------------------------------------------------------
}
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * StrUtil_StrToDouble --
+ *
+ * Convert a string into a double.
+ *
+ * Results:
+ * TRUE if the conversion was successful and 'out' contains the converted
+ * result.
+ * FALSE otherwise. 'out' is undefined.
+ *
+ * Side effects:
+ * Modifies errno.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+Bool
+StrUtil_StrToDouble(double *out, // OUT: The output value
+ const char *str) // IN : String to parse
+{
+ char *ptr = NULL;
+
+ ASSERT(out);
+ ASSERT(str);
+
+ errno = 0;
+
+ *out = strtod(str, &ptr);
+
+ /*
+ * Input must be complete and no overflow.
+ */
+
+ return *ptr == '\0' && errno != ERANGE;
+}
+
+
#ifndef N_PLAT_NLM // NetWare Tools ask for unresolved _GLOBAL_OFFSET_TABLE...
/*
*-----------------------------------------------------------------------------
/*
* [kK], [mM], [gG], and [tT] represent kilo, mega, giga, and tera
* byte quantities respectively. [bB] represents a singular byte
- * quantity. [sS] represents a sector quantity.
+ * quantity. [sS] represents a sector quantity.
*
* For kilo, mega, giga, and tera we're OK with an additional byte
* suffix. Otherwise, the presence of an additional suffix is an error.
return TRUE;
}
#endif
-
+
/*
*-----------------------------------------------------------------------------
#endif
+/*
+ *----------------------------------------------------------------------
+ *
+ * ProcMgr_ReadProcFile --
+ *
+ * Read the contents of a file in /proc/<pid>.
+ *
+ * The size is essentially unbounded because of cmdline arguments.
+ * The only way to figure out the content size is to keep reading;
+ * stat(2) and lseek(2) lie.
+ *
+ * The contents are NUL terminated -- in some distros may not include
+ * a NUL for some commands (eg. pid 1, /sbin/init) -- so add
+ * one to be safe.
+ *
+ * Results:
+ *
+ * The length of the file.
+ *
+ * -1 on error.
+ *
+ * Side effects:
+ *
+ * The returned contents must be freed by caller.
+ *
+ *----------------------------------------------------------------------
+ */
+
+#if !defined(sun)
+int
+ProcMgr_ReadProcFile(int fd, // IN
+ char **contents) // OUT
+{
+ int size = 0;
+#if !defined(__FreeBSD__) && !defined(__APPLE__)
+ char tmp[512];
+ int numRead;
+
+ *contents = NULL;
+ numRead = read(fd, tmp, sizeof(tmp));
+ size = numRead;
+
+ if (numRead <= 0) {
+ goto done;
+ }
+
+ /*
+ * handle the 99% case
+ */
+ if (sizeof(tmp) > numRead) {
+ char *result;
+
+ result = malloc(numRead + 1);
+ if (NULL == result) {
+ size = -1;
+ goto done;
+ }
+ memcpy(result, tmp, numRead);
+ result[numRead] = '\0';
+ *contents = result;
+ goto done;
+ } else {
+ DynBuf dbuf;
+
+ DynBuf_Init(&dbuf);
+ DynBuf_Append(&dbuf, tmp, numRead);
+ do {
+ numRead = read(fd, tmp, sizeof(tmp));
+ if (numRead > 0) {
+ DynBuf_Append(&dbuf, tmp, numRead);
+ }
+ size += numRead;
+ } while (numRead > 0);
+ // add the NUL term
+ DynBuf_Append(&dbuf, "", 1);
+ DynBuf_Trim(&dbuf);
+ *contents = DynBuf_Detach(&dbuf);
+ DynBuf_Destroy(&dbuf);
+ }
+done:
+#endif
+ return size;
+}
+
+#endif // !sun
+
/*
*----------------------------------------------------------------------
*
pid_t pid;
int replaceLoop;
struct passwd *pwd;
- char cmdLineTemp[2048];
- char cmdStatTemp[2048];
+ char *cmdLineTemp = NULL;
+ char *cmdStatTemp = NULL;
char *cmdLine;
char *userName = NULL;
size_t strLen = 0;
* In the future, we could keep the NUL version around and pass it
* back to the client for easier parsing when retrieving individual
* command line parameters is needed.
- *
- * We read at most (sizeof cmdLineTemp) - 1 bytes to leave room
- * for NUL termination at the end.
*/
- numRead = read(cmdFd, cmdLineTemp, sizeof cmdLineTemp - sizeof(char));
+ numRead = ProcMgr_ReadProcFile(cmdFd, &cmdLineTemp);
close(cmdFd);
+ if (numRead < 0) {
+ continue;
+ }
+
if (numRead > 0) {
+ /*
+ * Stop before we hit the final '\0'; want to leave it alone.
+ */
for (replaceLoop = 0 ; replaceLoop < (numRead - 1) ; replaceLoop++) {
if ('\0' == cmdLineTemp[replaceLoop]) {
cmdLineTemp[replaceLoop] = ' ';
cmdFd = open(cmdFilePath, O_RDONLY);
}
if (cmdFd != -1) {
- numRead = read(cmdFd, cmdLineTemp, sizeof(cmdLineTemp) - sizeof(char));
+ numRead = ProcMgr_ReadProcFile(cmdFd, &cmdLineTemp);
close(cmdFd);
-
- if (numRead < 0) {
- cmdLineTemp[0] = '\0';
- } else {
- cmdLineTemp[numRead] = '\0';
- }
}
if (numRead > 0) {
- /*
+ /*
* Extract the part with just the name, by reading until the first
* space, then reading the next non-space word after that, and
* ignoring everything else. The format looks like this:
* for example:
* "Name: nfsd"
*/
- const char* nameStart = NULL;
- char* copyItr = NULL;
+ const char *nameStart;
+ char *copyItr;
/* Skip non-whitespace. */
for (nameStart = cmdLineTemp; *nameStart &&
}
}
- /*
- * There is an edge case where /proc/#/cmdline does not NUL terminate
- * the command. /sbin/init (process 1) is like that on some distros.
- * So let's guarantee that the string is NUL terminated, even if
- * the last character of the string might already be NUL.
- * This is safe to do because we read at most (sizeof cmdLineTemp) - 1
- * bytes from /proc/#/cmdline -- we left just enough space to add
- * NUL termination at the end.
- */
- if (numRead < 0) {
- cmdLineTemp[0] = '\0';
- } else {
- cmdLineTemp[numRead] = '\0';
- }
-
/*
* Get the inode information for this process. This gives us
* the process owner.
"/proc/%s",
ent->d_name) == -1) {
Debug("Giant process id '%s'\n", ent->d_name);
- continue;
+ goto next_entry;
}
/*
*/
statResult = stat(cmdFilePath, &fileStat);
if (0 != statResult) {
- continue;
+ goto next_entry;
}
/*
"/proc/%s/stat",
ent->d_name) == -1) {
Debug("Giant process id '%s'\n", ent->d_name);
- continue;
+ goto next_entry;
}
cmdFd = open(cmdFilePath, O_RDONLY);
if (-1 == cmdFd) {
- continue;
+ goto next_entry;
}
- numRead = read(cmdFd, cmdStatTemp, sizeof cmdStatTemp);
+ numRead = ProcMgr_ReadProcFile(cmdFd, &cmdStatTemp);
close(cmdFd);
if (0 >= numRead) {
- continue;
+ goto next_entry;
}
/*
* Skip over initial process id and process name. "123 (bash) [...]".
*/
stringBegin = strchr(cmdStatTemp, ')') + 2;
-
+
numberFound = sscanf(stringBegin, "%c %d %d %d %d %d "
"%lu %lu %lu %lu %lu %Lu %Lu %Lu %Lu %ld %ld "
"%d %ld %Lu",
(int *) &dummy, (long *) &dummy,
&relativeStartTime);
if (20 != numberFound) {
- continue;
+ goto next_entry;
}
processStartTime = hostStartTime + (relativeStartTime / hertz);
/*
* Store the command line string pointer in dynbuf.
*/
- cmdLine = strdup(cmdLineTemp);
+ if (cmdLineTemp) {
+ cmdLine = Unicode_Alloc(cmdLineTemp, STRING_ENCODING_DEFAULT);
+ } else {
+ cmdLine = Unicode_Alloc("", STRING_ENCODING_UTF8);
+ }
DynBuf_Append(&dbProcCmd, &cmdLine, sizeof cmdLine);
/*
pwd = getpwuid(fileStat.st_uid);
userName = (NULL == pwd)
? Str_Asprintf(&strLen, "%d", (int) fileStat.st_uid)
- : Util_SafeStrdup(pwd->pw_name);
+ : Unicode_Alloc(pwd->pw_name, STRING_ENCODING_DEFAULT);
DynBuf_Append(&dbProcOwner, &userName, sizeof userName);
/*
DynBuf_Append(&dbProcStartTime,
&processStartTime,
sizeof processStartTime);
+
+next_entry:
+ free(cmdLineTemp);
+ free(cmdStatTemp);
} // while readdir
closedir(dir);
* ExtractCommandLineFromAddressSpaceFile for every process.
*/
if (strlen(procInfo.pr_psargs) + 1 == PRARGSZ) {
- cmdLineTemp = ExtractCommandLineFromAddressSpaceFile(&procInfo);
- if(cmdLineTemp == NULL) {
- cmdLineTemp = Util_SafeStrdup(procInfo.pr_psargs);
+ char *tmp;
+
+ tmp = ExtractCommandLineFromAddressSpaceFile(&procInfo);
+ if (tmp != NULL) {
+ cmdLineTemp = Unicode_Alloc(tmp, STRING_ENCODING_DEFAULT);
+ free(tmp);
+ } else {
+ cmdLineTemp = Unicode_Alloc(procInfo.pr_psargs,
+ STRING_ENCODING_DEFAULT);
}
} else {
- cmdLineTemp = Util_SafeStrdup(procInfo.pr_psargs);
+ cmdLineTemp = Unicode_Alloc(procInfo.pr_psargs,
+ STRING_ENCODING_DEFAULT);
}
/*
pwd = getpwuid(procInfo.pr_uid);
userName = (NULL == pwd)
? Str_Asprintf(&strLen, "%d", (int) procInfo.pr_uid)
- : Util_SafeStrdup(pwd->pw_name);
+ : Unicode_Alloc(pwd->pw_name, STRING_ENCODING_DEFAULT);
DynBuf_Append(&dbProcOwner, &userName, sizeof userName);
/*
#define _VMNET_DEF_H_
#define INCLUDE_ALLOW_USERLEVEL
+#define INCLUDE_ALLOW_VMCORE
#define INCLUDE_ALLOW_MODULE
#define INCLUDE_ALLOW_VMK_MODULE
#define INCLUDE_ALLOW_DISTRIBUTE
#include "includeCheck.h"
+#define VMNET_NAME_BUFFER_LEN 128 /* Increased for i18n. */
+
/*
* capabilities - not all of these are implemented in the virtual HW
* (eg VLAN support is in the virtual switch) so even vlance
#define G_LOG_DOMAIN "dndcp"
-#include "copyPasteDnDWrapper.h"
-#include "guestDnDCPMgr.hh"
-
#if defined(HAVE_GTKMM)
#include "copyPasteDnDX11.h"
#endif
#include "copyPasteDnDMac.h"
#endif
+#include "copyPasteDnDWrapper.h"
+#include "guestDnDCPMgr.hh"
+
extern "C" {
#include "vmware.h"
#include "rpcout.h"
#define DND_CP_LIB_EXPORT_HH
#if defined VMX86_TOOLS || COMPILE_WITHOUT_CUI
+# ifdef LIB_EXPORT
+# undef LIB_EXPORT
+# endif
#define LIB_EXPORT
#else
#include "libExport.hh"