From: VMware, Inc <> Date: Thu, 17 Dec 2009 21:42:21 +0000 (-0800) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2009.12.16-217847~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c0c78f3fd573df06d92fd292bd2e77d5b400819c;p=thirdparty%2Fopen-vm-tools.git Changes in shared code that don't affect open-vm-tools functionality. Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c index a8634eddf..a715d88b8 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -104,15 +104,15 @@ * 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; diff --git a/open-vm-tools/lib/include/fileIO.h b/open-vm-tools/lib/include/fileIO.h index e3a67eb3f..a83135b50 100644 --- a/open-vm-tools/lib/include/fileIO.h +++ b/open-vm-tools/lib/include/fileIO.h @@ -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