]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
Spawn mdmon with --offroot if mdadm was launched with --offroot
authorJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 25 Jan 2012 14:18:04 +0000 (15:18 +0100)
committerNeilBrown <neilb@suse.de>
Mon, 30 Jan 2012 01:11:29 +0000 (12:11 +1100)
Acked-by: Doug Ledford <dledford@redhat.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
mdadm.c
mdadm.h
util.c

diff --git a/mdadm.c b/mdadm.c
index 78f28d5890e6619e9fb57dfd142c395b22a028a4..1efa3e80a2eb40292f9379eb0270b17bc1584f4d 100644 (file)
--- a/mdadm.c
+++ b/mdadm.c
@@ -181,6 +181,7 @@ int main(int argc, char *argv[])
                 */
                case OffRootOpt:
                        argv[0][0] = '@';
+                       __offroot = 1;
                        continue;
 
                case ':':
diff --git a/mdadm.h b/mdadm.h
index fec93aab476b5f541b3252fc2e63beb3c26dcbb5..d862b3ed104b0c8cc02d1beaf4a4a33b33e9b5a7 100644 (file)
--- a/mdadm.h
+++ b/mdadm.h
@@ -1383,3 +1383,5 @@ static inline int xasprintf(char **strp, const char *fmt, ...) {
 
 #define PROCESS_DELAYED -2
 #define PROCESS_PENDING -3
+
+extern int __offroot;
diff --git a/util.c b/util.c
index 6985a7076204f6b11cf2b617594d968025ca8307..4ba44e61fd84574a73ea2e63d62c2a10134dbcc6 100644 (file)
--- a/util.c
+++ b/util.c
@@ -32,6 +32,8 @@
 #include       <dirent.h>
 #include       <signal.h>
 
+int __offroot;
+
 /*
  * following taken from linux/blkpg.h because they aren't
  * anywhere else and it isn't safe to #include linux/ * stuff.
@@ -1622,10 +1624,17 @@ int start_mdmon(int devnum)
                                skipped = 0;
 
                for (i=0; paths[i]; i++)
-                       if (paths[i][0])
-                               execl(paths[i], "mdmon",
-                                     devnum2devname(devnum),
-                                     NULL);
+                       if (paths[i][0]) {
+                               if (__offroot) {
+                                       execl(paths[i], "mdmon", "--offroot",
+                                             devnum2devname(devnum),
+                                             NULL);
+                               } else {
+                                       execl(paths[i], "mdmon",
+                                             devnum2devname(devnum),
+                                             NULL);
+                               }
+                       }
                exit(1);
        case -1: fprintf(stderr, Name ": cannot run mdmon. "
                         "Array remains readonly\n");