summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Teigland <teigland@redhat.com>2023-04-28 13:31:39 -0500
committerDavid Teigland <teigland@redhat.com>2023-04-28 13:31:39 -0500
commitc4440b5b495a2d11ff541dd7e7791e2a83c83609 (patch)
treeb015e06adb166a84726bba8afc5643ae3b5ec82d
parent6d262eaf640dead7861c1a7716e216b9bcea75e5 (diff)
downloadlvm2-c4440b5b495a2d11ff541dd7e7791e2a83c83609.tar.gz
pvck: improve error for write to existing file
-rw-r--r--tools/pvck.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/pvck.c b/tools/pvck.c
index 879810b76..0998caaf5 100644
--- a/tools/pvck.c
+++ b/tools/pvck.c
@@ -1444,8 +1444,13 @@ static int _dump_metadata(struct cmd_context *cmd, const char *dump, struct sett
int bad = 0;
if (arg_is_set(cmd, file_ARG)) {
+ struct stat sb;
if (!(tofile = arg_str_value(cmd, file_ARG, NULL)))
return 0;
+ if (!stat(tofile, &sb)) {
+ log_error("File already exists.");
+ return 0;
+ }
}
if (set->mda_num)