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.67 by ats, Thu Apr 8 13:44:44 2004 UTC vs.
Revision 1.72 by ats, Sun Jul 18 21:30:11 2004 UTC

# Line 37 | Line 37
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)
# Line 122 | Line 122 | sg_fs_stats *sg_get_fs_stats(int *entries){
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);
134          if (nummnt<=0){
135 <                sg_set_error(SG_ERROR_GETMNTINFO, NULL);
135 >                sg_set_error_with_errno(SG_ERROR_GETMNTINFO, NULL);
136                  return NULL;
137          }
138          for(;nummnt--; mp++){
# Line 151 | Line 155 | sg_fs_stats *sg_get_fs_stats(int *entries){
155  
156   #ifdef SOLARIS
157          if ((f=fopen("/etc/mnttab", "r" ))==NULL){
158 <                sg_set_error(SG_ERROR_OPEN, "/etc/mnttab");
158 >                sg_set_error_with_errno(SG_ERROR_OPEN, "/etc/mnttab");
159                  return NULL;
160          }
161          while((getmntent(f, &mp)) == 0){
# Line 344 | Line 348 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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_with_errno(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKCOUNT");
352                  return NULL;
353          }
354  
# Line 352 | Line 356 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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_with_errno(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES");
360                  return NULL;
361          }
362  
# Line 362 | Line 366 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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_with_errno(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKNAMES");
370                  return NULL;
371          }
372  
# Line 381 | Line 385 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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_with_errno(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS");
389                  return NULL;
390          }
391  
# Line 397 | Line 401 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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_with_errno(SG_ERROR_SYSCTL, "CTL_HW.HW_DISKSTATS");
405                  return NULL;
406          }
407  
# Line 410 | Line 414 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
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) {
# Line 458 | Line 468 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
468          }
469   #ifdef FREEBSD5
470          if ((devstat_getdevs(NULL, &stats)) < 0) {
471 +                /* FIXME devstat functions return a string error in
472 +                   devstat_errbuf */
473                  sg_set_error(SG_ERROR_DEVSTAT_GETDEVS, NULL);
474                  return NULL;
475          }
# Line 511 | Line 523 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
523   #endif
524                  if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name);
525                  if (asprintf((&diskio_stats_ptr->disk_name), "%s%d", dev_ptr->device_name, dev_ptr->unit_number) == -1) {
526 <                        sg_set_error(SG_ERROR_ASPRINTF, NULL);
526 >                        sg_set_error_with_errno(SG_ERROR_ASPRINTF, NULL);
527                          return NULL;
528                  }
529                  diskio_stats_ptr->systime=time(NULL);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines