summaryrefslogtreecommitdiff
path: root/policy.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-09-02 10:04:26 +1000
committerNeilBrown <neilb@suse.de>2010-09-06 11:26:28 +1000
commit73c9c47c70e52e4018f0adbaee136ec0d505382b (patch)
tree80cf6e99ba5f6b5e26d47bacc7eb888d5d9275db /policy.c
parent56e8be854ad5dfdf548941125cf07363a2e76776 (diff)
Factor out path_policy functon.
Allow disk-policy to be computed given the path and disk type explicitly. This can be used when hunting through /dev/disk/by-path for something interesting. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'policy.c')
-rw-r--r--policy.c36
1 files changed, 26 insertions, 10 deletions
diff --git a/policy.c b/policy.c
index 0e343b98..8aa4cc8e 100644
--- a/policy.c
+++ b/policy.c
@@ -333,23 +333,16 @@ static int config_rules_has_path = 0;
/*
* most policy comes from a set policy rules that are
* read from the config file.
- * disk_policy() gathers policy information for the
- * disk described in the given mdinfo (disk.{major,minor}).
+ * path_policy() gathers policy information for the
+ * disk described in the given a 'path' and a 'type'.
*/
-struct dev_policy *disk_policy(struct mdinfo *disk)
+struct dev_policy *path_policy(char *path, char *type)
{
- char *path = NULL;
- char *type = disk_type(disk);
struct pol_rule *rules;
struct dev_policy *pol = NULL;
if (!type)
return NULL;
- if (config_rules_has_path) {
- path = disk_path(disk);
- if (!path)
- return NULL;
- }
rules = config_rules;
@@ -369,6 +362,29 @@ struct dev_policy *disk_policy(struct mdinfo *disk)
}
pol_sort(&pol);
pol_dedup(pol);
+ return pol;
+}
+
+/*
+ * disk_policy() gathers policy information for the
+ * disk described in the given mdinfo (disk.{major,minor}).
+ */
+struct dev_policy *disk_policy(struct mdinfo *disk)
+{
+ char *path = NULL;
+ char *type = disk_type(disk);
+ struct dev_policy *pol = NULL;
+
+ if (!type)
+ return NULL;
+ if (config_rules_has_path) {
+ path = disk_path(disk);
+ if (!path)
+ return NULL;
+ }
+
+ pol = path_policy(path, type);
+
free(path);
return pol;
}