switch-root: add a comment regarding the safety limits of rm_rf_children()

This commit is contained in:
Lennart Poettering
2023-05-15 21:31:38 +02:00
committed by Yu Watanabe
parent 871a41f0ef
commit 84b4c78570

View File

@@ -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 */
}