summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2023-05-15 21:31:38 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2023-05-17 01:42:01 +0900
commit84b4c7857098cebce91fc98c61696b19e79ab53f (patch)
treea33a18542986cf59cebcd5e33084fcb6a7f3a4d7
parent871a41f0ef60cc33528dc249cb1358d0f3c1a3bc (diff)
downloadsystemd-84b4c7857098cebce91fc98c61696b19e79ab53f.tar.gz
switch-root: add a comment regarding the safety limits of rm_rf_children()
-rw-r--r--src/shared/switch-root.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/shared/switch-root.c b/src/shared/switch-root.c
index fa438b3c06..1ee06c8ee4 100644
--- a/src/shared/switch-root.c
+++ b/src/shared/switch-root.c
@@ -130,6 +130,8 @@ int switch_root(const char *new_root,
if (fstat(old_root_fd, &rb) < 0)
return log_error_errno(errno, "Failed to stat old root directory: %m");
+ /* Note: the below won't operate on non-memory file systems (i.e. only on tmpfs, ramfs), and
+ * it will stop at mount boundaries */
(void) rm_rf_children(TAKE_FD(old_root_fd), 0, &rb); /* takes possession of the dir fd, even on failure */
}