switch-root: modernize rm_rf_children() invocation a bit

This commit is contained in:
Lennart Poettering
2019-04-29 16:17:29 +02:00
parent 51aba17b88
commit c0ba6b9286
2 changed files with 4 additions and 6 deletions
+2 -2
View File
@@ -33,8 +33,8 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
assert(fd >= 0);
/* This returns the first error we run into, but nevertheless
* tries to go on. This closes the passed fd. */
/* This returns the first error we run into, but nevertheless tries to go on. This closes the passed
* fd, in all cases, including on failure.. */
if (!(flags & REMOVE_PHYSICAL)) {
+2 -4
View File
@@ -120,10 +120,8 @@ int switch_root(const char *new_root,
if (fstat(old_root_fd, &rb) < 0)
log_warning_errno(errno, "Failed to stat old root directory, leaving: %m");
else {
(void) rm_rf_children(old_root_fd, 0, &rb);
old_root_fd = -1;
}
else
(void) rm_rf_children(TAKE_FD(old_root_fd), 0, &rb); /* takes possession of the dir fd, even on failure */
}
return 0;