diff options
author | Doug Ledford <dledford@redhat.com> | 2010-04-16 11:46:51 -0400 |
---|---|---|
committer | Doug Ledford <dledford@redhat.com> | 2010-04-16 11:46:51 -0400 |
commit | ce03f04bde040ac014c61c74d2722981f7f2e02f (patch) | |
tree | 6206cfb1e82512f1b8a1eb1671ae975f7a8bd3db | |
parent | 8da2e49bcfa73c59bafe5aa51949752c524a3f69 (diff) | |
download | mdadm-ce03f04bde040ac014c61c74d2722981f7f2e02f.tar.gz mdadm-ce03f04bde040ac014c61c74d2722981f7f2e02f.tar.xz mdadm-ce03f04bde040ac014c61c74d2722981f7f2e02f.zip |
Add the table and program options for partition action and make them
a requirement.
Signed-off-by: Doug Ledford <dledford@redhat.com>
-rw-r--r-- | config.c | 48 | ||||
-rw-r--r-- | mdadm.h | 8 |
2 files changed, 55 insertions, 1 deletions
@@ -707,6 +707,12 @@ void free_domain(struct domain_ent *de) free(dp->path); free(dp); } + if (de->spare_group) + free(de->spare_group); + if (de->program) + free(de->program); + if (de->table) + free(de->table); free(de); } @@ -715,7 +721,7 @@ void domainline(char *line) char *w; struct domain_ent *de; struct domain_path *path, *prev_path; - int offset, a_seen=0, m_seen=0, sg_seen=0; + int offset, a_seen=0, m_seen=0, sg_seen=0, p_seen=0, t_seen=0; de = malloc(sizeof(struct domain_ent)); if (!de) { @@ -725,6 +731,8 @@ void domainline(char *line) } de->paths = NULL; de->spare_group = NULL; + de->program = NULL; + de->table = NULL; de->action = incremental; de->st = NULL; de->next = NULL; @@ -804,6 +812,38 @@ void domainline(char *line) free_domain(de); return; } + } else if (strncasecmp("program=", w, 8) == 0) { + if (!p_seen) + p_seen = 1; + else { + fprintf(stderr, Name ": only one program= " + "entry allowed per domain line, " + "ignoring\n"); + continue; + } + de->program = strdup(w+8); + if (!de->program) { + fprintf(stderr, Name ": failed to allocate " + "memory for program\n"); + free_domain(de); + return; + } + } else if (strncasecmp("table=", w, 6) == 0) { + if (!t_seen) + t_seen = 1; + else { + fprintf(stderr, Name ": only one table= " + "entry allowed per domain line, " + "ignoring\n"); + continue; + } + de->table = strdup(w+6); + if (!de->table) { + fprintf(stderr, Name ": failed to allocate " + "memory for table\n"); + free_domain(de); + return; + } } else { fprintf(stderr, Name ": unrecognized option %s on " "domain line\n", w); @@ -853,6 +893,12 @@ void domainline(char *line) free_domain(de); return; } + if (!de->table || !de->program) { + fprintf(stderr, Name ": partition action requires " + "both a table and program setting.\n"); + free_domain(de); + return; + } } de->next = domain_list; domain_list = de; @@ -305,6 +305,14 @@ struct domain_ent { int action; struct supertype *st; struct domain_ent *next; + char *program; /* only used when action is + partition, this is the program + to call to actually partition + the drive */ + char *table; /* This is the location of a file to + pass to the partition program, + used both for setting and checking + the partitions on drives */ }; /* structures read from config file */ |