Spawn mdmon with --offroot if mdadm was launched with --offroot

Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
This commit is contained in:
Jes Sorensen 2012-01-25 15:18:04 +01:00 committed by NeilBrown
parent da827518c1
commit a0963a86e1
3 changed files with 16 additions and 4 deletions

View File

@ -181,6 +181,7 @@ int main(int argc, char *argv[])
*/ */
case OffRootOpt: case OffRootOpt:
argv[0][0] = '@'; argv[0][0] = '@';
__offroot = 1;
continue; continue;
case ':': case ':':

View File

@ -1383,3 +1383,5 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
#define PROCESS_DELAYED -2 #define PROCESS_DELAYED -2
#define PROCESS_PENDING -3 #define PROCESS_PENDING -3
extern int __offroot;

17
util.c
View File

@ -32,6 +32,8 @@
#include <dirent.h> #include <dirent.h>
#include <signal.h> #include <signal.h>
int __offroot;
/* /*
* following taken from linux/blkpg.h because they aren't * following taken from linux/blkpg.h because they aren't
* anywhere else and it isn't safe to #include linux/ * stuff. * anywhere else and it isn't safe to #include linux/ * stuff.
@ -1622,10 +1624,17 @@ int start_mdmon(int devnum)
skipped = 0; skipped = 0;
for (i=0; paths[i]; i++) for (i=0; paths[i]; i++)
if (paths[i][0]) if (paths[i][0]) {
execl(paths[i], "mdmon", if (__offroot) {
devnum2devname(devnum), execl(paths[i], "mdmon", "--offroot",
NULL); devnum2devname(devnum),
NULL);
} else {
execl(paths[i], "mdmon",
devnum2devname(devnum),
NULL);
}
}
exit(1); exit(1);
case -1: fprintf(stderr, Name ": cannot run mdmon. " case -1: fprintf(stderr, Name ": cannot run mdmon. "
"Array remains readonly\n"); "Array remains readonly\n");