From 9b3532b3eab97b7f75847afa88f09e2254e252fe Mon Sep 17 00:00:00 2001 From: Charlie Fenton Date: Thu, 18 Nov 2010 10:40:11 +0000 Subject: [PATCH] client: Add support to detect VirtualBox VM software on Mac svn path=/trunk/boinc/; revision=22705 --- checkin_notes | 6 ++++++ client/hostinfo_unix.cpp | 44 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/checkin_notes b/checkin_notes index 3d213bee45..7c7e0c56ff 100644 --- a/checkin_notes +++ b/checkin_notes @@ -8151,3 +8151,9 @@ David 17 Nov 2010 hostinfo.cpp,h sched/ sched_types.cpp + +Charlie 18 Nov 2010 + - client: Add support to detect VirtualBox VM software on Mac. + + client/ + hostinfo_unix.cpp diff --git a/client/hostinfo_unix.cpp b/client/hostinfo_unix.cpp index 19e7c5fc50..269984bb16 100644 --- a/client/hostinfo_unix.cpp +++ b/client/hostinfo_unix.cpp @@ -1094,6 +1094,46 @@ int GetMaxCPUTemperature() { #endif +// see if Virtualbox is installed +// +int HOST_INFO::get_virtualbox_version() { + FSRef theFSRef; + OSStatus status = noErr; + char path[MAXPATHLEN]; + char cmd [MAXPATHLEN+35]; + char *newlinePtr; + FILE* fd; + + // First try to locate the VirtualBox application by Bundle ID and Creator Code + status = LSFindApplicationForInfo('VBOX', CFSTR("org.virtualbox.app.VirtualBox"), + NULL, &theFSRef, NULL + ); + if (status == noErr) { + status = FSRefMakePath(&theFSRef, (unsigned char *)path, sizeof(path)); + } + // If that failed, try its default location + if (status != noErr) { + strcpy(path, "/Applications/VirtualBox.app"); + } + + if (boinc_file_exists(path)) { + safe_strcpy(cmd, "defaults read "); + safe_strcat(cmd, path); + safe_strcat(cmd, "/Contents/Info CFBundleShortVersionString"); + fd = popen(cmd, "r"); + if (fd) { + fgets(virtualbox_version, sizeof(virtualbox_version), fd); + newlinePtr = strchr(virtualbox_version, '\n'); + if (newlinePtr) *newlinePtr = '\0'; + newlinePtr = strchr(virtualbox_version, '\r'); + if (newlinePtr) *newlinePtr = '\0'; + pclose(fd); + } + } + + return 0; +} + #endif // __APPLE__ // Rules: @@ -1103,6 +1143,10 @@ int GetMaxCPUTemperature() { int HOST_INFO::get_host_info() { get_filesystem_info(d_total, d_free); +#if defined( __APPLE__) + get_virtualbox_version(); +#endif + ///////////// p_vendor, p_model, p_features ///////////////// #if LINUX_LIKE_SYSTEM parse_cpuinfo_linux(*this);