ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/libstatgrab/src/libstatgrab/disk_stats.c
(Generate patch)

Comparing projects/libstatgrab/src/libstatgrab/disk_stats.c (file contents):
Revision 1.65 by tdb, Wed Apr 7 14:53:40 2004 UTC vs.
Revision 1.66 by tdb, Wed Apr 7 19:26:16 2004 UTC

# Line 128 | Line 128 | sg_fs_stats *sg_get_fs_stats(int *entries){
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++){
# Line 136 | Line 137 | sg_fs_stats *sg_get_fs_stats(int *entries){
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  
# Line 149 | Line 151 | sg_fs_stats *sg_get_fs_stats(int *entries){
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){
# Line 327 | Line 330 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 334 | Line 338 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 343 | Line 348 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 361 | Line 367 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 376 | Line 383 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 435 | Line 443 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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++){
# Line 477 | Line 497 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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);
# Line 488 | Line 509 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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  
# Line 656 | Line 678 | out:
678   #endif
679  
680   #ifdef CYGWIN
681 +        sg_set_error(SG_ERROR_UNSUPPORTED, "Cygwin");
682          return NULL;
683   #endif
684  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines