diff options
author | Peter Jones | 2009-06-19 21:21:59 +0200 |
---|---|---|
committer | Karel Zak | 2009-06-22 21:45:25 +0200 |
commit | 4c2d96e62a081aa0441a7724323a45035413da56 (patch) | |
tree | 2b2e6801a7b4ab086989be250a653c8f29213b91 /sys-utils/switch_root.c | |
parent | switch_root: use file descriptor instead of path for recursiveRemove() (diff) | |
download | kernel-qcow2-util-linux-4c2d96e62a081aa0441a7724323a45035413da56.tar.gz kernel-qcow2-util-linux-4c2d96e62a081aa0441a7724323a45035413da56.tar.xz kernel-qcow2-util-linux-4c2d96e62a081aa0441a7724323a45035413da56.zip |
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 <pjones@redhat.com>
Diffstat (limited to 'sys-utils/switch_root.c')
-rw-r--r-- | sys-utils/switch_root.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/sys-utils/switch_root.c b/sys-utils/switch_root.c index 75725e707..1de3a2e58 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); } |