chiark / gitweb /
btrfs: support recursively removing btrfs snapshots
[elogind.git] / src / shared / machine-image.c
index c5808af81efe27dfb13cdf6805f9b3b3318a3d25..fb72123f1a80e43b2ee2b38dc66c87c63a089089 100644 (file)
@@ -358,16 +358,18 @@ int image_remove(Image *i) {
         switch (i->type) {
 
         case IMAGE_SUBVOLUME:
-                return btrfs_subvol_remove(i->path);
+                return btrfs_subvol_remove(i->path, true);
 
         case IMAGE_DIRECTORY:
                 /* Allow deletion of read-only directories */
                 (void) chattr_path(i->path, false, FS_IMMUTABLE_FL);
-
-                /* fall through */
+                return rm_rf(i->path, REMOVE_ROOT|REMOVE_PHYSICAL|REMOVE_SUBVOLUME);
 
         case IMAGE_RAW:
-                return rm_rf(i->path, REMOVE_ROOT|REMOVE_PHYSICAL);
+                if (unlink(i->path) < 0)
+                        return -errno;
+
+                return 0;
 
         default:
                 return -EOPNOTSUPP;