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;
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 */
r = rm_rf_children(fd, flags, NULL);
if (flags & REMOVE_ROOT) {
-
if (rmdir(path) < 0 && errno != ENOENT) {
if (r == 0)
r = -errno;