]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
For FreeBSD 11 and later the correct osname is "freeBSD11".
authorOliver Kurth <okurth@vmware.com>
Fri, 29 Sep 2017 19:52:44 +0000 (12:52 -0700)
committerOliver Kurth <okurth@vmware.com>
Fri, 29 Sep 2017 19:52:44 +0000 (12:52 -0700)
Without the correct osname, guestInfo ends up with wrong guestId
and guestFullName.  Adjust the osname based on the FreeBSD release.

open-vm-tools/lib/include/guest_os.h
open-vm-tools/lib/misc/hostinfoPosix.c

index d0a2aa472f843ef29e88da4dd1eb173d693df18a..18fdfe78df9683f7bfa0ae48e0d3c40e06c1b6ac 100644 (file)
@@ -493,7 +493,8 @@ Bool Gos_InSetArray(uint32 gos, const uint32 *set);
 #define STR_OS_WIN_64_BIT_EXTENSION ", 64-bit"
 
 /* FreeBSD */
-#define STR_OS_FREEBSD "freeBSD"
+#define STR_OS_FREEBSD   "freeBSD"
+#define STR_OS_FREEBSD11 "freeBSD11"
 
 /* Solaris */
 #define STR_OS_SOLARIS "solaris"
index 0f5507061e2e0cd32ede0ec2a8ea85d2248c630d..6c0ddbd70cba2e58e0cf8af814b4b5af3e7734f2 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2017 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -1080,28 +1080,32 @@ HostinfoOSData(void)
 
       Str_Strcpy(osName, distroShort, sizeof osName);
    } else if (strstr(osNameFull, "FreeBSD")) {
-      size_t nameLen = sizeof STR_OS_FREEBSD - 1;
-      size_t releaseLen = 0;
-      char *dashPtr;
+      char distroShort[DISTRO_BUF_SIZE];
+      int majorVersion;
 
       /*
-       * FreeBSD releases report their version as "x.y-RELEASE". We'll be
-       * naive look for the first dash, and use everything before it as the
-       * version number.
+       * FreeBSD releases report their version as "x.y-RELEASE".
        */
 
-      dashPtr = Str_Strchr(buf.release, '-');
-      if (dashPtr != NULL) {
-         releaseLen = dashPtr - buf.release;
+      majorVersion = Hostinfo_OSVersion(0);
+
+      /*
+       * FreeBSD 11 and later are identified using
+       * a different guestId.
+       */
+      if (majorVersion >= 11) {
+         Str_Strcpy(distroShort, STR_OS_FREEBSD11, sizeof distroShort);
+      } else {
+         Str_Strcpy(distroShort, STR_OS_FREEBSD, sizeof distroShort);
       }
 
-      if (nameLen + releaseLen + 1 > sizeof osName) {
+      if (strlen(distroShort) + 1 > sizeof osName) {
          Warning("%s: Error: buffer too small\n", __FUNCTION__);
 
          return FALSE;
       }
 
-      Str_Strcpy(osName, STR_OS_FREEBSD, sizeof osName);
+      Str_Strcpy(osName, distroShort, sizeof osName);
    } else if (strstr(osNameFull, "SunOS")) {
       size_t nameLen = sizeof STR_OS_SOLARIS - 1;
       size_t releaseLen = 0;