diff --git a/checkin_notes b/checkin_notes index c8769cb035..1f7eed0b47 100644 --- a/checkin_notes +++ b/checkin_notes @@ -7936,3 +7936,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);