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.21 by ats, Tue Sep 9 08:43:33 2003 UTC vs.
Revision 1.29 by ats, Sat Oct 18 22:16:44 2003 UTC

# Line 338 | Line 338 | diskio_stat_t *get_diskio_stats(int *entries){
338   #ifdef FREEBSD
339          if (!stats_init) {
340                  stats.dinfo=malloc(sizeof(struct devinfo));
341 +                bzero(stats.dinfo, sizeof(struct devinfo));
342                  if(stats.dinfo==NULL) return NULL;
343                  stats_init = 1;
344          }
345 + #ifdef FREEBSD5
346 +        if ((devstat_getdevs(NULL, &stats)) < 0) return NULL;
347 +        /* Not aware of a get all devices, so i said 999. If we ever
348 +         * find a machine with more than 999 disks, then i'll change
349 +         * this number :)
350 +         */
351 +        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;
352 + #else
353          if ((getdevs(&stats)) < 0) return NULL;
354          /* Not aware of a get all devices, so i said 999. If we ever
355           * find a machine with more than 999 disks, then i'll change
356           * this number :)
357           */
358          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;
359 + #endif
360  
361          for(counter=0;counter<stats.dinfo->numdevs;counter++){
362                  dev_ptr=&stats.dinfo->devices[dev_sel[counter].position];
# Line 355 | Line 365 | diskio_stat_t *get_diskio_stats(int *entries){
365                   * devices.. like mem, proc.. and also doesn't report floppy
366                   * drives etc unless they are doing stuff :)
367                   */
368 + #ifdef FREEBSD5
369 +                if((dev_ptr->bytes[DEVSTAT_READ]==0) && (dev_ptr->bytes[DEVSTAT_WRITE]==0)) continue;
370 + #else
371                  if((dev_ptr->bytes_read==0) && (dev_ptr->bytes_written==0)) continue;
372 + #endif
373                  if((diskio_stats=diskio_stat_malloc(num_diskio+1, &sizeof_diskio_stats, diskio_stats))==NULL){
374                          return NULL;
375                  }
376                  diskio_stats_ptr=diskio_stats+num_diskio;
377 <                
377 >
378 > #ifdef FREEBSD5        
379 >                diskio_stats_ptr->read_bytes=dev_ptr->bytes[DEVSTAT_READ];
380 >                diskio_stats_ptr->write_bytes=dev_ptr->bytes[DEVSTAT_WRITE];
381 > #else
382                  diskio_stats_ptr->read_bytes=dev_ptr->bytes_read;
383                  diskio_stats_ptr->write_bytes=dev_ptr->bytes_written;
384 + #endif
385                  if(diskio_stats_ptr->disk_name!=NULL) free(diskio_stats_ptr->disk_name);
386                  asprintf((&diskio_stats_ptr->disk_name), "%s%d", dev_ptr->device_name, dev_ptr->unit_number);
387                  diskio_stats_ptr->systime=time(NULL);
# Line 370 | Line 389 | diskio_stat_t *get_diskio_stats(int *entries){
389                  num_diskio++;
390          }
391          free(dev_sel);
373        free(stats.dinfo);
392  
393   #endif
394   #ifdef SOLARIS

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines