* 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
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
* 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 |
#if defined(__APPLE__) || defined(__linux__)
uint64 curSize;
uint64 preallocLen;
-#ifdef __APPLE__
+#if defined(__APPLE__)
fstore_t prealloc;
#endif
}
preallocLen = size - curSize;
-#ifdef __APPLE__
+#if defined(__APPLE__)
prealloc.fst_flags = 0;
prealloc.fst_posmode = F_PEOFPOSMODE;
prealloc.fst_offset = 0;
* 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