void fetchiostat(void) { struct devinfo *tmp_dinfo; if (kinfo_get_sched_cputime(&cp_time)) err(1, "kinfo_get_sched_cputime"); tmp_dinfo = last.dinfo; last.dinfo = cur.dinfo; cur.dinfo = tmp_dinfo; last.busy_time = cur.busy_time; /* * Here what we want to do is refresh our device stats. * getdevs() returns 1 when the device list has changed. * If the device list has changed, we want to go through * the selection process again, in case a device that we * were previously displaying has gone away. */ switch (getdevs(&cur)) { case -1: errx(1, "%s", devstat_errbuf); break; case 1: cmdiostat("refresh", NULL); break; default: break; } num_devices = cur.dinfo->numdevs; generation = cur.dinfo->generation; }
void fetchiostat(void) { struct devinfo *tmp_dinfo; size_t len; len = sizeof(cur.cp_time); if (sysctlbyname("kern.cp_time", &cur.cp_time, &len, NULL, 0) || len != sizeof(cur.cp_time)) { perror("kern.cp_time"); exit (1); } tmp_dinfo = last.dinfo; last.dinfo = cur.dinfo; cur.dinfo = tmp_dinfo; last.snap_time = cur.snap_time; /* * Here what we want to do is refresh our device stats. * getdevs() returns 1 when the device list has changed. * If the device list has changed, we want to go through * the selection process again, in case a device that we * were previously displaying has gone away. */ switch (devstat_getdevs(NULL, &cur)) { case -1: errx(1, "%s", devstat_errbuf); break; case 1: cmdiostat("refresh", NULL); break; default: break; } num_devices = cur.dinfo->numdevs; generation = cur.dinfo->generation; }