bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

make 'dd conv=sync' pad last block


From: Scott Weikart
Subject: make 'dd conv=sync' pad last block
Date: Sat, 5 Jun 2004 16:56:26 -0700

I want to fit the maximum amount of data on a tape using tar.

tar seems to be the most space-efficient with --blocking-factor=2 .
The tape should be  most space-efficient with a large record
size.  So, I tried to do:

  tar cfb - 2 $files | dd of=/dev/nst0 obs=128k conv=sync

But GNU dd in coreutils-5.2.1 doesn't pad the final output block.  Here's a
patch to make it add the padding.

-scott

==================================================================

--- src/dd.c~   Wed Jan 21 14:27:02 2004
+++ src/dd.c    Sat Jun  5 16:43:15 2004
@@ -1116,7 +1116,15 @@
   /* Write out the last block. */
   if (oc != 0)
     {
-      size_t nwritten = full_write (STDOUT_FILENO, obuf, oc);
+      size_t nwritten;
+      if ((conversions_mask & C_SYNC) && (oc < output_blocksize))
+        {
+         memset(obuf + oc,
+                (conversions_mask & (C_BLOCK | C_UNBLOCK)) ? ' ' : '\0',
+                output_blocksize - oc);
+         oc = output_blocksize;
+       }
+      nwritten = full_write (STDOUT_FILENO, obuf, oc);
       if (nwritten != 0)
        w_partial++;
       if (nwritten != oc)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]