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

Comparing projects/libstatgrab/src/libstatgrab/tools.c (file contents):
Revision 1.19 by pajs, Fri Jan 9 16:19:58 2004 UTC vs.
Revision 1.22 by pajs, Thu Jan 15 22:21:37 2004 UTC

# Line 187 | Line 187 | int get_alias(char *alias){
187          return 0;
188   }
189  
190 +
191 + #define BIG_ENOUGH 512
192   int build_mapping(){
193 <        char device_name[512];
193 >        char device_name[BIG_ENOUGH];
194          int x;
195          kstat_ctl_t *kc;
196          kstat_t *ksp;
197          kstat_io_t kios;
198  
199 +        char driver_list[BIG_ENOUGH][BIG_ENOUGH];
200 +        int list_entries = 0;
201 +        int found;
202 +
203          if ((kc = kstat_open()) == NULL) {
204                  return;
205          }
# Line 210 | Line 216 | int build_mapping(){
216                          }
217                          if(x == sizeof device_name) x--;
218                          device_name[x] = '\0';
219 <                        if((get_alias(device_name)) != 0){
220 <                                return 1;
219 >
220 >                        /* Check if we've not already looked it up */
221 >                        found = 0;
222 >                        for(x=0;x<list_entries;x++){
223 >                                if (x>=BIG_ENOUGH){
224 >                                        /* We've got bigger than we thought was massive */
225 >                                        /* If we hit this.. Make big enough bigger */
226 >                                        return 1;
227 >                                }
228 >                                if( !strncmp(driver_list[x], device_name, BIG_ENOUGH)){
229 >                                        found = 1;
230 >                                        break;
231 >                                }
232                          }
233 +
234 +                        if(!found){
235 +                                if((get_alias(device_name)) != 0){
236 +                                        return 1;
237 +                                }
238 +                                strncpy(driver_list[x], device_name, BIG_ENOUGH);
239 +                                list_entries++;
240 +                        }
241                  }
242          }
243  
# Line 269 | Line 294 | static long long atoll(const char *s) {
294   #endif
295  
296   #ifndef HAVE_STRLCPY
297 < *      $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $     */
297 > /*      $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $     */
298  
299   /*
300   * Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
# Line 437 | Line 462 | int statgrab_init(){
462          }
463   #endif
464   #ifdef SOLARIS
465 <        if((build_mapping()) != 0) return 1;
465 >        /* On solaris 7, this will fail if you are not root. But, everything
466 >         * will still work, just no disk mappings. So we will ignore the exit
467 >         * status of this, and carry on merrily.
468 >         */
469 >        build_mapping();
470   #endif
471          return 0;
472   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines