chiark / gitweb /
Prep v228: With most functions split out, clean up the enormous includes list in...
[elogind.git] / src / basic / rm-rf.c
index d35d172958fb6ea3f3cc154f72e5d3f3cfff9a76..7a96295ba64bfbcb4972aab9cddcb940e97723b3 100644 (file)
   along with systemd; If not, see <http://www.gnu.org/licenses/>.
 ***/
 
-#include "util.h"
+//#include "btrfs-util.h"
+#include "fd-util.h"
+#include "mount-util.h"
 #include "path-util.h"
-// #include "btrfs-util.h"
 #include "rm-rf.h"
+#include "stat-util.h"
+#include "string-util.h"
+#include "util.h"
 
 int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
         _cleanup_closedir_ DIR *d = NULL;
@@ -120,9 +124,10 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
                         if ((flags & REMOVE_SUBVOLUME) && st.st_ino == 256) {
 
                                 /* This could be a subvolume, try to remove it */
-                                r = btrfs_subvol_remove_fd(fd, de->d_name, true);
+
+                                r =  btrfs_subvol_remove_fd(fd, de->d_name, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);;
                                 if (r < 0) {
-                                       if (r != -ENOTTY && r != -EINVAL) {
+                                        if (r != -ENOTTY && r != -EINVAL) {
                                                 if (ret == 0)
                                                         ret = r;
 
@@ -138,7 +143,7 @@ int rm_rf_children(int fd, RemoveFlags flags, struct stat *root_dev) {
                                         safe_close(subdir_fd);
                                         continue;
                                 }
-                       }
+                        }
 #endif // 0
 
                         /* We pass REMOVE_PHYSICAL here, to avoid
@@ -177,18 +182,19 @@ int rm_rf(const char *path, RemoveFlags flags) {
                 return -EPERM;
         }
 
+#if 0
         if ((flags & (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) == (REMOVE_SUBVOLUME|REMOVE_ROOT|REMOVE_PHYSICAL)) {
                 /* Try to remove as subvolume first */
-#if 0
-               r = btrfs_subvol_remove(path, true);
+                r = btrfs_subvol_remove(path, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA);
                 if (r >= 0)
                         return r;
 
                 if (r != -ENOTTY && r != -EINVAL && r != -ENOTDIR)
                         return r;
-#endif // 0
+
                 /* Not btrfs or not a subvolume */
         }
+#endif // 0
 
         fd = open(path, O_RDONLY|O_NONBLOCK|O_DIRECTORY|O_CLOEXEC|O_NOFOLLOW|O_NOATIME);
         if (fd < 0) {