11 #include "blacklist.h"
15 #include "../libcheckers/checkers.h"
18 find_hwe (vector hwtable, char * vendor, char * product)
23 vector_foreach_slot (hwtable, hwe, i) {
24 if (strcmp_chomp(hwe->vendor, vendor) == 0 &&
25 (hwe->product[0] == '*' ||
26 strcmp_chomp(hwe->product, product) == 0))
32 extern struct mpentry *
33 find_mpe (char * wwid)
41 vector_foreach_slot (conf->mptable, mpe, i)
42 if (mpe->wwid && !strcmp(mpe->wwid, wwid))
49 get_mpe_wwid (char * alias)
57 vector_foreach_slot (conf->mptable, mpe, i)
58 if (mpe->alias && strcmp(mpe->alias, alias) == 0)
65 free_hwe (struct hwentry * hwe)
95 free_hwtable (vector hwtable)
103 vector_foreach_slot (hwtable, hwe, i)
106 vector_free(hwtable);
110 free_mpe (struct mpentry * mpe)
131 free_mptable (vector mptable)
134 struct mpentry * mpe;
139 vector_foreach_slot (mptable, mpe, i)
142 vector_free(mptable);
148 struct mpentry * mpe = (struct mpentry *)
149 MALLOC(sizeof(struct mpentry));
154 static struct hwentry *
157 struct hwentry * hwe = (struct hwentry *)
158 MALLOC(sizeof(struct hwentry));
164 set_param_str(char * str)
177 dst = (char *)MALLOC(len + 1);
187 store_hwe (vector hwtable, char * vendor, char * product, int pgp,
190 struct hwentry * hwe;
197 hwe->vendor = set_param_str(vendor);
202 hwe->product = set_param_str(product);
211 hwe->getuid = set_param_str(getuid);
213 hwe->getuid = set_default(DEFAULT_GETUID);
218 if (!vector_alloc_slot(hwtable))
221 vector_set_slot(hwtable, hwe);
229 store_hwe_ext (vector hwtable, char * vendor, char * product, int pgp,
230 char * getuid, char * getprio, char * hwhandler,
231 char * features, char * checker)
233 struct hwentry * hwe;
240 hwe->vendor = set_param_str(vendor);
245 hwe->product = set_param_str(product);
254 hwe->getuid = set_param_str(getuid);
256 hwe->getuid = set_default(DEFAULT_GETUID);
262 hwe->getprio = set_param_str(getprio);
267 hwe->hwhandler = set_param_str(hwhandler);
269 hwe->hwhandler = set_default(DEFAULT_HWHANDLER);
275 hwe->features = set_param_str(features);
277 hwe->features = set_default(DEFAULT_FEATURES);
283 hwe->checker_index = get_checker_id(checker);
285 hwe->checker_index = get_checker_id(DEFAULT_CHECKER);
287 if (!vector_alloc_slot(hwtable))
290 vector_set_slot(hwtable, hwe);
300 return (struct config *)MALLOC(sizeof(struct config));
304 free_config (struct config * conf)
313 FREE(conf->udev_dir);
315 if (conf->default_selector)
316 FREE(conf->default_selector);
318 if (conf->default_getuid)
319 FREE(conf->default_getuid);
321 if (conf->default_getprio)
322 FREE(conf->default_getprio);
324 if (conf->default_features)
325 FREE(conf->default_features);
327 if (conf->default_hwhandler)
328 FREE(conf->default_hwhandler);
330 free_blacklist(conf->blist);
331 free_mptable(conf->mptable);
332 free_hwtable(conf->hwtable);
338 load_config (char * file)
341 conf = alloc_config();
349 if (!conf->verbosity)
352 conf->dev_type = DEV_NONE;
356 * read the config file
358 if (filepresent(file)) {
359 if (init_data(file, init_keywords)) {
360 condlog(0, "error parsing config file");
366 * fill the voids left in the config file
368 if (conf->hwtable == NULL) {
369 conf->hwtable = vector_alloc();
374 if (setup_default_hwtable(conf->hwtable))
377 if (conf->blist == NULL) {
378 conf->blist = vector_alloc();
383 if (setup_default_blist(conf->blist))
386 if (conf->mptable == NULL) {
387 conf->mptable = vector_alloc();
392 if (conf->default_selector == NULL)
393 conf->default_selector = set_default(DEFAULT_SELECTOR);
395 if (conf->udev_dir == NULL)
396 conf->udev_dir = set_default(DEFAULT_UDEVDIR);
398 if (conf->default_getuid == NULL)
399 conf->default_getuid = set_default(DEFAULT_GETUID);
401 if (conf->default_features == NULL)
402 conf->default_features = set_default(DEFAULT_FEATURES);
404 if (conf->default_hwhandler == NULL)
405 conf->default_hwhandler = set_default(DEFAULT_HWHANDLER);
407 if (!conf->default_selector || !conf->udev_dir ||
408 !conf->default_getuid || !conf->default_features ||
409 !conf->default_hwhandler)