]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes to common source files not applicable to open-vm-tools.
authorJohn Wolfe <jwolfe@vmware.com>
Mon, 9 Nov 2020 20:29:03 +0000 (12:29 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Mon, 9 Nov 2020 20:29:03 +0000 (12:29 -0800)
open-vm-tools/lib/include/hostinfo.h
open-vm-tools/lib/misc/hostinfoPosix.c

index 40552d0f98c8c0bc95e4c9d71c66a2464596d9bf..6f7873885f9f74e62a340a95fbde714fe1724431 100644 (file)
@@ -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)
index 6ac15412e7890babaedba444435dff15294fc1df..cf9d95b49d0f3fb762fc13a1cca069eabea0d9bb 100644 (file)
@@ -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__ */