From 5bbb48424bb461bab9b883f37ac82c8d2405f49e Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Mon, 15 May 2006 06:02:41 +0000 Subject: Allow default creation info to to be stored in mdadm.conf Default owner, group, mode and 'auto' flag can be given in a 'CREATE' line. Signed-off-by: Neil Brown --- mdadm.c | 37 +++---------------------------------- 1 file changed, 3 insertions(+), 34 deletions(-) (limited to 'mdadm.c') diff --git a/mdadm.c b/mdadm.c index 7f10948..119b749 100644 --- a/mdadm.c +++ b/mdadm.c @@ -75,7 +75,8 @@ int main(int argc, char *argv[]) int force = 0; int test = 0; int assume_clean = 0; - int autof = 0; /* -2 means create device based on name: + int autof = 0; /* -3 means don't create anything, + * -2 means create device based on name: * if it ends mdN, then non-partitioned array N * if it ends dN, then partitions array N * -1 means create non-partitioned, choose N @@ -482,39 +483,7 @@ int main(int argc, char *argv[]) case O(CREATE,'a'): case O(BUILD,'a'): case O(ASSEMBLE,'a'): /* auto-creation of device node */ - if (optarg == NULL) - autof = -2; - else if (strcasecmp(optarg,"no")==0) - autof = 0; - else if (strcasecmp(optarg,"yes")==0) - autof = -2; - else if (strcasecmp(optarg,"md")==0) - autof = -1; - else { - /* There might be digits, and maybe a hypen, at the end */ - char *e = optarg + strlen(optarg); - int num = 4; - int len; - while (e > optarg && isdigit(e[-1])) - e--; - if (*e) { - num = atoi(e); - if (num <= 0) num = 1; - } - if (e > optarg && e[-1] == '-') - e--; - len = e - optarg; - if ((len == 3 && strncasecmp(optarg,"mdp",3)==0) || - (len == 1 && strncasecmp(optarg,"p",1)==0) || - (len >= 4 && strncasecmp(optarg,"part",4)==0)) - autof = num; - else { - fprintf(stderr, Name ": --auto flag arg of \"%s\" unrecognised: use no,yes,md,mdp,part\n" - " optionally followed by a number.\n", - optarg); - exit(2); - } - } + autof = parse_auto(optarg, "--auto flag"); continue; case O(BUILD,'f'): /* force honouring '-n 1' */ -- cgit