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

Comparing projects/libstatgrab/src/libstatgrab/swap_stats.c (file contents):
Revision 1.5 by tdb, Sun Aug 24 20:24:09 2003 UTC vs.
Revision 1.6 by ats, Sun Oct 19 00:25:30 2003 UTC

# Line 23 | Line 23
23   #endif
24  
25   #include "statgrab.h"
26 + #include "tools.h"
27   #ifdef SOLARIS
28   #include <sys/stat.h>
29   #include <sys/swap.h>
# Line 30 | Line 31
31   #endif
32   #ifdef LINUX
33   #include <stdio.h>
33 #include "tools.h"
34   #endif
35   #ifdef FREEBSD
36   #include <unistd.h>
37   #include <sys/types.h>
38 #include <fcntl.h>
38   #include <kvm.h>
39   #endif
40  
# Line 54 | Line 53 | swap_stat_t *get_swap_stats(){
53   #ifdef FREEBSD
54          struct kvm_swap swapinfo;
55          int pagesize;
56 <        kvm_t *kvmd = NULL;
56 >        kvm_t *kvmd;
57   #endif
58  
59   #ifdef SOLARIS
# Line 83 | Line 82 | swap_stat_t *get_swap_stats(){
82          fclose(f);
83   #endif
84   #ifdef FREEBSD
85 <        if((kvmd = kvm_openfiles(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL){
85 >        if((kvmd = get_kvm()) == NULL){
86                  return NULL;
87          }
88          if ((kvm_getswapinfo(kvmd, &swapinfo, 1,0)) == -1){
# Line 94 | Line 93 | swap_stat_t *get_swap_stats(){
93          swap_stat.total= (long long)swapinfo.ksw_total * (long long)pagesize;
94          swap_stat.used = (long long)swapinfo.ksw_used * (long long)pagesize;
95          swap_stat.free = swap_stat.total-swap_stat.used;
97
98        kvm_close(kvmd);
96   #endif
97          return &swap_stat;
98  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines