From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Eric Sandeen <sandeen@redhat.com>
Cc: xfs <linux-xfs@vger.kernel.org>, David Shaw <dshaw@jabberwocky.com>
Subject: [PATCH] xfs_db: redirect printfs when metadumping to stdout
Date: Fri, 14 Jul 2017 16:30:32 -0700 [thread overview]
Message-ID: <20170714233032.GC4224@magnolia> (raw)
If we're metadumping to stdout, we don't want xfs_db's various dbprintf
statements dumping to stdout because that'll corrupt the metadump.
Therefore, let outf point to the existing stdout and redirect stdout to
stderr for the duration of the dump operation.
Reported-by: David Shaw <dshaw@jabberwocky.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
---
db/metadump.c | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/db/metadump.c b/db/metadump.c
index e046f60..e6e153d 100644
--- a/db/metadump.c
+++ b/db/metadump.c
@@ -2874,6 +2874,7 @@ metadump_f(
xfs_agnumber_t agno;
int c;
int start_iocur_sp;
+ bool stdout_metadump = false;
char *p;
exitcode = 1;
@@ -2989,6 +2990,8 @@ metadump_f(
return 0;
}
outf = stdout;
+ stdout = stderr;
+ stdout_metadump = true;
} else {
outf = fopen(argv[optind], "wb");
if (outf == NULL) {
@@ -3020,9 +3023,11 @@ metadump_f(
exitcode = write_index() < 0;
if (progress_since_warning)
- fputc('\n', (outf == stdout) ? stderr : stdout);
+ fputc('\n', stdout_metadump ? stderr : stdout);
- if (outf != stdout)
+ if (stdout_metadump)
+ stdout = outf;
+ else
fclose(outf);
/* cleanup iocur stack */
next reply other threads:[~2017-07-14 23:30 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-07-14 23:30 Darrick J. Wong [this message]
2017-07-15 0:37 ` [PATCH] xfs_db: redirect printfs when metadumping to stdout Eric Sandeen
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=20170714233032.GC4224@magnolia \
--to=darrick.wong@oracle.com \
--cc=dshaw@jabberwocky.com \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@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