summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDoug Ledford <dledford@redhat.com>2010-04-16 13:47:42 -0400
committerDoug Ledford <dledford@redhat.com>2010-04-16 13:47:42 -0400
commit3619d7da2ac629f8b980eb30daa979431ad5eaf9 (patch)
treec5b1707c6ca6e1729976f35c332689f1a38a0069
parent61923125d52d26398c38c8465a898913e3b7171a (diff)
downloadmdadm-3619d7da2ac629f8b980eb30daa979431ad5eaf9.tar.gz
mdadm-3619d7da2ac629f8b980eb30daa979431ad5eaf9.tar.xz
mdadm-3619d7da2ac629f8b980eb30daa979431ad5eaf9.zip
Modify config parsing and domain struct to use a partition handler
entry instead of just a program name. Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r--config.c21
-rw-r--r--mdadm.h2
2 files changed, 14 insertions, 9 deletions
diff --git a/config.c b/config.c
index 88f11e1..30764c9 100644
--- a/config.c
+++ b/config.c
@@ -709,8 +709,6 @@ void free_domain(struct domain_ent *de)
}
if (de->spare_group)
free(de->spare_group);
- if (de->program)
- free(de->program);
if (de->table)
free(de->table);
free(de);
@@ -731,7 +729,7 @@ void domainline(char *line)
}
de->paths = NULL;
de->spare_group = NULL;
- de->program = NULL;
+ de->handler = NULL;
de->table = NULL;
de->action = incremental;
de->st = NULL;
@@ -813,6 +811,8 @@ void domainline(char *line)
return;
}
} else if (strncasecmp("program=", w, 8) == 0) {
+ int i = 0;
+ struct partition_handler *h = partition_list[i];
if (!p_seen)
p_seen = 1;
else {
@@ -821,13 +821,18 @@ void domainline(char *line)
"ignoring\n");
continue;
}
- de->program = strdup(w+8);
- if (!de->program) {
- fprintf(stderr, Name ": failed to allocate "
- "memory for program\n");
+ while(h) {
+ if (strncasecmp(w+8, h->match, strlen(h->match)) == 0)
+ break;
+ h = partition_list[++i];
+ }
+ if (!h) {
+ fprintf(stderr, Name ": failed to recognize "
+ "program %s\n", w+8);
free_domain(de);
return;
}
+ de->handler = h;
} else if (strncasecmp("table=", w, 6) == 0) {
if (!t_seen)
t_seen = 1;
@@ -893,7 +898,7 @@ void domainline(char *line)
free_domain(de);
return;
}
- if (!de->table || !de->program) {
+ if (!de->table || !de->handler) {
fprintf(stderr, Name ": partition action requires "
"both a table and program setting.\n");
free_domain(de);
diff --git a/mdadm.h b/mdadm.h
index beadaf9..aa64a38 100644
--- a/mdadm.h
+++ b/mdadm.h
@@ -318,7 +318,7 @@ struct domain_ent {
int action;
struct supertype *st;
struct domain_ent *next;
- char *program; /* only used when action is
+ struct partition_handler *handler; /* only used when action is
partition, this is the program
to call to actually partition
the drive */