Kexec Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Rudo <prudo@redhat.com>
To: kexec@lists.infradead.org
Cc: k-hagio-ab@nec.com
Subject: [PATCH 1/2] makedumpfile: Fix bad file descriptor error when using --dry-run
Date: Thu, 12 Aug 2021 15:39:39 +0200	[thread overview]
Message-ID: <20210812133940.5370-2-prudo@redhat.com> (raw)
In-Reply-To: <20210812133940.5370-1-prudo@redhat.com>

When running makedumpfile with the --dry-run option it fails with

	[...]
	write_and_check_space: Can't seek the dump file(vmcore). Bad file descriptor
	[...]

This is because for --dry-run no dump file is created and a dummy file
descriptor of -1 is used. Thus the lseek in write_and_check_space will
fail. Fix this by treating a dry run as if writing to STDOUT.

Fixes: f0cfa86 ("[PATCH v2 3/3] Add -L option to limit output file size")
Signed-off-by: Philipp Rudo <prudo@redhat.com>
---
 makedumpfile.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/makedumpfile.c b/makedumpfile.c
index b1b3b42..30f9725 100644
--- a/makedumpfile.c
+++ b/makedumpfile.c
@@ -4712,7 +4712,7 @@ write_and_check_space(int fd, void *buf, size_t buf_size, const char* desc,
 	int retval = 0;
 	off_t pos;
 
-	if (fd == STDOUT_FILENO) {
+	if (fd == STDOUT_FILENO || info->flag_dry_run) {
 		pos = write_bytes;
 	} else {
 		pos = lseek(fd, 0, SEEK_CUR);
-- 
2.31.1


_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec

  reply	other threads:[~2021-08-12 13:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-12 13:39 [PATCH 0/2] makedumpfile: fix two bugs with --dry-run Philipp Rudo
2021-08-12 13:39 ` Philipp Rudo [this message]
2021-08-12 13:39 ` [PATCH 2/2] makedumpfile: Fix --dry-run for incomplete dumps Philipp Rudo
2021-08-16  2:54 ` [PATCH 0/2] makedumpfile: fix two bugs with --dry-run HAGIO KAZUHITO(萩尾 一仁)

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=20210812133940.5370-2-prudo@redhat.com \
    --to=prudo@redhat.com \
    --cc=k-hagio-ab@nec.com \
    --cc=kexec@lists.infradead.org \
    /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