[systemd-devel] [PATCH] main: do_switch_root() do not recursively remove across device boundaries

harald at redhat.com harald at redhat.com
Wed May 16 06:08:28 PDT 2012


From: Harald Hoyer <harald at redhat.com>

---
 src/core/main.c |    9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/core/main.c b/src/core/main.c
index a816015..e8bcbe7 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -1234,7 +1234,14 @@ static int do_switch_root(const char *switch_root) {
         }
 
         if (cfd >= 0) {
-                rm_rf_children(cfd, false, false);
+                struct stat rb;
+
+                if (fstat(cfd, &rb)) {
+                        log_error("failed to stat old root directory");
+                        goto fail;
+                }
+
+                rm_rf_children(cfd, false, false, &rb);
                 close(cfd);
                 cfd=-1;
         }
-- 
1.7.10.1



More information about the systemd-devel mailing list