From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:32 +0000 (-0700) Subject: Add constants for macOS os major versions. X-Git-Tag: stable-10.2.0~276 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae05d32a9303f27ff642ab39bb49abc46e3ba78b;p=thirdparty%2Fopen-vm-tools.git Add constants for macOS os major versions. MacOS versions can get a bit confusing because there are two parallel versioning schemes. There is the marketing version (e.g. 10.6, 10.7.5, etc.) which is what everybody uses when discussing the OS but is very hard to get at via code, and there is the kernel version (e.g. 10.0.0, 11.4.2) which is what is returned by POSIX syscalls like uname. The confusion sets in because in comments we tend to use the marketing version, but then the code actually checks for the kernel version. This change adds constants for the marketing version for comparisons with HostInfo_OSVersion(0) (the major version), which makes checking for 10.6 vs 10.7 vs 10.8 etc. much more readable. --- diff --git a/open-vm-tools/lib/file/fileIOPosix.c b/open-vm-tools/lib/file/fileIOPosix.c index d85812af0..73f7888fc 100644 --- a/open-vm-tools/lib/file/fileIOPosix.c +++ b/open-vm-tools/lib/file/fileIOPosix.c @@ -958,10 +958,9 @@ FileIOCreateRetry(FileIODescriptor *file, // OUT: if (!(access & FILEIO_OPEN_SYNC)) { /* - * F_NODIRECT was added in Mac OS 10.7.0 "Lion" which has Darwin - * kernel 11.0.0. + * F_NODIRECT was added in Mac OS 10.7.0 "Lion". */ - if (Hostinfo_OSVersion(0) >= 11) { + if (Hostinfo_OSVersion(0) >= HOSTINFO_OS_VERSION_MACOS_10_7) { error = fcntl(fd, F_NODIRECT, 1); if (error == -1) { ret = FileIOErrno2Result(errno); diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index abba8e3bb..67b09058c 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -79,6 +79,22 @@ Hostinfo_SystemTimerMS(void) return Hostinfo_SystemTimerNS() / 1000000ULL; } +/* + * Apple's kernel major versions are the same as their marketed + * minor versions + 4. (E.g. Marketed 10.8.0 == Kernel 12.0.0) + * These constants simplify this and make code easier to read / understand. + */ +enum { + HOSTINFO_OS_VERSION_MACOS_10_5 = 9, + HOSTINFO_OS_VERSION_MACOS_10_6 = 10, + HOSTINFO_OS_VERSION_MACOS_10_7 = 11, + HOSTINFO_OS_VERSION_MACOS_10_8 = 12, + HOSTINFO_OS_VERSION_MACOS_10_9 = 13, + HOSTINFO_OS_VERSION_MACOS_10_10 = 14, + HOSTINFO_OS_VERSION_MACOS_10_11 = 15, + HOSTINFO_OS_VERSION_MACOS_10_12 = 16, +}; + int Hostinfo_OSVersion(unsigned int i); int Hostinfo_GetSystemBitness(void); const char *Hostinfo_OSVersionString(void);