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.61 by ats, Mon Apr 5 15:40:15 2004 UTC vs.
Revision 1.64 by ats, Wed Apr 7 10:33:50 2004 UTC

# Line 1 | Line 1
1   /*
2 < * i-scream central monitoring system
2 > * i-scream libstatgrab
3   * http://www.i-scream.org
4   * Copyright (C) 2000-2004 i-scream
5   *
# Line 165 | Line 165 | sg_fs_stats *sg_get_fs_stats(int *entries){
165                          disk_ptr=disk_stats+num_disks;
166  
167   #ifdef ALLBSD
168 <                        if (sg_update_string(&disk_ptr->device_name, mp->f_mntfromname) == NULL) {
168 >                        if (sg_update_string(&disk_ptr->device_name, mp->f_mntfromname) < 0) {
169                                  return NULL;
170                          }
171 <                        if (sg_update_string(&disk_ptr->fs_type, mp->f_fstypename) == NULL) {
171 >                        if (sg_update_string(&disk_ptr->fs_type, mp->f_fstypename) < 0) {
172                                  return NULL;
173                          }
174 <                        if (sg_update_string(&disk_ptr->mnt_point, mp->f_mntonname) == NULL) {
174 >                        if (sg_update_string(&disk_ptr->mnt_point, mp->f_mntonname) < 0) {
175                                  return NULL;
176                          }
177  
# Line 185 | Line 185 | sg_fs_stats *sg_get_fs_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 (sg_update_string(&disk_ptr->device_name, mp->mnt_fsname) == NULL) {
188 >                        if (sg_update_string(&disk_ptr->device_name, mp->mnt_fsname) < 0) {
189                                  return NULL;
190                          }
191                                  
192 <                        if (sg_update_string(&disk_ptr->fs_type, mp->mnt_type) == NULL) {      
192 >                        if (sg_update_string(&disk_ptr->fs_type, mp->mnt_type) < 0) {  
193                                  return NULL;
194                          }
195  
196 <                        if (sg_update_string(&disk_ptr->mnt_point, mp->mnt_dir) == NULL) {
196 >                        if (sg_update_string(&disk_ptr->mnt_point, mp->mnt_dir) < 0) {
197                                  return NULL;
198                          }
199                          disk_ptr->size = (long long)fs.f_bsize * (long long)fs.f_blocks;
# Line 211 | Line 211 | sg_fs_stats *sg_get_fs_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 (sg_update_string(&disk_ptr->device_name, mp.mnt_special) == NULL) {
214 >                        if (sg_update_string(&disk_ptr->device_name, mp.mnt_special) < 0) {
215                                  return NULL;
216                          }
217  
218 <                        if (sg_update_string(&disk_ptr->fs_type, mp.mnt_fstype) == NULL) {
218 >                        if (sg_update_string(&disk_ptr->fs_type, mp.mnt_fstype) < 0) {
219                                  return NULL;
220                          }
221          
222 <                        if (sg_update_string(&disk_ptr->mnt_point, mp.mnt_mountp) == NULL) {
222 >                        if (sg_update_string(&disk_ptr->mnt_point, mp.mnt_mountp) < 0) {
223                                  return NULL;
224                          }
225                          
# Line 337 | Line 337 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
337                  return NULL;
338          }
339  
340 <        disknames = malloc(size);
340 >        disknames = sg_malloc(size);
341          if (disknames == NULL) {
342                  return NULL;
343          }
# Line 346 | Line 346 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
346                  return NULL;
347          }
348  
349 <        dk_name = calloc(diskcount, sizeof(char *));
349 >        dk_name = sg_malloc(diskcount * sizeof(char *));
350          bufpp = disknames;
351          for (i = 0; i < diskcount && (name = strsep(&bufpp, ",")) != NULL; i++) {
352                  dk_name[i] = name;
# Line 370 | Line 370 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
370          num_disks = size / sizeof(struct diskstats);
371   #endif
372  
373 <        stats = malloc(size);
373 >        stats = sg_malloc(size);
374          if (stats == NULL) {
375                  return NULL;
376          }
# Line 412 | Line 412 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
412   #else
413                  name = dk_name[i];
414   #endif
415 <                if (sg_update_string(&diskio_stats_ptr->disk_name, name) == NULL) {
415 >                if (sg_update_string(&diskio_stats_ptr->disk_name, name) < 0) {
416                          return NULL;
417                  }
418                  diskio_stats_ptr->systime = time(NULL);
# Line 429 | Line 429 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
429  
430   #if defined(FREEBSD) || defined(DFBSD)
431          if (!stats_init) {
432 <                stats.dinfo=malloc(sizeof(struct devinfo));
432 >                stats.dinfo=sg_malloc(sizeof(struct devinfo));
433                  if(stats.dinfo==NULL) return NULL;
434                  bzero(stats.dinfo, sizeof(struct devinfo));
435                  stats_init = 1;
# Line 509 | Line 509 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
509                          diskio_stats_ptr->read_bytes=kios.nread;
510                          diskio_stats_ptr->write_bytes=kios.nwritten;
511                          if (sg_update_string(&diskio_stats_ptr->disk_name,
512 <                                             sg_get_svr_from_bsd(ksp->ks_name)) == NULL) {
512 >                                             sg_get_svr_from_bsd(ksp->ks_name)) < 0) {
513                                  return NULL;
514                          }
515                          diskio_stats_ptr->systime=time(NULL);
# Line 568 | Line 568 | sg_disk_io_stats *sg_get_disk_io_stats(int *entries){
568                          goto out;
569                  }
570  
571 <                if (sg_update_string(&diskio_stats[n].disk_name, name) == NULL) {
571 >                if (sg_update_string(&diskio_stats[n].disk_name, name) < 0) {
572                          goto out;
573                  }
574                  diskio_stats[n].read_bytes = rsect * 512;
# Line 686 | Line 686 | sg_disk_io_stats *sg_get_disk_io_stats_diff(int *entri
686                  src = &diskio_stats[i];
687                  dest = &diff[i];
688  
689 <                if (sg_update_string(&dest->disk_name, src->disk_name) == NULL) {
689 >                if (sg_update_string(&dest->disk_name, src->disk_name) < 0) {
690                          return NULL;
691                  }
692                  dest->read_bytes = src->read_bytes;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines