lvm2/SOURCES/0005-pvck-improve-error-for...

32 lines
834 B
Diff

From 0a9228807d0b3901be4ccf29311a955efba4877e Mon Sep 17 00:00:00 2001
From: David Teigland <teigland@redhat.com>
Date: Fri, 28 Apr 2023 13:31:39 -0500
Subject: [PATCH 5/8] pvck: improve error for write to existing file
(cherry picked from commit c4440b5b495a2d11ff541dd7e7791e2a83c83609)
---
tools/pvck.c | 5 +++++
1 file changed, 5 insertions(+)
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)
--
2.40.1