summaryrefslogtreecommitdiff
path: root/mdmon.c
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2009-10-13 17:08:33 -0700
committerDan Williams <dan.j.williams@intel.com>2009-10-13 17:41:58 -0700
commitb928b5a0384e7181425a282a0586cbbb3c85fbc3 (patch)
tree38d0603c2cdbcac85000076c2a8c05994c17f6e1 /mdmon.c
parent96a8270d46faab599b41f1cf78b4331b44c5a6be (diff)
mdmon: exec(2) when the switchroot argument is not "/"
Try to execute mdmon from the target namespace. When used for initramfs handovers we need to drop all references to the initramfs filesystem for that memory to be freed. Cc: Hans de Goede <hdegoede@redhat.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'mdmon.c')
-rw-r--r--mdmon.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mdmon.c b/mdmon.c
index 5f87e786..d3e8be56 100644
--- a/mdmon.c
+++ b/mdmon.c
@@ -369,6 +369,29 @@ int mdmon(char *devname, int devnum, int scan, char *switchroot)
dprintf("starting mdmon for %s in %s\n",
devname, switchroot ? : "/");
+
+ /* try to spawn mdmon instances from the target file system */
+ if (switchroot && strcmp(switchroot, "/") != 0) {
+ char path[1024];
+ pid_t pid;
+
+ sprintf(path, "%s/sbin/mdmon", switchroot);
+ switch (fork()) {
+ case 0:
+ execl(path, "mdmon", devname, NULL);
+ exit(1);
+ case -1:
+ return 1;
+ default:
+ pid = wait(&status);
+ if (pid > -1 && WIFEXITED(status) &&
+ WEXITSTATUS(status) == 0)
+ return 0;
+ else
+ return 1;
+ }
+ }
+
mdfd = open_dev(devnum);
if (mdfd < 0) {
fprintf(stderr, "mdmon: %s: %s\n", devname,