From: Oliver Kurth Date: Fri, 15 Sep 2017 18:23:51 +0000 (-0700) Subject: Use correct osname for FreeBSD 11. X-Git-Tag: stable-10.2.0~100 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=eecfdd625b3e134830a7c012fc8aadda36bfd4da;p=thirdparty%2Fopen-vm-tools.git Use correct osname for FreeBSD 11. For FreeBSD 11 and later the correct osname is "freeBSD11". Without the correct osname, guestInfo ends up with the wrong guestId and guestFullName. Also cleaned up some unused code. --- diff --git a/open-vm-tools/lib/include/guest_os.h b/open-vm-tools/lib/include/guest_os.h index 34e520212..9028c0d6d 100644 --- a/open-vm-tools/lib/include/guest_os.h +++ b/open-vm-tools/lib/include/guest_os.h @@ -505,7 +505,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" diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index d1c36d613..60ec0aa9b 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -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 @@ -1079,28 +1079,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;