From: VMware, Inc <> Date: Tue, 28 Jun 2011 19:48:49 +0000 (-0700) Subject: Changes in shared code that don't affect open-vm-tools functionality. X-Git-Tag: 2011.06.27-437995~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=718a3254130eab3e78198472bf54097d3f3baaa7;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 e93ce46f2..0d1936b40 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -2291,7 +2291,7 @@ FileIO_DescriptorToStream(FileIODescriptor *fdesc, // IN: * * Returns TRUE if the host OS is new enough to support F_PREALLOCATE * without data loss bugs. On OSX, this has been verified fixed - * on 10.6 build with kern.osreleasae 10.0.0d6. + * on 10.6 build with kern.osrelease 10.0.0d6. * * Results: * TRUE if the current host OS is new enough. @@ -2306,6 +2306,8 @@ FileIO_DescriptorToStream(FileIODescriptor *fdesc, // IN: static Bool HostSupportsPrealloc(void) { + static Atomic_uint32 supported = { 0 }; + enum { PREALLOC_UNKNOWN = 0, PREALLOC_YES, PREALLOC_NO } val; char curRel[32]; char type; unsigned static const int req[] = { 10, 0, 0, 6 }; @@ -2314,6 +2316,11 @@ HostSupportsPrealloc(void) size_t len = sizeof(curRel); Bool ret = FALSE; + val = Atomic_Read(&supported); + if (val != PREALLOC_UNKNOWN) { + return val == PREALLOC_YES; + } + if (sysctlbyname("kern.osrelease", (void *) &curRel, &len, NULL, 0) == -1) { goto exit; } @@ -2363,10 +2370,12 @@ HostSupportsPrealloc(void) exit: if (!ret && filePosixOptions.initialized && filePosixOptions.aioNumThreads == 1) { - ret =TRUE; + ret = TRUE; } - return ret; + Atomic_Write(&supported, ret ? PREALLOC_YES : PREALLOC_NO); + + return ret; } #else