344 |
|
|
345 |
|
size = sizeof(diskcount); |
346 |
|
if (sysctl(mib, MIBSIZE, &diskcount, &size, NULL, 0) < 0) { |
347 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT"); |
347 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT"); |
348 |
|
return NULL; |
349 |
|
} |
350 |
|
|
352 |
|
mib[1] = HW_DISKNAMES; |
353 |
|
|
354 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
355 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
355 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
356 |
|
return NULL; |
357 |
|
} |
358 |
|
|
362 |
|
} |
363 |
|
|
364 |
|
if (sysctl(mib, MIBSIZE, disknames, &size, NULL, 0) < 0) { |
365 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
365 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
366 |
|
return NULL; |
367 |
|
} |
368 |
|
|
381 |
|
#endif |
382 |
|
|
383 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
384 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
384 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
385 |
|
return NULL; |
386 |
|
} |
387 |
|
|
397 |
|
} |
398 |
|
|
399 |
|
if (sysctl(mib, MIBSIZE, stats, &size, NULL, 0) < 0) { |
400 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
400 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
401 |
|
return NULL; |
402 |
|
} |
403 |
|
|
410 |
|
rbytes = stats[i].dk_rbytes; |
411 |
|
wbytes = stats[i].dk_wbytes; |
412 |
|
#else |
413 |
< |
/* Before 1.7, NetBSD merged reads and writes. */ |
413 |
> |
/* Before 2.0, NetBSD merged reads and writes. */ |
414 |
|
rbytes = wbytes = stats[i].dk_bytes; |
415 |
|
#endif |
416 |
|
#else |
417 |
+ |
#ifdef HAVE_DS_RBYTES |
418 |
+ |
rbytes = stats[i].ds_rbytes; |
419 |
+ |
wbytes = stats[i].ds_wbytes; |
420 |
+ |
#else |
421 |
+ |
/* Before 3.5, OpenBSD merged reads and writes */ |
422 |
|
rbytes = wbytes = stats[i].ds_bytes; |
423 |
+ |
#endif |
424 |
|
#endif |
425 |
|
|
426 |
|
/* Don't keep stats for disks that have never been used. */ |