37 |
|
#include <sys/mnttab.h> |
38 |
|
#include <sys/statvfs.h> |
39 |
|
#include <kstat.h> |
40 |
< |
#define VALID_FS_TYPES {"ufs", "tmpfs"} |
40 |
> |
#define VALID_FS_TYPES {"ufs", "tmpfs", "vxfs"} |
41 |
|
#endif |
42 |
|
|
43 |
|
#if defined(LINUX) || defined(CYGWIN) |
122 |
|
#endif |
123 |
|
#ifdef ALLBSD |
124 |
|
int nummnt; |
125 |
+ |
#ifdef HAVE_STATVFS |
126 |
+ |
struct statvfs *mp; |
127 |
+ |
#else |
128 |
|
struct statfs *mp; |
129 |
|
#endif |
130 |
+ |
#endif |
131 |
|
|
132 |
|
#ifdef ALLBSD |
133 |
|
nummnt=getmntinfo(&mp , MNT_LOCAL); |
257 |
|
|
258 |
|
} |
259 |
|
|
260 |
+ |
int sg_fs_compare_device_name(const void *va, const void *vb) { |
261 |
+ |
const sg_fs_stats *a = (const sg_fs_stats *)va; |
262 |
+ |
const sg_fs_stats *b = (const sg_fs_stats *)vb; |
263 |
+ |
|
264 |
+ |
return strcmp(a->device_name, b->device_name); |
265 |
+ |
} |
266 |
+ |
|
267 |
+ |
int sg_fs_compare_mnt_point(const void *va, const void *vb) { |
268 |
+ |
const sg_fs_stats *a = (const sg_fs_stats *)va; |
269 |
+ |
const sg_fs_stats *b = (const sg_fs_stats *)vb; |
270 |
+ |
|
271 |
+ |
return strcmp(a->mnt_point, b->mnt_point); |
272 |
+ |
} |
273 |
+ |
|
274 |
|
static void diskio_stat_init(sg_disk_io_stats *d) { |
275 |
|
d->disk_name = NULL; |
276 |
|
} |
348 |
|
|
349 |
|
size = sizeof(diskcount); |
350 |
|
if (sysctl(mib, MIBSIZE, &diskcount, &size, NULL, 0) < 0) { |
351 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT"); |
351 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT"); |
352 |
|
return NULL; |
353 |
|
} |
354 |
|
|
356 |
|
mib[1] = HW_DISKNAMES; |
357 |
|
|
358 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
359 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
359 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
360 |
|
return NULL; |
361 |
|
} |
362 |
|
|
366 |
|
} |
367 |
|
|
368 |
|
if (sysctl(mib, MIBSIZE, disknames, &size, NULL, 0) < 0) { |
369 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
369 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
370 |
|
return NULL; |
371 |
|
} |
372 |
|
|
385 |
|
#endif |
386 |
|
|
387 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
388 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
388 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
389 |
|
return NULL; |
390 |
|
} |
391 |
|
|
401 |
|
} |
402 |
|
|
403 |
|
if (sysctl(mib, MIBSIZE, stats, &size, NULL, 0) < 0) { |
404 |
< |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
404 |
> |
sg_set_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
405 |
|
return NULL; |
406 |
|
} |
407 |
|
|
414 |
|
rbytes = stats[i].dk_rbytes; |
415 |
|
wbytes = stats[i].dk_wbytes; |
416 |
|
#else |
417 |
< |
/* Before 1.7, NetBSD merged reads and writes. */ |
417 |
> |
/* Before 2.0, NetBSD merged reads and writes. */ |
418 |
|
rbytes = wbytes = stats[i].dk_bytes; |
419 |
|
#endif |
420 |
|
#else |
421 |
+ |
#ifdef HAVE_DS_RBYTES |
422 |
+ |
rbytes = stats[i].ds_rbytes; |
423 |
+ |
wbytes = stats[i].ds_wbytes; |
424 |
+ |
#else |
425 |
+ |
/* Before 3.5, OpenBSD merged reads and writes */ |
426 |
|
rbytes = wbytes = stats[i].ds_bytes; |
427 |
|
#endif |
428 |
+ |
#endif |
429 |
|
|
430 |
|
/* Don't keep stats for disks that have never been used. */ |
431 |
|
if (rbytes == 0 && wbytes == 0) { |
773 |
|
|
774 |
|
*entries = diff_count; |
775 |
|
return diff; |
776 |
+ |
} |
777 |
+ |
|
778 |
+ |
int sg_disk_io_compare_name(const void *va, const void *vb) { |
779 |
+ |
const sg_disk_io_stats *a = (const sg_disk_io_stats *)va; |
780 |
+ |
const sg_disk_io_stats *b = (const sg_disk_io_stats *)vb; |
781 |
+ |
|
782 |
+ |
return strcmp(a->disk_name, b->disk_name); |
783 |
|
} |
784 |
|
|