}
int
-blacklist_device (vector blist, char * vendor, char * product)
+blacklist_exceptions_device(vector elist, char * vendor, char * product)
{
int i;
struct blentry_device * ble;
+ vector_foreach_slot (elist, ble, i) {
+ if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) &&
+ !regexec(&ble->product_reg, product, 0, NULL, 0)) {
+ condlog(3, "%s:%s: exception-listed", vendor, product);
+ return 1;
+ }
+ }
+ return 0;
+}
+
+int
+blacklist_device (vector blist, vector elist, char * vendor, char * product)
+{
+ int i;
+ struct blentry_device * ble;
+
+ if (blacklist_exceptions_device(elist, vendor, product))
+ return 0;
+
vector_foreach_slot (blist, ble, i) {
if (!regexec(&ble->vendor_reg, vendor, 0, NULL, 0) &&
!regexec(&ble->product_reg, product, 0, NULL, 0)) {
return 1;
if (pp->vendor_id && pp->product_id &&
- blacklist_device(conf->blist_device, pp->vendor_id, pp->product_id))
+ blacklist_device(conf->blist_device, conf->elist_device, pp->vendor_id, pp->product_id))
return 1;
return 0;
int setup_default_blist (struct config *);
int alloc_ble_device (vector);
int blacklist (vector, vector, char *);
-int blacklist_device (vector, char *, char *);
+int blacklist_device (vector, vector, char *, char *);
int blacklist_path (struct config *, struct path *);
int store_ble (vector, char *, int);
int set_ble_device (vector, char *, char *, int);
free_blacklist(conf->blist_wwid);
free_blacklist_device(conf->blist_device);
- if (conf->elist_devnode)
- FREE(conf->elist_devnode);
- if (conf->elist_wwid)
- FREE(conf->elist_wwid);
+ free_blacklist(conf->elist_devnode);
+ free_blacklist(conf->elist_wwid);
+ free_blacklist_device(conf->elist_device);
free_mptable(conf->mptable);
free_hwtable(conf->hwtable);
goto out;
}
+ if (conf->elist_device == NULL) {
+ conf->elist_device = vector_alloc();
+
+ if (!conf->elist_device)
+ goto out;
+ }
+
if (conf->mptable == NULL) {
conf->mptable = vector_alloc();
vector blist_device;
vector elist_devnode;
vector elist_wwid;
+ vector elist_device;
};
struct config * conf;
{
conf->elist_devnode = vector_alloc();
conf->elist_wwid = vector_alloc();
+ conf->elist_device = vector_alloc();
- if (!conf->elist_devnode || !conf->elist_wwid)
+ if (!conf->elist_devnode || !conf->elist_wwid || !conf->blist_device)
return 1;
return 0;
}
static int
+ble_except_device_handler(vector strvec)
+{
+ return alloc_ble_device(conf->elist_device);
+}
+
+static int
ble_vendor_handler(vector strvec)
{
char * buff;
}
static int
+ble_except_vendor_handler(vector strvec)
+{
+ char * buff;
+ int r;
+
+ buff = set_value(strvec);
+
+ if (!buff)
+ return 1;
+
+ return set_ble_device(conf->elist_device, buff, NULL, ORIGIN_CONFIG);
+}
+
+static int
ble_product_handler(vector strvec)
{
char * buff;
return set_ble_device(conf->blist_device, NULL, buff, ORIGIN_CONFIG);
}
+static int
+ble_except_product_handler(vector strvec)
+{
+ char * buff;
+
+ buff = set_value(strvec);
+
+ if (!buff)
+ return 1;
+
+ return set_ble_device(conf->elist_device, NULL, buff, ORIGIN_CONFIG);
+}
+
/*
* devices block handlers
*/
install_keyword_root("blacklist_exceptions", &blacklist_exceptions_handler);
install_keyword("devnode", &ble_except_devnode_handler, &snprint_ble_simple);
install_keyword("wwid", &ble_except_wwid_handler, &snprint_ble_simple);
+ install_keyword("device", &ble_except_device_handler, NULL);
+ install_sublevel();
+ install_keyword("vendor", &ble_except_vendor_handler, &snprint_bled_vendor);
+ install_keyword("product", &ble_except_product_handler, &snprint_bled_product);
+ install_sublevel_end();
#if 0
__deprecated install_keyword_root("devnode_blacklist", &blacklist_handler);
if (snprint_blacklist_devgroup(buff, len, &fwd, &conf->blist_device) == 0)
return len;
+ if ((len - fwd - threshold) <= 0)
+ return len;
+ fwd += snprintf(buff + fwd, len - fwd, "- exceptions:\n");
+ if (snprint_blacklist_devgroup(buff, len, &fwd, &conf->elist_device) == 0)
+ return len;
+
if (fwd > len)
return len;
return fwd;
{
int i;
struct blentry * ele;
+ struct blentry_device * eled;
int fwd = 0;
struct keyword *rootkw;
struct keyword *kw;
if (fwd > len)
return len;
}
+ rootkw = find_keyword(rootkw->sub, "device");
+ if (!rootkw)
+ return 0;
+
+ vector_foreach_slot (conf->elist_device, eled, i) {
+ fwd += snprintf(buff + fwd, len - fwd, "\tdevice {\n");
+ if (fwd > len)
+ return len;
+ kw = find_keyword(rootkw->sub, "vendor");
+ if (!kw)
+ return 0;
+ fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
+ kw, eled);
+ if (fwd > len)
+ return len;
+ kw = find_keyword(rootkw->sub, "product");
+ if (!kw)
+ return 0;
+ fwd += snprint_keyword(buff + fwd, len - fwd, "\t\t%k %v\n",
+ kw, eled);
+ if (fwd > len)
+ return len;
+ fwd += snprintf(buff + fwd, len - fwd, "\t}\n");
+ if (fwd > len)
+ return len;
+ }
fwd += snprintf(buff + fwd, len - fwd, "}\n");
if (fwd > len)
return len;