diff options
author | NeilBrown <neilb@suse.de> | 2013-08-05 14:55:13 +1000 |
---|---|---|
committer | NeilBrown <neilb@suse.de> | 2013-08-05 14:55:13 +1000 |
commit | 9540cc244dfc56d40f686d8f63aa5b6d73663bcf (patch) | |
tree | d41a15af6b6cce11cad6dce23cab744d8df72f2a /util.c | |
parent | 4389b648bb9dc8ab61ce8777654d59634dafc737 (diff) | |
download | mdadm-9540cc244dfc56d40f686d8f63aa5b6d73663bcf.tar.gz |
test: ensure testing uses correct mdmon
When testing we want to run mdmon directly, not use
systemctl to get systemd to run it.
So allow an environment variable to make that choice.
Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r-- | util.c | 63 |
1 files changed, 33 insertions, 30 deletions
@@ -1711,36 +1711,39 @@ int start_mdmon(char *devnm) pathbuf[0] = '\0'; /* First try to run systemctl */ - switch(fork()) { - case 0: - /* FIXME yuk. CLOSE_EXEC?? */ - skipped = 0; - for (i = 3; skipped < 20; i++) - if (close(i) < 0) - skipped++; - else - skipped = 0; - - /* Don't want to see error messages from systemctl. - * If the service doesn't exist, we start mdmon ourselves. - */ - close(2); - open("/dev/null", O_WRONLY); - snprintf(pathbuf, sizeof(pathbuf), "mdmon@%s.service", - devnm); - status = execl("/usr/bin/systemctl", "systemctl", "start", - pathbuf, NULL); - status = execl("/bin/systemctl", "systemctl", "start", - pathbuf, NULL); - exit(1); - case -1: pr_err("cannot run mdmon. " - "Array remains readonly\n"); - return -1; - default: /* parent - good */ - pid = wait(&status); - if (pid >= 0 && status == 0) - return 0; - } + if (!check_env("MDADM_NO_SYSTEMCTL")) + switch(fork()) { + case 0: + /* FIXME yuk. CLOSE_EXEC?? */ + skipped = 0; + for (i = 3; skipped < 20; i++) + if (close(i) < 0) + skipped++; + else + skipped = 0; + + /* Don't want to see error messages from + * systemctl. If the service doesn't exist, + * we start mdmon ourselves. + */ + close(2); + open("/dev/null", O_WRONLY); + snprintf(pathbuf, sizeof(pathbuf), "mdmon@%s.service", + devnm); + status = execl("/usr/bin/systemctl", "systemctl", + "start", + pathbuf, NULL); + status = execl("/bin/systemctl", "systemctl", "start", + pathbuf, NULL); + exit(1); + case -1: pr_err("cannot run mdmon. " + "Array remains readonly\n"); + return -1; + default: /* parent - good */ + pid = wait(&status); + if (pid >= 0 && status == 0) + return 0; + } /* That failed, try running mdmon directly */ switch(fork()) { |