From 4c2d96e62a081aa0441a7724323a45035413da56 Mon Sep 17 00:00:00 2001 From: Peter Jones Date: Fri, 19 Jun 2009 15:21:59 -0400 Subject: [PATCH] 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 --- sys-utils/switch_root.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) 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); } -- 2.39.5