summaryrefslogtreecommitdiff
path: root/btrfs-image.c
diff options
context:
space:
mode:
Diffstat (limited to 'btrfs-image.c')
-rw-r--r--btrfs-image.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/btrfs-image.c b/btrfs-image.c
index 8ad488d5..c03a98d6 100644
--- a/btrfs-image.c
+++ b/btrfs-image.c
@@ -2607,10 +2607,20 @@ int main(int argc, char *argv[])
}
out:
- if (out == stdout)
+ if (out == stdout) {
fflush(out);
- else
+ } else {
fclose(out);
+ if (ret && create) {
+ int unlink_ret;
+
+ unlink_ret = unlink(target);
+ if (unlink_ret)
+ fprintf(stderr,
+ "unlink output file failed : %s\n",
+ strerror(errno));
+ }
+ }
return !!ret;
}