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.60 by ats, Mon Apr 5 00:07:37 2004 UTC vs.
Revision 1.61 by ats, Mon Apr 5 15:40:15 2004 UTC

# Line 76 | Line 76
76                          "ntfs"}
77   #endif
78  
79 < static void disk_stat_init(disk_stat_t *d) {
79 > static void disk_stat_init(sg_fs_stats *d) {
80          d->device_name = NULL;
81          d->fs_type = NULL;
82          d->mnt_point = NULL;
83   }
84  
85 < static void disk_stat_destroy(disk_stat_t *d) {
85 > static void disk_stat_destroy(sg_fs_stats *d) {
86          free(d->device_name);
87          free(d->fs_type);
88          free(d->mnt_point);
89   }
90  
91 < int is_valid_fs_type(const char *type) {
91 > static int is_valid_fs_type(const char *type) {
92          const char *types[] = VALID_FS_TYPES;
93          int i;
94  
# Line 100 | Line 100 | int is_valid_fs_type(const char *type) {
100          return 0;
101   }
102  
103 < disk_stat_t *get_disk_stats(int *entries){
104 <        VECTOR_DECLARE_STATIC(disk_stats, disk_stat_t, 10,
103 > sg_fs_stats *sg_get_fs_stats(int *entries){
104 >        VECTOR_DECLARE_STATIC(disk_stats, sg_fs_stats, 10,
105                                disk_stat_init, disk_stat_destroy);
106  
107          int valid_type;
# Line 110 | Line 110 | disk_stat_t *get_disk_stats(int *entries){
110          FILE *f;
111   #endif
112  
113 <        disk_stat_t *disk_ptr;
113 >        sg_fs_stats *disk_ptr;
114  
115   #ifdef SOLARIS
116          struct mnttab mp;
# Line 165 | Line 165 | disk_stat_t *get_disk_stats(int *entries){
165                          disk_ptr=disk_stats+num_disks;
166  
167   #ifdef ALLBSD
168 <                        if (update_string(&disk_ptr->device_name, mp->f_mntfromname) == NULL) {
168 >                        if (sg_update_string(&disk_ptr->device_name, mp->f_mntfromname) == NULL) {
169                                  return NULL;
170                          }
171 <                        if (update_string(&disk_ptr->fs_type, mp->f_fstypename) == NULL) {
171 >                        if (sg_update_string(&disk_ptr->fs_type, mp->f_fstypename) == NULL) {
172                                  return NULL;
173                          }
174 <                        if (update_string(&disk_ptr->mnt_point, mp->f_mntonname) == NULL) {
174 >                        if (sg_update_string(&disk_ptr->mnt_point, mp->f_mntonname) == NULL) {
175                                  return NULL;
176                          }
177  
# Line 185 | Line 185 | disk_stat_t *get_disk_stats(int *entries){
185                          disk_ptr->used_inodes=disk_ptr->total_inodes-disk_ptr->free_inodes;
186   #endif
187   #if defined(LINUX) || defined(CYGWIN)
188 <                        if (update_string(&disk_ptr->device_name, mp->mnt_fsname) == NULL) {
188 >                        if (sg_update_string(&disk_ptr->device_name, mp->mnt_fsname) == NULL) {
189                                  return NULL;
190                          }
191                                  
192 <                        if (update_string(&disk_ptr->fs_type, mp->mnt_type) == NULL) {  
192 >                        if (sg_update_string(&disk_ptr->fs_type, mp->mnt_type) == NULL) {      
193                                  return NULL;
194                          }
195  
196 <                        if (update_string(&disk_ptr->mnt_point, mp->mnt_dir) == NULL) {
196 >                        if (sg_update_string(&disk_ptr->mnt_point, mp->mnt_dir) == NULL) {
197                                  return NULL;
198                          }
199                          disk_ptr->size = (long long)fs.f_bsize * (long long)fs.f_blocks;
# Line 211 | Line 211 | disk_stat_t *get_disk_stats(int *entries){
211                           * Downside is its a bit hungry for a lot of mounts, as MNT_MAX_SIZE would prob
212                           * be upwards of a k each
213                           */
214 <                        if (update_string(&disk_ptr->device_name, mp.mnt_special) == NULL) {
214 >                        if (sg_update_string(&disk_ptr->device_name, mp.mnt_special) == NULL) {
215                                  return NULL;
216                          }
217  
218 <                        if (update_string(&disk_ptr->fs_type, mp.mnt_fstype) == NULL) {
218 >                        if (sg_update_string(&disk_ptr->fs_type, mp.mnt_fstype) == NULL) {
219                                  return NULL;
220                          }
221          
222 <                        if (update_string(&disk_ptr->mnt_point, mp.mnt_mountp) == NULL) {
222 >                        if (sg_update_string(&disk_ptr->mnt_point, mp.mnt_mountp) == NULL) {
223                                  return NULL;
224                          }
225                          
# Line 250 | Line 250 | disk_stat_t *get_disk_stats(int *entries){
250  
251   }
252  
253 < static void diskio_stat_init(diskio_stat_t *d) {
253 > static void diskio_stat_init(sg_disk_io_stats *d) {
254          d->disk_name = NULL;
255   }
256  
257 < static void diskio_stat_destroy(diskio_stat_t *d) {
257 > static void diskio_stat_destroy(sg_disk_io_stats *d) {
258          free(d->disk_name);
259   }
260  
261 < VECTOR_DECLARE_STATIC(diskio_stats, diskio_stat_t, 10,
261 > VECTOR_DECLARE_STATIC(diskio_stats, sg_disk_io_stats, 10,
262                        diskio_stat_init, diskio_stat_destroy);
263  
264   #ifdef LINUX
# Line 268 | Line 268 | typedef struct {
268   } partition;
269   #endif
270  
271 < diskio_stat_t *get_diskio_stats(int *entries){
271 > sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
272          int num_diskio;
273   #ifndef LINUX
274 <        diskio_stat_t *diskio_stats_ptr;
274 >        sg_disk_io_stats *diskio_stats_ptr;
275   #endif
276  
277   #ifdef SOLARIS
# Line 412 | Line 412 | diskio_stat_t *get_diskio_stats(int *entries){
412   #else
413                  name = dk_name[i];
414   #endif
415 <                if (update_string(&diskio_stats_ptr->disk_name, name) == NULL) {
415 >                if (sg_update_string(&diskio_stats_ptr->disk_name, name) == NULL) {
416                          return NULL;
417                  }
418                  diskio_stats_ptr->systime = time(NULL);
# Line 508 | Line 508 | diskio_stat_t *get_diskio_stats(int *entries){
508                          
509                          diskio_stats_ptr->read_bytes=kios.nread;
510                          diskio_stats_ptr->write_bytes=kios.nwritten;
511 <                        if (update_string(&diskio_stats_ptr->disk_name,
512 <                                          get_svr_from_bsd(ksp->ks_name)) == NULL) {
511 >                        if (sg_update_string(&diskio_stats_ptr->disk_name,
512 >                                             sg_get_svr_from_bsd(ksp->ks_name)) == NULL) {
513                                  return NULL;
514                          }
515                          diskio_stats_ptr->systime=time(NULL);
# Line 539 | Line 539 | diskio_stat_t *get_diskio_stats(int *entries){
539          if (f == NULL) goto out;
540          now = time(NULL);
541  
542 <        while ((line_ptr = f_read_line(f, "")) != NULL) {
542 >        while ((line_ptr = sg_f_read_line(f, "")) != NULL) {
543                  char name[100];
544                  char *s;
545                  long long rsect, wsect;
# Line 568 | Line 568 | diskio_stat_t *get_diskio_stats(int *entries){
568                          goto out;
569                  }
570  
571 <                if (update_string(&diskio_stats[n].disk_name, name) == NULL) {
571 >                if (sg_update_string(&diskio_stats[n].disk_name, name) == NULL) {
572                          goto out;
573                  }
574                  diskio_stats[n].read_bytes = rsect * 512;
# Line 592 | Line 592 | diskio_stat_t *get_diskio_stats(int *entries){
592                  if (f == NULL) goto out;
593                  now = time(NULL);
594          
595 <                line_ptr = f_read_line(f, "disk_io:");
595 >                line_ptr = sg_f_read_line(f, "disk_io:");
596                  if (line_ptr == NULL) goto out;
597          
598                  while((line_ptr=strchr(line_ptr, ' '))!=NULL){
# Line 664 | Line 664 | out:
664          return diskio_stats;
665   }
666  
667 < diskio_stat_t *get_diskio_stats_diff(int *entries){
668 <        VECTOR_DECLARE_STATIC(diff, diskio_stat_t, 1,
667 > sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entries){
668 >        VECTOR_DECLARE_STATIC(diff, sg_disk_io_stats, 1,
669                                diskio_stat_init, diskio_stat_destroy);
670 <        diskio_stat_t *src = NULL, *dest;
670 >        sg_disk_io_stats *src = NULL, *dest;
671          int i, j, diff_count, new_count;
672  
673          if (diskio_stats == NULL) {
674                  /* No previous stats, so we can't calculate a difference. */
675 <                return get_diskio_stats(entries);
675 >                return sg_get_disk_io_stats(entries);
676          }
677  
678          /* Resize the results array to match the previous stats. */
# Line 686 | Line 686 | diskio_stat_t *get_diskio_stats_diff(int *entries){
686                  src = &diskio_stats[i];
687                  dest = &diff[i];
688  
689 <                if (update_string(&dest->disk_name, src->disk_name) == NULL) {
689 >                if (sg_update_string(&dest->disk_name, src->disk_name) == NULL) {
690                          return NULL;
691                  }
692                  dest->read_bytes = src->read_bytes;
# Line 695 | Line 695 | diskio_stat_t *get_diskio_stats_diff(int *entries){
695          }
696  
697          /* Get a new set of stats. */
698 <        if (get_diskio_stats(&new_count) == NULL) {
698 >        if (sg_get_disk_io_stats(&new_count) == NULL) {
699                  return NULL;
700          }
701  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines