summaryrefslogtreecommitdiff
path: root/src/core/switch-root.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/switch-root.c')
-rw-r--r--src/core/switch-root.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/core/switch-root.c b/src/core/switch-root.c
index efc7d345e1..150332a858 100644
--- a/src/core/switch-root.c
+++ b/src/core/switch-root.c
@@ -115,6 +115,12 @@ int switch_root(const char *new_root) {
goto fail;
}
+ if (chdir("/") < 0) {
+ r = -errno;
+ log_error("Failed to change directory: %m");
+ goto fail;
+ }
+
if (old_root_fd >= 0) {
struct stat rb;