dd: call fsync() only once before exiting if conv=fsync is specified
authorRostislav Skudnov <rostislav@tuxera.com>
Thu, 16 Mar 2017 19:54:35 +0000 (20:54 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Thu, 16 Mar 2017 19:54:35 +0000 (20:54 +0100)
Signed-off-by: Rostislav Skudnov <rostislav@tuxera.com>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
coreutils/dd.c

index 5e68087fc708016291668d3a42e40f4db2d678ae..7d980f1c45d19be0a38d213f9d4df9b1cf172ccf 100644 (file)
@@ -532,11 +532,11 @@ int dd_main(int argc UNUSED_PARAM, char **argv)
                        if (write_and_stats(ibuf, n, obs, outfile))
                                goto out_status;
                }
+       }
 
-               if (G.flags & FLAG_FSYNC) {
-                       if (fsync(ofd) < 0)
-                               goto die_outfile;
-               }
+       if (G.flags & FLAG_FSYNC) {
+               if (fsync(ofd) < 0)
+                       goto die_outfile;
        }
 
        if (ENABLE_FEATURE_DD_IBS_OBS && oc) {