]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Publish Mac OS's short name in sync with VMX value.
authorVMware, Inc <>
Tue, 29 Mar 2011 18:43:13 +0000 (11:43 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Tue, 29 Mar 2011 18:43:13 +0000 (11:43 -0700)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/include/guest_os.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 7902d734f028ea4992679c8cc5b04351d620e5ea..24d4ec24f879e894315351f1a88293e8f12c91be 100644 (file)
@@ -433,6 +433,9 @@ typedef enum GuestOSFamilyType {
 /* Solaris */
 #define STR_OS_SOLARIS "solaris"
 
+/* Mac OS */
+#define STR_OS_MACOS "darwin"
+
 /* All */
 #define STR_OS_64BIT_SUFFIX "-64"
 #define STR_OS_64BIT_SUFFIX_FULL " (64 bit)"
index a3c6aaac8e2bdaa56396ced35d50712ce4ae54ec..12ac25ca8e262a6af3041b72af159ab017cabd24 100644 (file)
@@ -861,6 +861,7 @@ HostinfoOSData(void)
        * drive as a side-effect. So use "system_profiler SPSoftwareDataType"
        * instead.
        */
+      SInt32 major;
       char *sysname = HostinfoGetCmdOutput(
                          "/usr/sbin/system_profiler SPSoftwareDataType"
                       " | /usr/bin/grep 'System Version:'"
@@ -877,6 +878,23 @@ HostinfoOSData(void)
          Log("%s: Failed to get output of system_profiler.\n", __FUNCTION__);
          /* Fall back to returning the original osNameFull. */
       }
+
+      if (Gestalt(gestaltSystemVersionMajor, &major) == 0) {
+         /*
+          * XXX: some places in the code refer to Mac OS X Lion (10.7?)
+          * as "darwin11", which is not what this code is doing. Once it's
+          * released and we support it, this code may need some tweaking.
+          */
+         Str_Snprintf(osName, sizeof osName, "%s%d", STR_OS_MACOS, (int) major);
+      } else if (Gestalt(gestaltSystemVersion, &major) == 0) {
+         /* Pre 10.3 Mac OS doesn't have gestaltSystemVersionMajor. */
+         NOT_TESTED();
+         major = (major & 0xFF00) >> 8;
+         Str_Snprintf(osName, sizeof osName, "%s%x", STR_OS_MACOS, (int) major);
+      } else {
+         Log("Call to Gestalt() failed!\n");
+         Str_Snprintf(osName, sizeof osName, "%s", STR_OS_MACOS);
+      }
    }
 #else
    // XXX Use compile-time instead of run-time checks for these as well.