diff options
author | Lennart Poettering <lennart@poettering.net> | 2014-12-27 02:35:47 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2014-12-28 02:08:40 +0100 |
commit | 086821244b5113f00a0ef993b78dc56aae2a8f6c (patch) | |
tree | 296492582d2fc44697d98505907e3a0ab678451c /src/shared/machine-image.c | |
parent | 1b9cebf6385b5ea0e5ea099da163687013ac7790 (diff) |
machined: add "machinectl remove" for removing images
Diffstat (limited to 'src/shared/machine-image.c')
-rw-r--r-- | src/shared/machine-image.c | 15 |
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", |