summaryrefslogtreecommitdiff
path: root/src/shared/machine-image.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/shared/machine-image.c')
-rw-r--r--src/shared/machine-image.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c
index 51f89d5921..fa06a0dc59 100644
--- a/src/shared/machine-image.c
+++ b/src/shared/machine-image.c
@@ -316,6 +316,21 @@ void image_hashmap_free(Hashmap *map) {
hashmap_free(map);
}
+int image_remove(Image *i) {
+ int r;
+
+ assert(i);
+
+ if (path_equal(i->path, "/") ||
+ path_startswith(i->path, "/usr"))
+ return -EROFS;
+
+ if (i->type == IMAGE_SUBVOLUME)
+ return btrfs_subvol_remove(i->path);
+ else
+ return rm_rf_dangerous(i->path, false, true, false);
+}
+
static const char* const image_type_table[_IMAGE_TYPE_MAX] = {
[IMAGE_DIRECTORY] = "directory",
[IMAGE_SUBVOLUME] = "subvolume",