]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - policy.c
Add one sanity check for missing device
[thirdparty/mdadm.git] / policy.c
index 104695d3c473b829a70575a93ff7ef5d720d4c5f..c0d18a7eca5b18a0d352a4da1bb5b45af96d4079 100644 (file)
--- a/policy.c
+++ b/policy.c
@@ -661,6 +661,7 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
         *  1:  has domains, all match
         */
        int found_any = -1;
+       int has_one_domain = 1;
        struct dev_policy *p;
 
        pol = pol_find(pol, pol_domain);
@@ -670,6 +671,9 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
                        dom = dom->next;
                if (!dom || strcmp(dom->dom, p->value) != 0)
                        return 0;
+               if (has_one_domain && metadata && strcmp(metadata, "imsm") == 0)
+                       found_any = -1;
+               has_one_domain = 0;
        }
        return found_any;
 }
@@ -727,16 +731,14 @@ void policy_save_path(char *id_path, struct map_ent *array)
        FILE *f = NULL;
 
        if (mkdir(FAILED_SLOTS_DIR, S_IRWXU) < 0 && errno != EEXIST) {
-               pr_err("can't create file to save path "
-                       "to old disk: %s\n", strerror(errno));
+               pr_err("can't create file to save path to old disk: %s\n", strerror(errno));
                return;
        }
 
        snprintf(path, PATH_MAX, FAILED_SLOTS_DIR "/%s", id_path);
        f = fopen(path, "w");
        if (!f) {
-               pr_err("can't create file to"
-                       " save path to old disk: %s\n",
+               pr_err("can't create file to save path to old disk: %s\n",
                        strerror(errno));
                return;
        }
@@ -745,8 +747,7 @@ void policy_save_path(char *id_path, struct map_ent *array)
                    array->metadata,
                    array->uuid[0], array->uuid[1],
                    array->uuid[2], array->uuid[3]) <= 0)
-               pr_err("Failed to write to "
-                      "<id_path> cookie\n");
+               pr_err("Failed to write to <id_path> cookie\n");
 
        fclose(f);
 }
@@ -799,12 +800,12 @@ char *find_rule(struct rule *rule, char *rule_type)
 #define UDEV_RULE_FORMAT \
 "ACTION==\"add\", SUBSYSTEM==\"block\", " \
 "ENV{DEVTYPE}==\"%s\", ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
 
 #define UDEV_RULE_FORMAT_NOTYPE \
 "ACTION==\"add\", SUBSYSTEM==\"block\", " \
 "ENV{ID_PATH}==\"%s\", " \
-"RUN+=\"/sbin/mdadm --incremental $env{DEVNAME}\"\n"
+"RUN+=\"" BINDIR "/mdadm --incremental $env{DEVNAME}\"\n"
 
 /* Write rule in the rule file. Use format from UDEV_RULE_FORMAT */
 int write_rule(struct rule *rule, int fd, int force_part)
@@ -890,9 +891,8 @@ int Write_rules(char *rule_name)
                fd = 1;
 
        /* write static invocation */
-       if (write(fd, udev_template_start,
-                 sizeof(udev_template_start) - 1)
-           != (int)sizeof(udev_template_start)-1)
+       if (write(fd, udev_template_start, sizeof(udev_template_start) - 1) !=
+           (int)sizeof(udev_template_start) - 1)
                goto abort;
 
        /* iterate, if none created or error occurred, remove file */