From 097c0ef1870e64667f85e689286228035af8323e Mon Sep 17 00:00:00 2001 From: Doug Ledford Date: Thu, 15 Apr 2010 17:38:37 -0400 Subject: Added sanity checks on DOMAIN lines, add an action_mask value Signed-off-by: Doug Ledford --- config.c | 16 ++++++++++++++-- mdadm.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/config.c b/config.c index a1eb9dd..55c7ba6 100644 --- a/config.c +++ b/config.c @@ -811,10 +811,10 @@ void domainline(char *line) } /* Some sanity checks now that all the options are parsed */ if ((de->action & force) && - ((de->action & (force - 1)) <= incremental)) { + ((de->action & action_mask) <= incremental)) { fprintf(stderr, Name ": force makes no sense with ignore or " "incremental, removing.\n"); - de->action &= (force - 1); + de->action &= action_mask; } if (de->spare_group && de->action <= incremental) { fprintf(stderr, Name ": defined a spare group when we aren't " @@ -822,6 +822,18 @@ void domainline(char *line) free(de->spare_group); de->spare_group = NULL; } + if ((de->action & action_mask) == partition) + for (path = de->paths; path; path = path->next) + if ((strstr(path->path, "part") != NULL) || + (path->path[strlen(path->path) - 1] == '*')) { + fprintf(stderr, Name ": partition method only " + "allowed on whole disks, not on " + "partitions\n"); + fprintf(stderr, Name ": bad path=%s\n", + path->path); + free_domain(de); + return; + } de->next = domain_list; domain_list = de; } diff --git a/mdadm.h b/mdadm.h index e090920..6b50953 100644 --- a/mdadm.h +++ b/mdadm.h @@ -286,6 +286,7 @@ enum domain_actions { appropriate things with the partitions */ spare, grow, + action_mask=511, force=512, /* so we can bitwise & this with actions to signify we should forcibly take over drives even if they have other metadata on them */ -- cgit