machined: add "machinectl remove" for removing images

This commit is contained in:
Lennart Poettering
2014-12-28 02:08:40 +01:00
parent 1b9cebf638
commit 086821244b
5 changed files with 102 additions and 3 deletions
+15
View File
@@ -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",