dd: warn when we disable oflag=direct not at EOF
authorPádraig Brady <P@draigBrady.com>
Fri, 25 Feb 2011 12:27:25 +0000 (12:27 +0000)
committerPádraig Brady <P@draigBrady.com>
Sat, 5 Mar 2011 01:48:55 +0000 (01:48 +0000)
An alternative to this is to auto enable iflag=fullblock
when oflag=direct and bs= is specified.
It was thought better though, to warn about the specific issue,
and give full control of dd's options to the user.

* src/dd.c (iwrite): Warn, when we write after having
disabled O_DIRECT.
See https://bugzilla.redhat.com/show_bug.cgi?id=614605

src/dd.c

index daddc1e..fd468a6 100644 (file)
--- a/src/dd.c
+++ b/src/dd.c
@@ -837,6 +837,12 @@ iwrite (int fd, char const *buf, size_t size)
 {
   size_t total_written = 0;
 
+  if ((output_flags & O_DIRECT) && w_partial == 1)
+    {
+      error (0, 0, _("dd: warning: partial read; oflag=direct disabled; "
+                     "suggest iflag=fullblock"));
+    }
+
   if ((output_flags & O_DIRECT) && size < output_blocksize)
     {
       int old_flags = fcntl (STDOUT_FILENO, F_GETFL);