diff options
Diffstat (limited to 'src/shared/rm-rf.c')
-rw-r--r-- | src/shared/rm-rf.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/shared/rm-rf.c b/src/shared/rm-rf.c index 99d12b11c6..eeb2e39196 100644 --- a/src/shared/rm-rf.c +++ b/src/shared/rm-rf.c @@ -89,7 +89,7 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) { if (is_dir) { int subdir_fd; - /* if root_dev is set, remove subdirectories only, if device is same as dir */ + /* if root_dev is set, remove subdirectories only if device is same */ if (root_dev && st.st_dev != root_dev->st_dev) continue; @@ -100,6 +100,20 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) { continue; } + /* Stop at mount points */ + r = fd_is_mount_point(subdir_fd); + if (r < 0) { + if (ret == 0 && r != -ENOENT) + ret = r; + + safe_close(subdir_fd); + continue; + } + if (r) { + safe_close(subdir_fd); + continue; + } + /* We pass REMOVE_PHYSICAL here, to avoid * doing the fstatfs() to check the file * system type again for each directory */ @@ -162,7 +176,6 @@ int rm_rf(const char *path, RemoveFlags flags) { r = rm_rf_children(fd, flags, NULL); if (flags & REMOVE_ROOT) { - if (rmdir(path) < 0 && errno != ENOENT) { if (r == 0) r = -errno; |