From: Oliver Kurth Date: Fri, 29 Sep 2017 19:52:44 +0000 (-0700) Subject: For FreeBSD 11 and later the correct osname is "freeBSD11". X-Git-Tag: 10.1.15~5 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8410d26cb69f48ad8de43704ca2bf0e020fc1b93;p=thirdparty%2Fopen-vm-tools.git For FreeBSD 11 and later the correct osname is "freeBSD11". Without the correct osname, guestInfo ends up with wrong guestId and guestFullName. Adjust the osname based on the FreeBSD release. --- diff --git a/open-vm-tools/lib/include/guest_os.h b/open-vm-tools/lib/include/guest_os.h index d0a2aa472..18fdfe78d 100644 --- a/open-vm-tools/lib/include/guest_os.h +++ b/open-vm-tools/lib/include/guest_os.h @@ -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" diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 0f5507061..6c0ddbd70 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 @@ -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;