static void __cache_obtain_info(Processor *processor, gint processor_number) { ProcessorCache *cache; gchar *endpoint, *entry, *index; gint i; endpoint = g_strdup_printf("/sys/devices/system/cpu/cpu%d/cache", processor_number); for (i = 0; ; i++) { cache = g_new0(ProcessorCache, 1); index = g_strdup_printf("index%d/", i); entry = g_strconcat(index, "type", NULL); cache->type = h_sysfs_read_string(endpoint, entry); g_free(entry); if (!cache->type) { g_free(cache); g_free(index); goto fail; } entry = g_strconcat(index, "level", NULL); cache->level = h_sysfs_read_int(endpoint, entry); g_free(entry); entry = g_strconcat(index, "number_of_sets", NULL); cache->number_of_sets = h_sysfs_read_int(endpoint, entry); g_free(entry); entry = g_strconcat(index, "physical_line_partition", NULL); cache->physical_line_partition = h_sysfs_read_int(endpoint, entry); g_free(entry); entry = g_strconcat(index, "size", NULL); cache->size = h_sysfs_read_int(endpoint, entry); g_free(entry); entry = g_strconcat(index, "ways_of_associativity", NULL); cache->ways_of_associativity = h_sysfs_read_int(endpoint, entry); g_free(entry); g_free(index); processor->cache = g_slist_append(processor->cache, cache); } fail: g_free(endpoint); }
void __scan_usb_sysfs_add_device(gchar * endpoint, int n) { gchar *manufacturer, *product, *mxpwr, *tmp, *strhash; gint bus, classid, vendor, prodid; gfloat version, speed; classid = h_sysfs_read_int(endpoint, "bDeviceClass"); vendor = h_sysfs_read_int(endpoint, "idVendor"); prodid = h_sysfs_read_int(endpoint, "idProduct"); bus = h_sysfs_read_int(endpoint, "busnum"); speed = h_sysfs_read_float(endpoint, "speed"); version = h_sysfs_read_float(endpoint, "version"); if (!(mxpwr = h_sysfs_read_string(endpoint, "bMaxPower"))) { mxpwr = g_strdup("0 mA"); } if (!(manufacturer = h_sysfs_read_string(endpoint, "manufacturer"))) { manufacturer = g_strdup("Unknown"); } if (!(product = h_sysfs_read_string(endpoint, "product"))) { if (classid == 9) { product = g_strdup_printf("USB %.2f Hub", version); } else { product = g_strdup_printf("Unknown USB %.2f Device (class %d)", version, classid); } } const gchar *url = vendor_get_url(manufacturer); if (url) { tmp = g_strdup_printf("%s (%s)", vendor_get_name(manufacturer), url); g_free(manufacturer); manufacturer = tmp; } tmp = g_strdup_printf("USB%d", n); usb_list = h_strdup_cprintf("$%s$%s=\n", usb_list, tmp, product); strhash = g_strdup_printf("[Device Information]\n" "Product=%s\n" "Manufacturer=%s\n" "Speed=%.2fMbit/s\n" "Max Current=%s\n" "[Misc]\n" "USB Version=%.2f\n" "Class=0x%x\n" "Vendor=0x%x\n" "Product ID=0x%x\n" "Bus=%d\n", product, manufacturer, speed, mxpwr, version, classid, vendor, prodid, bus); moreinfo_add_with_prefix("DEV", tmp, strhash); g_free(tmp); g_free(manufacturer); g_free(product); g_free(mxpwr); }