} else {
struct dev_policy *pol = NULL;
pol = devnum_policy(stb.st_rdev);
- if (domain_test(domains, pol, NULL))
+ if (domain_test(domains, pol, NULL) == 1)
/* take this spare if domains match */
tmpdev->used = 1;
else
}
dl = domain_from_array(sra, st2->ss->name);
- if (!domain_test(dl, pol, st2->ss->name)) {
+ if (domain_test(dl, pol, st2->ss->name) != 1) {
/* domain test fails */
if (verbose > 1)
fprintf(stderr, Name ": not adding %s to %s as"
pol2 = path_policy(de->d_name, type_disk);
domain_merge(&domlist, pol2, st ? st->ss->name : NULL);
- if (domain_test(domlist, pol, st ? st->ss->name : NULL) == 0)
+ if (domain_test(domlist, pol, st ? st->ss->name : NULL) != 1)
/* new device is incompatible with this device. */
goto next;
if (!st) {
/* Check domain policy again, this time referring to metadata */
domain_merge(&domlist, pol2, st2->ss->name);
- if (domain_test(domlist, pol, st2->ss->name) == 0)
+ if (domain_test(domlist, pol, st2->ss->name) != 1)
/* Incompatible devices for this metadata type */
goto next;
if (!policy_action_allows(pol, st2->ss->name, act_spare))
if (from->spare_group)
pol_add(&pol, pol_domain,
from->spare_group, NULL);
- if (domain_test(domlist, pol, to->metadata->ss->name))
+ if (domain_test(domlist, pol, to->metadata->ss->name) == 1)
dev = from->devid[d];
dev_policy_free(pol);
}
/* Check that all domains in pol (for metadata) are also in
* dom. Both lists are sorted.
* If pol has no domains, we don't really know about this device
- * so we reject the match.
+ * so we allow caller to choose:
+ * -1: has no domains
+ * 0: has domains, not all match
+ * 1: has domains, all match
*/
- int found_any = 0;
+ int found_any = -1;
struct dev_policy *p;
pol = pol_find(pol, pol_domain);
if (spare_group)
pol_add(&pol, pol_domain,
spare_group, NULL);
- if (!domain_test(domlist, pol, metadata))
+ if (domain_test(domlist, pol, metadata) != 1)
found = 0;
dev_policy_free(pol);
}