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.15 by tdb, Wed Nov 19 21:56:21 2003 UTC vs.
Revision 1.17 by pajs, Mon Jan 5 14:21:07 2004 UTC

# Line 77 | Line 77 | void add_mapping(char *bsd, char *svr){
77          svr = strdup(svr);
78  
79          if (mapping == NULL){
80                printf("New malloc\n");
80                  mapping = malloc(sizeof(mapping_t));
81                  if (mapping == NULL) return;
82                  map_ptr = mapping;
# Line 85 | Line 84 | void add_mapping(char *bsd, char *svr){
84                  /* See if its already been added */
85                  for(map_ptr = mapping; map_ptr != NULL; map_ptr = map_ptr->next){
86                          if( (!strcmp(map_ptr->bsd, bsd)) || (!strcmp(map_ptr->svr, svr)) ){
88                                printf("%s matches %s\n", map_ptr->bsd, bsd);
87                                  return;
88                          }
89                          map_end_ptr = map_ptr;
# Line 95 | Line 93 | void add_mapping(char *bsd, char *svr){
93                   * new mapping_t
94                   */
95                  map_end_ptr->next = malloc(sizeof(mapping_t));
98                printf("Second malloc\n");
96                  if (map_end_ptr->next == NULL) return;
97                  map_ptr = map_end_ptr->next;
98          }
99  
103        printf("Adding %s\n", bsd);
100          map_ptr->next = NULL;
101          map_ptr->bsd = bsd;
102          map_ptr->svr = svr;
# Line 144 | Line 140 | char *read_dir(char *disk_path){
140                                  return svr_name;
141                          }
142                  }
147                closedir(dirp);
143          }
144 +        closedir(dirp);
145          return NULL;
146   }
147  
# Line 162 | Line 158 | int get_alias(char *alias){
158          char *value;
159          int instance;
160          if ((root_node = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
161 <                fprintf(stderr, "di_init() failed\n");
166 <                exit(1);
161 >                return 1;
162          }
163          node = di_drv_first_node(alias, root_node);
164          while (node != DI_NODE_NIL) {
# Line 173 | Line 168 | int get_alias(char *alias){
168                          minor_name = di_minor_name(minor);
169                          strcpy(tmpnode, alias);
170                          sprintf(tmpnode, "%s%d", tmpnode, instance);
171 <                        strcpy(file, "/devices");
172 <                        strcat(file, phys_path);
173 <                        strcat(file, ":");
174 <                        strcat(file, minor_name);
171 >                        strlcpy(file, "/devices", sizeof file);
172 >                        strlcat(file, phys_path, sizeof file);
173 >                        strlcat(file, ":", sizeof file);
174 >                        strlcat(file, minor_name, sizeof file);
175                          value = read_dir(file);
176                          if (value != NULL){
177                                  add_mapping(tmpnode, value);
# Line 188 | Line 183 | int get_alias(char *alias){
183                  }
184          }
185          di_fini(root_node);
186 <        return (-1);
186 >        return 0;
187   }
188  
189 < void build_mapping(){
189 > int build_mapping(){
190          char device_name[512];
191          int x;
192          kstat_ctl_t *kc;
# Line 199 | Line 194 | void build_mapping(){
194          kstat_io_t kios;
195  
196          if ((kc = kstat_open()) == NULL) {
197 <                return NULL;
197 >                return;
198          }
199  
200          for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
# Line 214 | Line 209 | void build_mapping(){
209                          }
210                          if(x == sizeof device_name) x--;
211                          device_name[x] = '\0';
212 <                        get_alias(device_name);
212 >                        if((get_alias(device_name)) != 0){
213 >                                return 1;
214 >                        }
215                  }
216          }
217  
218 <        return;
218 >        return 0;
219   }
220  
221   #endif
# Line 336 | Line 333 | int statgrab_init(){
333          }
334   #endif
335   #ifdef SOLARIS
336 <        build_mapping();
336 >        if((build_mapping()) != 0) return 1;
337   #endif
338          return 0;
339   }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines