X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=blobdiff_plain;f=src%2Fshared%2Fmachine-image.c;h=f166e9410d0f1385cdad959a92a92cb8687c2e3c;hb=2c2ecbebd3913607d833617230dc904a05ce0999;hp=00337e7c9fe03a6c208e0e16034d45cc5b9bcc71;hpb=f85ef957e647c5182acf5e64298f68e4b7fbfe8f;p=elogind.git diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index 00337e7c9..f166e9410 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -28,6 +28,7 @@ #include "path-util.h" #include "copy.h" #include "mkdir.h" +#include "rm-rf.h" #include "machine-image.h" static const char image_search_path[] = @@ -362,14 +363,16 @@ int image_remove(Image *i) { 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_dangerous(i->path, false, true, false); + if (unlink(i->path) < 0) + return -errno; + + return 0; default: - return -ENOTSUP; + return -EOPNOTSUPP; } } @@ -430,7 +433,7 @@ int image_rename(Image *i, const char *new_name) { } default: - return -ENOTSUP; + return -EOPNOTSUPP; } if (!new_path) @@ -498,7 +501,7 @@ int image_clone(Image *i, const char *new_name, bool read_only) { break; default: - return -ENOTSUP; + return -EOPNOTSUPP; } if (r < 0) @@ -563,7 +566,7 @@ int image_read_only(Image *i, bool b) { } default: - return -ENOTSUP; + return -EOPNOTSUPP; } return 0; @@ -622,7 +625,7 @@ int image_set_limit(Image *i, uint64_t referenced_max) { return -EROFS; if (i->type != IMAGE_SUBVOLUME) - return -ENOTSUP; + return -EOPNOTSUPP; return btrfs_quota_limit(i->path, referenced_max); }