From: Peter Jones Date: Fri, 19 Jun 2009 19:21:59 +0000 (-0400) Subject: switch_root: fork before cleaning up the filesystem. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4c2d96e62a081aa0441a7724323a45035413da56;p=util-linux switch_root: fork before cleaning up the filesystem. Fork before cleaning up the old filesystem, so it becomes asyncronous, which results in a faster boot time. Signed-off-by: Peter Jones --- diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index 75725e70..1de3a2e5 100644 --- a/sys-utils/switch_root.c +++ b/sys-utils/switch_root.c @@ -114,6 +114,7 @@ static int switchroot(const char *newroot) const char *umounts[] = { "/dev", "/proc", "/sys", NULL }; int i; int cfd; + pid_t pid; for (i = 0; umounts[i] != NULL; i++) { char newmount[PATH_MAX]; @@ -135,7 +136,12 @@ static int switchroot(const char *newroot) cfd = open("/", O_RDONLY); if (cfd >= 0) { - recursiveRemove(cfd); + pid = fork(); + if (pid <= 0) { + recursiveRemove(cfd); + if (pid == 0) + exit(EXIT_SUCCESS); + } close(cfd); }