From: Pádraig Brady
Date: Thu, 18 Jul 2013 17:39:55 +0000 (+0100)
Subject: dd: make status=none suppress all diagnostics
X-Git-Tag: v8.22~103
X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e6fc265b755eef0eae425caec3f93b8e28dbdddb;p=thirdparty%2Fcoreutils.git
dd: make status=none suppress all diagnostics
* src/dd.c (STATUS_NONE): Simplify the enum so that
it's more general than just suppressing transfer counts.
Then test this in all locations where non fatal diagnostics
are output.
* tests/dd/misc.sh: Ensure the diagnostic about
being unable to skip past the end of input is suppressed.
* NEWS: Mention the change in behavior.
Fixes http://bugs.gnu.org/14897
---
diff --git a/NEWS b/NEWS
index 5abaf81f1b..62181ec8de 100644
--- a/NEWS
+++ b/NEWS
@@ -51,6 +51,9 @@ GNU coreutils NEWS -*- outline -*-
** Changes in behavior
+ dd status=none now suppresses all non fatal diagnostic messages,
+ not just the transfer counts.
+
stdbuf now requires at least one buffering mode option to be specified,
as per the documented interface.
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
index ca10a16ff8..b8d40b4f5b 100644
--- a/doc/coreutils.texi
+++ b/doc/coreutils.texi
@@ -8548,7 +8548,7 @@ that normally make up the last status line.
@item none
@opindex none @r{dd status=}
-Do not print any informational messages to stderr.
+Do not print any informational or warning messages to stderr.
Error messages are output as normal.
@end table
diff --git a/src/dd.c b/src/dd.c
index f727a5ef9f..59d6cd1dcb 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -136,9 +136,7 @@ enum
enum
{
STATUS_NOXFER = 01,
- STATUS_NOCOUNTS = 02,
- STATUS_LAST = STATUS_NOCOUNTS,
- STATUS_NONE = STATUS_LAST | (STATUS_LAST - 1)
+ STATUS_NONE = 02
};
/* The name of the input file, or NULL for the standard input. */
@@ -738,7 +736,7 @@ print_stats (void)
double delta_s;
char const *bytes_per_second;
- if ((status_flags & STATUS_NONE) == STATUS_NONE)
+ if (status_flags & STATUS_NONE)
return;
fprintf (stderr,
@@ -1031,12 +1029,13 @@ iread (int fd, char *buf, size_t size)
if (0 < prev_nread && prev_nread < size)
{
uintmax_t prev = prev_nread;
- error (0, 0, ngettext (("warning: partial read (%"PRIuMAX" byte); "
- "suggest iflag=fullblock"),
- ("warning: partial read (%"PRIuMAX" bytes); "
- "suggest iflag=fullblock"),
- select_plural (prev)),
- prev);
+ if (!(status_flags & STATUS_NONE))
+ error (0, 0, ngettext (("warning: partial read (%"PRIuMAX" byte); "
+ "suggest iflag=fullblock"),
+ ("warning: partial read (%"PRIuMAX" bytes); "
+ "suggest iflag=fullblock"),
+ select_plural (prev)),
+ prev);
warn_partial_read = false;
}
@@ -1080,7 +1079,8 @@ iwrite (int fd, char const *buf, size_t size)
if ((output_flags & O_DIRECT) && size < output_blocksize)
{
int old_flags = fcntl (STDOUT_FILENO, F_GETFL);
- if (fcntl (STDOUT_FILENO, F_SETFL, old_flags & ~O_DIRECT) != 0)
+ if (fcntl (STDOUT_FILENO, F_SETFL, old_flags & ~O_DIRECT) != 0
+ && !(status_flags & STATUS_NONE))
error (0, errno, _("failed to turn off O_DIRECT: %s"),
quote (output_file));
@@ -1573,9 +1573,11 @@ skip_via_lseek (char const *filename, int fdesc, off_t offset, int whence)
&& ioctl (fdesc, MTIOCGET, &s2) == 0
&& MT_SAME_POSITION (s1, s2))
{
- error (0, 0, _("warning: working around lseek kernel bug for file (%s)\n\
- of mt_type=0x%0lx -- see