From: John Wolfe Date: Mon, 9 Nov 2020 20:29:03 +0000 (-0800) Subject: Changes to common source files not applicable to open-vm-tools. X-Git-Tag: stable-11.3.0~270 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d35ef560247e7f0bd798ae45646eeaee38d3a12b;p=thirdparty%2Fopen-vm-tools.git Changes to common source files not applicable to open-vm-tools. --- diff --git a/open-vm-tools/lib/include/hostinfo.h b/open-vm-tools/lib/include/hostinfo.h index 40552d0f9..6f7873885 100644 --- a/open-vm-tools/lib/include/hostinfo.h +++ b/open-vm-tools/lib/include/hostinfo.h @@ -258,6 +258,7 @@ Bool Hostinfo_GetLoadAverage(uint32 *l); #ifdef __APPLE__ size_t Hostinfo_GetKernelZoneElemSize(char const *name); char *Hostinfo_GetHardwareModel(void); +int Hostinfo_ProcessIsRosetta(void); #endif #if defined(__cplusplus) diff --git a/open-vm-tools/lib/misc/hostinfoPosix.c b/open-vm-tools/lib/misc/hostinfoPosix.c index 6ac15412e..cf9d95b49 100644 --- a/open-vm-tools/lib/misc/hostinfoPosix.c +++ b/open-vm-tools/lib/misc/hostinfoPosix.c @@ -3722,6 +3722,35 @@ Hostinfo_GetHardwareModel(void) { return HostinfoGetSysctlStringAlloc("hw.model"); } + + +/* + *---------------------------------------------------------------------- + * + * Hostinfo_ProcessIsRosetta -- + * + * Checks if the current process is running as a translated binary. + * + * Results: + * 0 for a native process, 1 for a translated process, + * and -1 when an error occurs. + * + * Side effects: + * None + *---------------------------------------------------------------------- + */ + +int +Hostinfo_ProcessIsRosetta(void) +{ + int ret = 0; + size_t size = sizeof ret; + + if (sysctlbyname("sysctl.proc_translated", &ret, &size, NULL, 0) == -1) { + return errno == ENOENT ? 0 : -1; + } + return ret; +} #endif /* __APPLE__ */