mirror of
https://github.com/kdave/btrfs-progs
synced 2025-03-21 02:16:35 +00:00
btrfs-progs: delete invalid output file when btrfs-image failed
When btrfs-image failed to create an image, the invalid output file had better be deleted to prevent being used mistakenly in the future. Signed-off-by: Gui Hecheng <guihc.fnst@cn.fujitsu.com> Signed-off-by: David Sterba <dsterba@suse.cz>
This commit is contained in:
parent
08b0fdced1
commit
792ef0938d
@ -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;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user