From: Lennart Poettering Date: Wed, 4 Oct 2017 15:42:23 +0000 (+0200) Subject: machine-image: handle nicely if the user asks us to remove a symlinked image X-Git-Tag: v236~280^2~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=9fb0b9c70d8cf04ae000a3431a2ccf9e8b8b798c;p=platform%2Fupstream%2Fsystemd.git machine-image: handle nicely if the user asks us to remove a symlinked image Much like for dirs/raw images lets remove the symlink and not the destination. --- diff --git a/src/shared/machine-image.c b/src/shared/machine-image.c index a8af1b7..24209fa 100644 --- a/src/shared/machine-image.c +++ b/src/shared/machine-image.c @@ -483,9 +483,15 @@ int image_remove(Image *i) { switch (i->type) { case IMAGE_SUBVOLUME: - r = btrfs_subvol_remove(i->path, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA); - if (r < 0) - return r; + + /* Let's unlink first, maybe it is a symlink? If that works we are happy. Otherwise, let's get out the + * big guns */ + if (unlink(i->path) < 0) { + r = btrfs_subvol_remove(i->path, BTRFS_REMOVE_RECURSIVE|BTRFS_REMOVE_QUOTA); + if (r < 0) + return r; + } + break; case IMAGE_DIRECTORY: