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 dup_hwe (vector hwtable, char * vendor, char * product)
189 struct hwentry * hwe = find_hwe(hwtable, vendor, product);
198 store_hwe (vector hwtable, char * vendor, char * product, int pgp,
201 struct hwentry * hwe;
203 if (dup_hwe(hwtable, vendor, product))
211 hwe->vendor = set_param_str(vendor);
216 hwe->product = set_param_str(product);
225 hwe->getuid = set_param_str(getuid);
227 hwe->getuid = set_default(DEFAULT_GETUID);
232 if (!vector_alloc_slot(hwtable))
235 vector_set_slot(hwtable, hwe);
243 store_hwe_ext (vector hwtable, char * vendor, char * product, int pgp,
244 char * getuid, char * getprio, char * hwhandler,
245 char * features, char * checker, int pgfailback)
247 struct hwentry * hwe;
249 if (dup_hwe(hwtable, vendor, product))
257 hwe->vendor = set_param_str(vendor);
262 hwe->product = set_param_str(product);
271 hwe->getuid = set_param_str(getuid);
273 hwe->getuid = set_default(DEFAULT_GETUID);
279 hwe->getprio = set_param_str(getprio);
284 hwe->hwhandler = set_param_str(hwhandler);
286 hwe->hwhandler = set_default(DEFAULT_HWHANDLER);
292 hwe->features = set_param_str(features);
294 hwe->features = set_default(DEFAULT_FEATURES);
300 hwe->checker_index = get_checker_id(checker);
302 hwe->checker_index = get_checker_id(DEFAULT_CHECKER);
304 hwe->pgfailback = pgfailback;
306 if (!vector_alloc_slot(hwtable))
309 vector_set_slot(hwtable, hwe);
319 return (struct config *)MALLOC(sizeof(struct config));
323 free_config (struct config * conf)
332 FREE(conf->udev_dir);
334 if (conf->default_selector)
335 FREE(conf->default_selector);
337 if (conf->default_getuid)
338 FREE(conf->default_getuid);
340 if (conf->default_getprio)
341 FREE(conf->default_getprio);
343 if (conf->default_features)
344 FREE(conf->default_features);
346 if (conf->default_hwhandler)
347 FREE(conf->default_hwhandler);
349 free_blacklist(conf->blist);
350 free_mptable(conf->mptable);
351 free_hwtable(conf->hwtable);
357 load_config (char * file)
360 conf = alloc_config();
368 if (!conf->verbosity)
371 conf->dev_type = DEV_NONE;
375 * read the config file
377 if (filepresent(file)) {
378 if (init_data(file, init_keywords)) {
379 condlog(0, "error parsing config file");
385 * fill the voids left in the config file
387 if (conf->hwtable == NULL) {
388 conf->hwtable = vector_alloc();
394 if (setup_default_hwtable(conf->hwtable))
397 if (conf->blist == NULL) {
398 conf->blist = vector_alloc();
403 if (setup_default_blist(conf->blist))
406 if (conf->mptable == NULL) {
407 conf->mptable = vector_alloc();
412 if (conf->default_selector == NULL)
413 conf->default_selector = set_default(DEFAULT_SELECTOR);
415 if (conf->udev_dir == NULL)
416 conf->udev_dir = set_default(DEFAULT_UDEVDIR);
418 if (conf->default_getuid == NULL)
419 conf->default_getuid = set_default(DEFAULT_GETUID);
421 if (conf->default_features == NULL)
422 conf->default_features = set_default(DEFAULT_FEATURES);
424 if (conf->default_hwhandler == NULL)
425 conf->default_hwhandler = set_default(DEFAULT_HWHANDLER);
427 if (!conf->default_selector || !conf->udev_dir ||
428 !conf->default_getuid || !conf->default_features ||
429 !conf->default_hwhandler)
432 if (!conf->default_checker_index)
433 conf->default_checker_index = READSECTOR0;