From: VMware, Inc <> Date: Wed, 18 Sep 2013 03:18:23 +0000 (-0700) Subject: Internal branch sync. Included in this change: X-Git-Tag: 2013.09.16-1328054~98 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=447758846b1a1caa09c2aa0dad5757897ad79bc0;p=thirdparty%2Fopen-vm-tools.git Internal branch sync. Included in this change: . lib/file - add File_MakeSafeTempDir() . 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/fileTemp.c b/open-vm-tools/lib/file/fileTemp.c index f45628779..c0922e5b3 100644 --- a/open-vm-tools/lib/file/fileTemp.c +++ b/open-vm-tools/lib/file/fileTemp.c @@ -267,12 +267,51 @@ File_MakeTempEx(ConstUnicode dir, // IN: } +/* + *---------------------------------------------------------------------- + * + * File_MakeSafeTempDir -- + * + * Create a temporary directory in a safe area. + * + * Optional argument 'prefix' specifies the name prefix of the + * created directory. When not provided a default will be provided. + * + * Results: + * NULL Failure + * !NULL Path name of created directory + * + * Side effects: + * Creates a directory if successful. Errno is set on error + * + *---------------------------------------------------------------------- + */ + +Unicode +File_MakeSafeTempDir(ConstUnicode prefix) // IN: +{ + Unicode result = NULL; + Unicode dir = File_GetSafeTmpDir(TRUE); + + if (dir != NULL) { + ConstUnicode effectivePrefix = (prefix == NULL) ? "safeDir" : prefix; + + File_MakeTempEx2(dir, FALSE, FileMakeTempExCreateNameFunc, + (void *) effectivePrefix, &result); + + Unicode_Free(dir); + } + + return result; +} + + /* *---------------------------------------------------------------------- * * File_MakeSafeTemp -- * - * Exactly the same as File_MakeTemp except uses a safe directory + * Exactly the same as File_MakeTempEx except uses a safe directory * as the default temporary directory. * * Results: @@ -280,6 +319,7 @@ File_MakeTempEx(ConstUnicode dir, // IN: * * Side effects: * Creates a file if successful. + * *---------------------------------------------------------------------- */ diff --git a/open-vm-tools/lib/include/file.h b/open-vm-tools/lib/include/file.h index 4aba415d0..19eb04c22 100644 --- a/open-vm-tools/lib/include/file.h +++ b/open-vm-tools/lib/include/file.h @@ -229,6 +229,8 @@ int File_MakeTempEx2(ConstUnicode dir, void *createFuncData, Unicode *presult); +Unicode File_MakeSafeTempDir(ConstUnicode prefix); + int64 File_GetModTime(ConstUnicode pathName); char *File_GetModTimeString(ConstUnicode pathName); diff --git a/open-vm-tools/lib/include/vm_basic_defs.h b/open-vm-tools/lib/include/vm_basic_defs.h index 4713a16b1..c2085379a 100644 --- a/open-vm-tools/lib/include/vm_basic_defs.h +++ b/open-vm-tools/lib/include/vm_basic_defs.h @@ -80,6 +80,10 @@ #include "includeCheck.h" #include "vm_basic_types.h" // For INLINE. +#if defined VMKERNEL +#include "vm_assert.h" // For ASSERT_ON_COMPILE. +#endif + /* Checks for FreeBSD, filtering out VMKERNEL. */ #define __IS_FREEBSD__ (!defined(VMKERNEL) && defined(__FreeBSD__)) #define __IS_FREEBSD_VER__(ver) (__IS_FREEBSD__ && __FreeBSD_version >= (ver)) @@ -362,6 +366,23 @@ void *_ReturnAddress(void); #define GetReturnAddress() _ReturnAddress() #elif __GNUC__ #define GetReturnAddress() __builtin_return_address(0) + +#if VMKERNEL +/* + * Using __builtin_frame_address(N) and__builtin_return_address(N) + * with N >= 1 causes crashes for code compiled without frame pointers. + * Use Stackwalk_ReturnAddress(N) instead. Or, to collect a backtrace + * fragment, use STACKWALK_STORE_BACKTRACE(). + */ +#define __builtin_frame_address(N) ({ \ + ASSERT_ON_COMPILE(N == 0); \ + __builtin_frame_address(N); \ + }) +#define __builtin_return_address(N) ({ \ + ASSERT_ON_COMPILE(N == 0); \ + __builtin_return_address(N); \ + }) +#endif #endif diff --git a/open-vm-tools/modules/shared/vmxnet/eth_public.h b/open-vm-tools/modules/shared/vmxnet/eth_public.h index d75a8ae91..f606c9f81 100644 --- a/open-vm-tools/modules/shared/vmxnet/eth_public.h +++ b/open-vm-tools/modules/shared/vmxnet/eth_public.h @@ -1143,7 +1143,7 @@ Eth_GetPayload(const void *frame) static INLINE Bool Eth_IsFrameHeaderComplete(const Eth_Header *eh, - const uint16 len, + const uint32 len, uint16 *ehHdrLen) { uint16 ehLen;