]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - policy.c
Remove lots of unnecessary white space.
[thirdparty/mdadm.git] / policy.c
index 8ee6a6c815b358f8b3e791d385324a18c4d70b46..b4f39434268e896a38c45eff2203680040bdc0cc 100644 (file)
--- a/policy.c
+++ b/policy.c
@@ -401,7 +401,6 @@ void pol_add(struct dev_policy **pol,
        pol_dedup(*pol);
 }
 
-
 /*
  * disk_policy() gathers policy information for the
  * disk described in the given mdinfo (disk.{major,minor}).
@@ -421,7 +420,7 @@ struct dev_policy *disk_policy(struct mdinfo *disk)
        return pol;
 }
 
-struct dev_policy *devnum_policy(int dev)
+struct dev_policy *devid_policy(int dev)
 {
        struct mdinfo disk;
        disk.disk.major = major(dev);
@@ -592,7 +591,6 @@ int disk_action_allows(struct mdinfo *disk, const char *metadata, enum policy_ac
        return rv;
 }
 
-
 /* Domain policy:
  * Any device can have a list of domains asserted by different policy
  * statements.
@@ -677,9 +675,9 @@ int domain_test(struct domainlist *dom, struct dev_policy *pol,
        return found_any;
 }
 
-void domainlist_add_dev(struct domainlist **dom, int devnum, const char *metadata)
+void domainlist_add_dev(struct domainlist **dom, int devid, const char *metadata)
 {
-       struct dev_policy *pol = devnum_policy(devnum);
+       struct dev_policy *pol = devid_policy(devid);
        domain_merge(dom, pol, metadata);
        dev_policy_free(pol);
 }
@@ -703,7 +701,6 @@ void domain_add(struct domainlist **domp, char *domain)
        domain_merge_one(domp, domain);
 }
 
-
 void domain_free(struct domainlist *dl)
 {
        while (dl) {
@@ -791,13 +788,13 @@ char udev_template_start[] =
 /* find rule named rule_type and return its value */
 char *find_rule(struct rule *rule, char *rule_type)
 {
-       while (rule) {
-               if (rule->name == rule_type)
-                       return rule->value;
+       while (rule) {
+               if (rule->name == rule_type)
+                       return rule->value;
 
-               rule = rule->next;
-       }
-       return NULL;
+               rule = rule->next;
+       }
+       return NULL;
 }
 
 #define UDEV_RULE_FORMAT \
@@ -834,44 +831,44 @@ int write_rule(struct rule *rule, int fd, int force_part)
  */
 int generate_entries(int fd)
 {
-       struct pol_rule *loop, *dup;
-       char *loop_value, *dup_value;
-       int duplicate;
-
-       for (loop = config_rules; loop; loop = loop->next) {
-               if (loop->type != rule_policy && loop->type != rule_part)
-                       continue;
-               duplicate = 0;
-
-               /* only policies with paths and with actions supporting
-                * bare disks are considered */
-               loop_value = find_rule(loop->rule, pol_act);
-               if (!loop_value || map_act(loop_value) < act_spare_same_slot)
-                       continue;
-               loop_value = find_rule(loop->rule, rule_path);
-               if (!loop_value)
-                       continue;
-               for (dup = config_rules; dup != loop; dup = dup->next) {
-                       if (dup->type != rule_policy && loop->type != rule_part)
-                               continue;
-                       dup_value = find_rule(dup->rule, pol_act);
-                       if (!dup_value || map_act(dup_value) < act_spare_same_slot)
-                               continue;
-                       dup_value = find_rule(dup->rule, rule_path);
-                       if (!dup_value)
-                               continue;
-                       if (strcmp(loop_value, dup_value) == 0) {
-                               duplicate = 1;
-                               break;
-                       }
-               }
-
-               /* not a dup or first occurrence */
-               if (!duplicate)
-                       if (!write_rule(loop->rule, fd, loop->type == rule_part) )
-                               return 0;
-       }
-       return 1;
+       struct pol_rule *loop, *dup;
+       char *loop_value, *dup_value;
+       int duplicate;
+
+       for (loop = config_rules; loop; loop = loop->next) {
+               if (loop->type != rule_policy && loop->type != rule_part)
+                       continue;
+               duplicate = 0;
+
+               /* only policies with paths and with actions supporting
+                * bare disks are considered */
+               loop_value = find_rule(loop->rule, pol_act);
+               if (!loop_value || map_act(loop_value) < act_spare_same_slot)
+                       continue;
+               loop_value = find_rule(loop->rule, rule_path);
+               if (!loop_value)
+                       continue;
+               for (dup = config_rules; dup != loop; dup = dup->next) {
+                       if (dup->type != rule_policy && loop->type != rule_part)
+                               continue;
+                       dup_value = find_rule(dup->rule, pol_act);
+                       if (!dup_value || map_act(dup_value) < act_spare_same_slot)
+                               continue;
+                       dup_value = find_rule(dup->rule, rule_path);
+                       if (!dup_value)
+                               continue;
+                       if (strcmp(loop_value, dup_value) == 0) {
+                               duplicate = 1;
+                               break;
+                       }
+               }
+
+               /* not a dup or first occurrence */
+               if (!duplicate)
+                       if (!write_rule(loop->rule, fd, loop->type == rule_part) )
+                               return 0;
+       }
+       return 1;
 }
 
 /* Write_rules routine creates dynamic udev rules used to handle
@@ -879,40 +876,40 @@ int generate_entries(int fd)
  */
 int Write_rules(char *rule_name)
 {
-       int fd;
-       char udev_rule_file[PATH_MAX];
-
-       if (rule_name) {
-              strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6);
-              udev_rule_file[sizeof(udev_rule_file) - 6] = '\0';
-              strcat(udev_rule_file, ".temp");
-               fd = creat(udev_rule_file,
-                          S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
-              if (fd == -1)
-                      return 1;
-       } else
-               fd = 1;
-
-       /* write static invocation */
-       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 */
-       if (generate_entries(fd) < 0)
-              goto abort;
-
-       fsync(fd);
-       if (rule_name) {
-              close(fd);
-              rename(udev_rule_file, rule_name);
-       }
-       return 0;
+       int fd;
+       char udev_rule_file[PATH_MAX];
+
+       if (rule_name) {
+               strncpy(udev_rule_file, rule_name, sizeof(udev_rule_file) - 6);
+               udev_rule_file[sizeof(udev_rule_file) - 6] = '\0';
+               strcat(udev_rule_file, ".temp");
+               fd = creat(udev_rule_file,
+                          S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
+               if (fd == -1)
+                       return 1;
+       } else
+               fd = 1;
+
+       /* write static invocation */
+       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 */
+       if (generate_entries(fd) < 0)
+               goto abort;
+
+       fsync(fd);
+       if (rule_name) {
+               close(fd);
+               rename(udev_rule_file, rule_name);
+       }
+       return 0;
 abort:
-       if (rule_name) {
-              close(fd);
-              unlink(udev_rule_file);
-       }
-       return 1;
+       if (rule_name) {
+               close(fd);
+               unlink(udev_rule_file);
+       }
+       return 1;
 }