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.40 by ats, Mon Nov 10 23:25:45 2003 UTC vs.
Revision 1.41 by ats, Mon Nov 10 23:32:59 2003 UTC

# Line 98 | Line 98 | void init_disk_stat(int start, int end, disk_stat_t *d
98          }
99   }
100  
101 + int is_valid_fs_type(const char *type) {
102 +        const char *types[] = VALID_FS_TYPES;
103 +        int i;
104 +
105 +        for (i = 0; i < (sizeof types / sizeof *types); i++) {
106 +                if (strcmp(types[i], type) == 0) {
107 +                        return 1;
108 +                }
109 +        }
110 +        return 0;
111 + }
112 +
113   disk_stat_t *get_disk_stats(int *entries){
114  
115          static disk_stat_t *disk_stats;
116          static int watermark=-1;
117  
118 <        char *fs_types[] = VALID_FS_TYPES;
107 <        int x, valid_type;
118 >        int valid_type;
119          int num_disks=0;
120   #if defined(LINUX) || defined (SOLARIS) || defined(CYGWIN)
121          FILE *f;
# Line 139 | Line 150 | disk_stat_t *get_disk_stats(int *entries){
150                  return NULL;
151          }
152          for(;nummnt--; mp++){
153 <                valid_type=0;
143 <                for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){
144 <                        if(strcmp(mp->f_fstypename, fs_types[x]) ==0){
145 <                                valid_type=1;
146 <                                break;
147 <                        }
148 <                }
153 >                valid_type = is_valid_fs_type(mp->f_fstypename);
154   #endif
155  
156   #if defined(LINUX) || defined(CYGWIN)
# Line 158 | Line 163 | disk_stat_t *get_disk_stats(int *entries){
163                          continue;
164                  }      
165  
166 <                valid_type=0;
162 <                for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){
163 <                        if(strcmp(mp->mnt_type, fs_types[x]) ==0){
164 <                                valid_type=1;
165 <                                break;
166 <                        }
167 <                }
166 >                valid_type = is_valid_fs_type(mp->mnt_type);
167   #endif
168  
169   #ifdef SOLARIS
# Line 175 | Line 174 | disk_stat_t *get_disk_stats(int *entries){
174                  if ((statvfs(mp.mnt_mountp, &fs)) !=0){
175                          continue;
176                  }
177 <                valid_type=0;
179 <                for(x=0;x<((sizeof(fs_types))/(sizeof(char*)));x++){
180 <                        if(strcmp(mp.mnt_fstype, fs_types[x]) ==0){
181 <                                valid_type=1;
182 <                                break;
183 <                        }
184 <                }
177 >                valid_type = is_valid_fs_type(mp.mnt_fstype);
178   #endif
179  
180                  if(valid_type){

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines