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>
This commit is contained in:
parent
96a8270d46
commit
b928b5a038
23
mdmon.c
23
mdmon.c
|
@ -369,6 +369,29 @@ int mdmon(char *devname, int devnum, int scan, char *switchroot)
|
||||||
|
|
||||||
dprintf("starting mdmon for %s in %s\n",
|
dprintf("starting mdmon for %s in %s\n",
|
||||||
devname, switchroot ? : "/");
|
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);
|
mdfd = open_dev(devnum);
|
||||||
if (mdfd < 0) {
|
if (mdfd < 0) {
|
||||||
fprintf(stderr, "mdmon: %s: %s\n", devname,
|
fprintf(stderr, "mdmon: %s: %s\n", devname,
|
||||||
|
|
Loading…
Reference in New Issue