]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Thu, 17 Dec 2009 21:42:21 +0000 (13:42 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 17 Dec 2009 21:42:21 +0000 (13:42 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/file/fileIOPosix.c
open-vm-tools/lib/include/fileIO.h

index a8634eddfadb66fc53b6b1143e71f287e326e642..a715d88b8cba53d11bd34fb87327ca19359ad1fb 100644 (file)
  * fallocate() is only supported since the glibc-2.8 and
  * linux kernel-2.6.23. Presently the glibc in our toolchain is 2.3.
  */
-#ifdef __linux__
-   #ifndef SYS_fallocate
-      #ifdef __i386__
+#if defined(__linux__)
+   #if !defined(SYS_fallocate)
+      #if defined(__i386__)
          #define SYS_fallocate 324
       #elif __x86_64__
          #define SYS_fallocate 285
       #endif
    #endif
-   #ifndef FALLOC_FL_KEEP_SIZE
+   #if !defined(FALLOC_FL_KEEP_SIZE)
       #define FALLOC_FL_KEEP_SIZE 1
    #endif
 #endif
@@ -759,7 +759,21 @@ FileIO_Create(FileIODescriptor *file,    // OUT:
    ASSERT(file->lockToken == NULL);
    ASSERT_ON_COMPILE(FILEIO_ERROR_LAST < 16); /* See comment in fileIO.h */
 
-#if !defined(__FreeBSD__) && !defined(sun) && !defined(N_PLAT_NLM)
+#if defined(__APPLE__)
+   /*
+    * O_EXLOCK, O_SHLOCK behavior tested on Mac OS X Server 10.6, kernel 10.0.0.
+    *
+    * |                      | Block devices      | Regular files
+    * |----------------------|--------------------|----------------
+    * | Locking behavior     | mandatory          | advisory
+    * |                      |                    |
+    * | If O_NONBLOCK absent | open doesn't block | open blocks
+    * |                      | on conflicts       | on conflicts
+    */
+   if (access & FILEIO_OPEN_EXCLUSIVE_LOCK_MACOS) {
+      flags |= O_EXLOCK;
+   }
+#elif !defined(__FreeBSD__) && !defined(sun) && !defined(N_PLAT_NLM)
    /*
     * If FILEIO_OPEN_EXCLUSIVE_LOCK or FILEIO_OPEN_MULTIWRITER_LOCK or
     * (FILEIO_OPEN_ACCESS_READ | FILEIO_OPEN_LOCKED) are passed, and we are
@@ -768,7 +782,7 @@ FileIO_Create(FileIODescriptor *file,    // OUT:
     * File_OnVMFS() unless really necessary.
     *
     * If the above conditions are met FILEIO_OPEN_LOCKED, is filtered out --
-    * vmfs will be handling the locking, so there is no need to create 
+    * vmfs will be handling the locking, so there is no need to create
     * lockfiles.
     */
    if ((access & (FILEIO_OPEN_EXCLUSIVE_LOCK |
@@ -1920,7 +1934,7 @@ FileIO_SetAllocSize(const FileIODescriptor *fd,  // IN
 #if defined(__APPLE__) || defined(__linux__)
    uint64 curSize;
    uint64 preallocLen;
-#ifdef __APPLE__
+#if defined(__APPLE__)
    fstore_t prealloc;
 #endif
 
@@ -1931,7 +1945,7 @@ FileIO_SetAllocSize(const FileIODescriptor *fd,  // IN
    }
    preallocLen = size - curSize;
 
-#ifdef __APPLE__
+#if defined(__APPLE__)
    prealloc.fst_flags = 0;
    prealloc.fst_posmode = F_PEOFPOSMODE;
    prealloc.fst_offset = 0;
index e3a67eb3fe08784d21943504aab4d7eecc1855b2..a83135b502d76bac3511603151305aa8874f758d 100644 (file)
@@ -169,6 +169,20 @@ typedef enum {
  * Flag the file as not to be backed up by Time Machine on Mac OS X.
  */
 #define FILEIO_OPEN_NO_TIME_MACHINE      (1 << 15)
+/*
+ * Valid only for MacOS. It eventually results into O_EXLOCK flag passed to open
+ * system call.
+ *
+ * O_EXLOCK, O_SHLOCK behavior is tested on Mac OS X Server 10.6, kernel 10.0.0.
+ *
+ * |                      | Block devices      | Regular files
+ * |----------------------|--------------------|----------------
+ * | Locking behavior     | mandatory          | advisory
+ * |                      |                    |
+ * | If O_NONBLOCK absent | open doesn't block | open blocks
+ * |                      | on conflicts       | on conflicts
+ */
+#define FILEIO_OPEN_EXCLUSIVE_LOCK_MACOS (1 << 16)
 
 /*
  * Flag passed to open() to not attempt to get the lun attributes as part of