int refresh_disks(struct diskstats *stats, pmdaIndom *indom) { io_registry_entry_t drive; CFMutableDictionaryRef match; int i, status; static int inited = 0; static mach_port_t mach_master_port; static io_iterator_t mach_device_list; if (!inited) { /* Get ports and services for device statistics. */ if (IOMasterPort(bootstrap_port, &mach_master_port)) { fprintf(stderr, "%s: IOMasterPort error\n", __FUNCTION__); return -oserror(); } memset(stats, 0, sizeof(struct diskstats)); inited = 1; } /* Get an interator for IOMedia objects (drives). */ match = IOServiceMatching("IOMedia"); CFDictionaryAddValue(match, CFSTR(kIOMediaWholeKey), kCFBooleanTrue); status = IOServiceGetMatchingServices(mach_master_port, match, &mach_device_list); if (status != KERN_SUCCESS) { fprintf(stderr, "%s: IOServiceGetMatchingServices error\n", __FUNCTION__); return -oserror(); } indom->it_numinst = 0; clear_disk_totals(stats); for (i = 0; (drive = IOIteratorNext(mach_device_list)) != 0; i++) { status = update_disk(stats, drive, i); if (status) break; IOObjectRelease(drive); } IOIteratorReset(mach_device_list); if (!status) status = update_disk_indom(stats, i, indom); return status; }
void update_status() { #ifdef DEBUG char buffer[256]; sprintf(buffer, "Update Status: draw Memory %s", sbar_status_symbols[DrawMemory].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Battery %s", sbar_status_symbols[DrawBattery].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Uptime %s", sbar_status_symbols[DrawUptime].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); sprintf(buffer, "Update Status: draw Termal %s", sbar_status_symbols[DrawTermal].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #ifdef NF310_A01 sprintf(buffer, "Update Status: draw Backlight %s", sbar_status_symbols[DrawBacklight].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif sprintf(buffer, "Update Status: draw Net %s", sbar_status_symbols[DrawNet].active ? "yes" : "no"); log_str(buffer, LOG_DEBUG); #endif if(sbar_status_symbols[DrawMemory].active) { get_memory(); #ifdef DEBUG log_str("Sucessfully Updated Memory", LOG_DEBUG); #endif } if(sbar_status_symbols[DrawBattery].active) { check_battery(); #ifdef DEBUG log_str("Sucessfully Updated Battery", LOG_DEBUG); #endif } cpu_usage(); #ifdef DEBUG log_str("Sucessfully Updated CPU", LOG_DEBUG); #endif update_date(); #ifdef DEBUG log_str("Sucessfully Updated Date", LOG_DEBUG); #endif if(sbar_status_symbols[DrawUptime].active) { update_uptime(); #ifdef DEBUG log_str("Sucessfully Updated Uptime", LOG_DEBUG); #endif } if(sbar_status_symbols[DrawTermal].active) { get_thermal(); #ifdef DEBUG log_str("Sucessfully Updated Termal", LOG_DEBUG); #endif } #ifdef NF310_A01 if(sbar_status_symbols[DrawBacklight].active) { update_backlight(); #ifdef DEBUG log_str("Sucessfully Updated Backlight", LOG_DEBUG); #endif } #endif if(sbar_status_symbols[DrawNet].active) { update_net(); #ifdef DEBUG log_str("Sucessfully Updated Net", LOG_DEBUG); #endif } update_disk(); #ifdef DEBUG log_str("Sucessfully Updated Disk", LOG_DEBUG); #endif }