]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Wed, 18 Sep 2013 03:18:23 +0000 (20:18 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:01:54 +0000 (22:01 -0700)
. lib/file - add File_MakeSafeTempDir()
. changes in shared code that don't affect open-vm-tools functionality

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/file/fileTemp.c
open-vm-tools/lib/include/file.h
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/modules/shared/vmxnet/eth_public.h

index f45628779b70a3c812a8f07d3776f2fdca610279..c0922e5b3e66f0d89f5ae975198270aad37228b1 100644 (file)
@@ -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.
+ *
  *----------------------------------------------------------------------
  */
 
index 4aba415d0ef02ad03eb7acc64eed74bb5eb10e32..19eb04c22e1b018d34fdaa9f97985e2cdd9d5da4 100644 (file)
@@ -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);
index 4713a16b12db212f3c09c487944da781d3017f67..c2085379a6d88ba1f9fcd77c0fdc59da92250885 100644 (file)
 #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
 
 
index d75a8ae91bd087f44edaa31ab98d7d0d7c88007c..f606c9f81f3418e39f202a88deda675d9e8513fd 100644 (file)
@@ -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;