From: VMware, Inc <> Date: Fri, 12 Apr 2013 19:57:08 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2013.04.16-1098359~8 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=47ba080c7df1badb0a160df3bf10e241aef880aa;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/lib/file/filePosix.c b/open-vm-tools/lib/file/filePosix.c index a4ff4a01d..58d08230d 100644 --- a/open-vm-tools/lib/file/filePosix.c +++ b/open-vm-tools/lib/file/filePosix.c @@ -656,6 +656,20 @@ FileVMFSGetCanonicalPath(ConstUnicode absVMDirName) // IN Unicode dirPath = NULL; Unicode canonPath = NULL; /* result */ + /* + * The very first thing that we do is to open the VVol control node. + * This will fail if the VVol module is not loaded. In that case we + * short circuit to the failure case. This helps systems which do not + * use VVols, as we avoid the extra file opens (by File_IsDirectory + * and File_GetVMFSFSType) in those cases. + * Note that file opens are especially expensive on NFS. + * See PR 1007403. + */ + ctrlfd = Posix_Open(VVOL_NAMESPACE_CONTROL_NODE, O_RDONLY); + if (ctrlfd < 0) { + goto use_same_path; + } + /* * absVMDirName should start with /vmfs/volumes/. */ @@ -689,16 +703,6 @@ FileVMFSGetCanonicalPath(ConstUnicode absVMDirName) // IN goto use_same_path; } - /* - * The most likely reason this will fail is if the VVol control node is - * not present which means VVol module is not loaded. We can not translate - * the pathname in that case. - */ - ctrlfd = Posix_Open(VVOL_NAMESPACE_CONTROL_NODE, O_RDONLY); - if (ctrlfd < 0) { - goto use_same_path; - } - /* * VM directory is on an NFS fileystem. It could be a regular NFS filesystem * backed storage or an NFS config VVol. We need to check. diff --git a/open-vm-tools/lib/include/backdoor_def.h b/open-vm-tools/lib/include/backdoor_def.h index 92d2fd336..d9a080427 100644 --- a/open-vm-tools/lib/include/backdoor_def.h +++ b/open-vm-tools/lib/include/backdoor_def.h @@ -168,7 +168,8 @@ #define BDOOR_CMD_SET_PCI_HOLE 77 /* CPL 0 only */ #define BDOOR_CMD_GET_PCI_HOLE 78 /* CPL 0 only */ #define BDOOR_CMD_GET_PCI_BAR 79 /* CPL 0 only */ -#define BDOOR_CMD_MAX 80 +#define BDOOR_CMD_SHOULD_GENERATE_SYSTEMID 80 /* CPL 0 only */ +#define BDOOR_CMD_MAX 81 /* diff --git a/open-vm-tools/lib/include/codeset.h b/open-vm-tools/lib/include/codeset.h index 0dfcfacb0..f70b8144b 100644 --- a/open-vm-tools/lib/include/codeset.h +++ b/open-vm-tools/lib/include/codeset.h @@ -376,6 +376,9 @@ Bool CodeSet_UTF32ToUTF8(const char *utf32, int CodeSet_LengthInCodePoints(const char *utf8); +int CodeSet_CodePointOffsetToByteOffset(const char *utf8, + int codePointOffset); + int CodeSet_GetUtf8(const char *string, const char *end, uint32 *uchar); @@ -458,7 +461,7 @@ CodeSet_Utf16ToUtf8(const utf16_t *strW) // IN: * put a NUL terminator. * * Results: - * + * * Returns the offset of the byte immediately following the last * complete UTF-8 code point in buf that is entirely within the * range [0, offset-1]. Note that if the final UTF-8 code point @@ -543,7 +546,7 @@ CodeSet_Utf8FindCodePointBoundary(const char *buf, // IN * put a NUL terminator. * * Results: - * + * * Returns the offset of the byte immediately following the last * complete UTF-16 code point in buf that is entirely within the * range [0, offset-1]. Note that if the final UTF-16 code point diff --git a/open-vm-tools/lib/include/includeCheck.h b/open-vm-tools/lib/include/includeCheck.h index 4e202c4be..8a7ab0924 100644 --- a/open-vm-tools/lib/include/includeCheck.h +++ b/open-vm-tools/lib/include/includeCheck.h @@ -160,9 +160,7 @@ #endif #undef INCLUDE_ALLOW_VMIROM -#if defined INCLUDE_ALLOW_MKS && \ - !(defined LOCALMKS || defined REMOTEMKS || \ - defined SERVERMKS || defined CLIENTMKS) +#if defined INCLUDE_ALLOW_MKS && !(defined COREMKS) #error "The surrounding include file is not allowed outside of the MKS." #endif #undef INCLUDE_ALLOW_MKS diff --git a/open-vm-tools/lib/include/loglevel_user.h b/open-vm-tools/lib/include/loglevel_user.h index 4176daa75..3e3451335 100644 --- a/open-vm-tools/lib/include/loglevel_user.h +++ b/open-vm-tools/lib/include/loglevel_user.h @@ -136,6 +136,7 @@ LOGLEVEL_VAR(mksGLShader), \ LOGLEVEL_VAR(mksGLState), \ LOGLEVEL_VAR(mksGLWindow), \ + LOGLEVEL_VAR(mksGLContextMux), \ LOGLEVEL_VAR(mksWinBSOD), \ LOGLEVEL_VAR(vdpPlugin), \ \ diff --git a/open-vm-tools/lib/include/poll.h b/open-vm-tools/lib/include/poll.h index c123a2101..7cb4d475b 100644 --- a/open-vm-tools/lib/include/poll.h +++ b/open-vm-tools/lib/include/poll.h @@ -164,10 +164,10 @@ PollClassSet_Include(PollClassSet set, PollClass c) #define POLL_CS_MAIN PollClassSet_Singleton(POLL_CLASS_MAIN) #define POLL_CS_PAUSE PollClassSet_Union(POLL_CS_MAIN, \ PollClassSet_Singleton(POLL_CLASS_PAUSE)) -#define POLL_CS_IPC PollClassSet_Union(POLL_CS_PAUSE, \ - PollClassSet_Singleton(POLL_CLASS_IPC)) -#define POLL_CS_CPT PollClassSet_Union(POLL_CS_IPC, \ +#define POLL_CS_CPT PollClassSet_Union(POLL_CS_PAUSE, \ PollClassSet_Singleton(POLL_CLASS_CPT)) +#define POLL_CS_IPC PollClassSet_Union(POLL_CS_CPT, \ + PollClassSet_Singleton(POLL_CLASS_IPC)) #define POLL_CS_VMDB POLL_CS_PAUSE /* POLL_CLASS_VMDB is retired */ #define POLL_CS_MKS PollClassSet_Singleton(POLL_CLASS_MKS) /* @@ -185,11 +185,11 @@ PollClassSet_Include(PollClassSet set, PollClass c) * POLL_CS_CPT * - Only for callbacks which can trigger intermediate Checkpoint * transitions. - * The ONLY such callbacks are CrossUserRPC and VMotion. + * The ONLY such callback is Migrate. * POLL_CS_IPC * - Only for callbacks which can contain Msg_(Post|Hint|Question) * responses, and for signal handlers (why)? - * IPC, VMDB, and Foundry can contain Msg_* responses. + * Vigor, VMDB, and Foundry can contain Msg_* responses. * POLL_CS_MKS * - Callback runs in MKS thread. * POLL_CS_ALWAYS diff --git a/open-vm-tools/lib/include/vm_assert.h b/open-vm-tools/lib/include/vm_assert.h index 9078d5ff9..12bcb676d 100644 --- a/open-vm-tools/lib/include/vm_assert.h +++ b/open-vm-tools/lib/include/vm_assert.h @@ -287,10 +287,10 @@ do { \ #define LOG_ONCE(_s) DO_ONCE(Log _s) #ifdef VMX86_DEVEL - #define DEPRECATED(_fix) DO_ONCE( \ - Warning("%s:%d: %s is DEPRECATED; %s\n", \ - __FILE__, __LINE__, __FUNCTION__, \ - _fix)) + #define DEPRECATED(_fix) DO_ONCE( \ + Warning("%s:%d: %s is DEPRECATED. %s\n", \ + __FILE__, __LINE__, __FUNCTION__, \ + _fix)) #else #define DEPRECATED(_fix) do {} while (0) #endif diff --git a/open-vm-tools/lib/misc/codesetBase.c b/open-vm-tools/lib/misc/codesetBase.c index 8c4611b14..cf093c870 100644 --- a/open-vm-tools/lib/misc/codesetBase.c +++ b/open-vm-tools/lib/misc/codesetBase.c @@ -73,7 +73,7 @@ CodeSet_GetCurrentCodeSet(void) int CodeSet_GetUtf8(const char *string, // IN: string const char *end, // IN: end of string - uint32 *uchar) // OUT: the Unicode character + uint32 *uchar) // OUT/OPT: the Unicode character { uint8 *p = (uint8 *) string; uint8 *e; @@ -181,8 +181,7 @@ CodeSet_LengthInCodePoints(const char *utf8) // IN: end = p + strlen(utf8); while (p < end) { - uint32 utf32; - uint32 len = CodeSet_GetUtf8(p, end, &utf32); + uint32 len = CodeSet_GetUtf8(p, end, NULL); if (len == 0) { return -1; @@ -196,6 +195,55 @@ CodeSet_LengthInCodePoints(const char *utf8) // IN: } +/* + *----------------------------------------------------------------------------- + * + * CodeSet_CodePointOffsetToByteOffset -- + * + * Return the byte offset of the character at the given codepoint + * offset. + * + * Results: + * -1 on error + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +int +CodeSet_CodePointOffsetToByteOffset(const char *utf8, // IN + int codePointOffset) // IN +{ + const char *p; + const char *end; + + ASSERT(utf8); + + p = utf8; + end = p + strlen(utf8); + + while (p < end && codePointOffset > 0) { + uint32 utf32; + uint32 len = CodeSet_GetUtf8(p, end, &utf32); + + if (len == 0) { + return -1; + } + + p += len; + codePointOffset--; + } + + if (codePointOffset == 0) { + return p - utf8; + } else { + return -1; + } +} + + /* *----------------------------------------------------------------------------- *