public inbox for lvm-devel@lists.linux.dev
 help / color / mirror / Atom feed
From: David Teigland <teigland@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - pvck: improve error for write to existing file
Date: Fri, 28 Apr 2023 18:32:20 +0000 (GMT)	[thread overview]
Message-ID: <20230428183220.AE89B3858418@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=c4440b5b495a2d11ff541dd7e7791e2a83c83609
Commit:        c4440b5b495a2d11ff541dd7e7791e2a83c83609
Parent:        6d262eaf640dead7861c1a7716e216b9bcea75e5
Author:        David Teigland <teigland@redhat.com>
AuthorDate:    Fri Apr 28 13:31:39 2023 -0500
Committer:     David Teigland <teigland@redhat.com>
CommitterDate: Fri Apr 28 13:31:39 2023 -0500

pvck: improve error for write to existing file

---
 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)


                 reply	other threads:[~2023-04-28 18:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230428183220.AE89B3858418@sourceware.org \
    --to=teigland@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox