128 |
|
#ifdef ALLBSD |
129 |
|
nummnt=getmntinfo(&mp , MNT_LOCAL); |
130 |
|
if (nummnt<=0){ |
131 |
+ |
sg_set_error(SG_ERROR_GETMNTINFO, NULL); |
132 |
|
return NULL; |
133 |
|
} |
134 |
|
for(;nummnt--; mp++){ |
137 |
|
|
138 |
|
#if defined(LINUX) || defined(CYGWIN) |
139 |
|
if ((f=setmntent("/etc/mtab", "r" ))==NULL){ |
140 |
+ |
sg_set_error(SG_ERROR_SETMNTENT, NULL); |
141 |
|
return NULL; |
142 |
|
} |
143 |
|
|
151 |
|
|
152 |
|
#ifdef SOLARIS |
153 |
|
if ((f=fopen("/etc/mnttab", "r" ))==NULL){ |
154 |
+ |
sg_set_error(SG_ERROR_OPEN, "/etc/mnttab"); |
155 |
|
return NULL; |
156 |
|
} |
157 |
|
while((getmntent(f, &mp)) == 0){ |
330 |
|
|
331 |
|
size = sizeof(diskcount); |
332 |
|
if (sysctl(mib, MIBSIZE, &diskcount, &size, NULL, 0) < 0) { |
333 |
+ |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT"); |
334 |
|
return NULL; |
335 |
|
} |
336 |
|
|
338 |
|
mib[1] = HW_DISKNAMES; |
339 |
|
|
340 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
341 |
+ |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
342 |
|
return NULL; |
343 |
|
} |
344 |
|
|
348 |
|
} |
349 |
|
|
350 |
|
if (sysctl(mib, MIBSIZE, disknames, &size, NULL, 0) < 0) { |
351 |
+ |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES"); |
352 |
|
return NULL; |
353 |
|
} |
354 |
|
|
367 |
|
#endif |
368 |
|
|
369 |
|
if (sysctl(mib, MIBSIZE, NULL, &size, NULL, 0) < 0) { |
370 |
+ |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
371 |
|
return NULL; |
372 |
|
} |
373 |
|
|
383 |
|
} |
384 |
|
|
385 |
|
if (sysctl(mib, MIBSIZE, stats, &size, NULL, 0) < 0) { |
386 |
+ |
sg_error(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS"); |
387 |
|
return NULL; |
388 |
|
} |
389 |
|
|
443 |
|
stats_init = 1; |
444 |
|
} |
445 |
|
#ifdef FREEBSD5 |
446 |
< |
if ((devstat_getdevs(NULL, &stats)) < 0) return NULL; |
446 |
> |
if ((devstat_getdevs(NULL, &stats)) < 0) { |
447 |
> |
sg_set_error(SG_ERROR_DEVSTAT_GETDEVS, NULL); |
448 |
> |
return NULL; |
449 |
> |
} |
450 |
|
/* Not aware of a get all devices, so i said 999. If we ever |
451 |
|
* find a machine with more than 999 disks, then i'll change |
452 |
|
* this number :) |
453 |
|
*/ |
454 |
< |
if (devstat_selectdevs(&dev_sel, &n_selected, &n_selections, &sel_gen, stats.dinfo->generation, stats.dinfo->devices, stats.dinfo->numdevs, NULL, 0, NULL, 0, DS_SELECT_ONLY, 999, 1) < 0) return NULL; |
454 |
> |
if (devstat_selectdevs(&dev_sel, &n_selected, &n_selections, &sel_gen, stats.dinfo->generation, stats.dinfo->devices, stats.dinfo->numdevs, NULL, 0, NULL, 0, DS_SELECT_ONLY, 999, 1) < 0) { |
455 |
> |
sg_set_error(SG_ERROR_DEVSTAT_SELECTDEVS, NULL); |
456 |
> |
return NULL; |
457 |
> |
} |
458 |
|
#else |
459 |
< |
if ((getdevs(&stats)) < 0) return NULL; |
459 |
> |
if ((getdevs(&stats)) < 0) { |
460 |
> |
sg_set_error(SG_ERROR_DEVSTAT_GETDEVS, NULL); |
461 |
> |
return NULL; |
462 |
> |
} |
463 |
|
/* Not aware of a get all devices, so i said 999. If we ever |
464 |
|
* find a machine with more than 999 disks, then i'll change |
465 |
|
* this number :) |
466 |
|
*/ |
467 |
< |
if (selectdevs(&dev_sel, &n_selected, &n_selections, &sel_gen, stats.dinfo->generation, stats.dinfo->devices, stats.dinfo->numdevs, NULL, 0, NULL, 0, DS_SELECT_ONLY, 999, 1) < 0) return NULL; |
467 |
> |
if (selectdevs(&dev_sel, &n_selected, &n_selections, &sel_gen, stats.dinfo->generation, stats.dinfo->devices, stats.dinfo->numdevs, NULL, 0, NULL, 0, DS_SELECT_ONLY, 999, 1) < 0) { |
468 |
> |
sg_set_error(SG_ERROR_DEVSTAT_SELECTDEVS, NULL); |
469 |
> |
return NULL; |
470 |
> |
} |
471 |
|
#endif |
472 |
|
|
473 |
|
for(counter=0;counter<stats.dinfo->numdevs;counter++){ |
497 |
|
#endif |
498 |
|
if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name); |
499 |
|
if (asprintf((&diskio_stats_ptr->disk_name), "%s%d", dev_ptr->device_name, dev_ptr->unit_number) == -1) { |
500 |
+ |
sg_set_error(SG_ERROR_ASPRINTF, NULL); |
501 |
|
return NULL; |
502 |
|
} |
503 |
|
diskio_stats_ptr->systime=time(NULL); |
509 |
|
#endif |
510 |
|
#ifdef SOLARIS |
511 |
|
if ((kc = kstat_open()) == NULL) { |
512 |
+ |
sg_set_error(SG_ERROR_KSTAT_OPEN, NULL); |
513 |
|
return NULL; |
514 |
|
} |
515 |
|
|
678 |
|
#endif |
679 |
|
|
680 |
|
#ifdef CYGWIN |
681 |
+ |
sg_set_error(SG_ERROR_UNSUPPORTED, "Cygwin"); |
682 |
|
return NULL; |
683 |
|
#endif |
684 |
|
|