+ char *hwproduct, *hwmodel;
+ size_t hwproduct_size, hwmodel_size;
+ int hwproduct_name[2], hwmodel_name[2];
+
+ hwproduct_name[0] = CTL_HW;
+ hwproduct_name[1] = HW_PRODUCT;
+
+ hwmodel_name[0] = CTL_HW;
+ hwmodel_name[1] = HW_MODEL;
+
+ /* pass NULL buffer to check size first, then pass hw to be filled according to freshly-set hw_size */
+ if(sysctl(&hwproduct_name, 2, NULL, &hwproduct_size, NULL, 0) || sysctl(&hwproduct_name, 2, hwproduct, &hwproduct_size, NULL, 0))
+ return "desktop"; /* TODO error properly here */
+
+ if(sysctl(&hwmodel_name, 2, NULL, &hwmodel_size, NULL, 0) || sysctl(&hwmodel_name, 2, hwmodel, &hwmodel_size, NULL, 0))
+ return "desktop"; /* TODO error properly here */
+
+ if(test_against_known_vm_strings(hwproduct) || test_against_known_vm_strings(hwmodel))
+ return "vm"; /*TODO differentiate between VMs (hardware virt, seperate kernel) and containers (paravirt, shared kernel)
+
+ /* TODO: test for laptop, if not, dmidecode for desktop vs. server
+ * probably move this code to vm test func and set a global after running it early, once */
+
+ return "desktop";