GNU bug report logs - #6417
[Bug 591969] Re: dd bs=3G || ubuntu-bug coreutils

Previous Next

Package: coreutils;

Reported by: Jim Meyering <jim <at> meyering.net>

Date: Sun, 13 Jun 2010 19:21:02 UTC

Severity: normal

Fixed in version 8.6

Done: Pádraig Brady <P <at> draigBrady.com>

Bug is archived. No further changes may be made.

Full log


Message #14 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> CS.UCLA.EDU>
To: Jim Meyering <jim <at> meyering.net>
Cc: bug-coreutils <at> gnu.org
Subject: Re: bug#6417: [Bug 591969] Re: dd bs=3G || ubuntu-bug coreutils
Date: Mon, 12 Jul 2010 17:22:17 -0700
On 06/14/10 13:35, Jim Meyering wrote:
> Paul Eggert wrote:
>> Or, we could output both, as in "3EiB (3458764513820540928 bytes)",
>> where the first is the string and the second is the integer that
>> we converted it to.
> 
> That would be an improvement, indeed.
> ...
> You're welcome to patch further.

Thanks, I tried it out, and discovered that outputting the exact
number isn't right, since the user might complain "I asked for 1 MB;
why is it complaining about 1005000 bytes"?  Since the slop is small,
it's better to simply output the user-requested size and omit the
overhead, which is plausibly small enough to be like malloc's internal
overhead anyway.  Also, from a technical-wording point of view it's
more accurate that way, since the message talks about the buffer size,
not the malloc request size.

Anyway, I installed this; of course further improvements are welcome.

From 335b59b9625758f92ba82cd6b7138f7423df60ef Mon Sep 17 00:00:00 2001
From: Paul R. Eggert <eggert <at> cs.ucla.edu>
Date: Mon, 12 Jul 2010 17:12:43 -0700
Subject: [PATCH] dd: also spell out size on memory exhaustion

* src/dd.c (dd_copy): Use requested blocksize (not adjusted) in
diagnostic, to forestall user complaints that the numbers don't
match exactly.  Report both exact and human-readable sizes, using
a message format that is consistent with both "BBBB bytes (N XB)
copied" in dd.c and "memory exhausted" in lib/xmalloc.c.
---
 src/dd.c |   14 ++++++--------
 1 files changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/dd.c b/src/dd.c
index c9b8cbd..ab8b84c 100644
--- a/src/dd.c
+++ b/src/dd.c
@@ -1603,12 +1603,11 @@ dd_copy (void)
      It is necessary when accessing raw (i.e. character special) disk
      devices on Unixware or other SVR4-derived system.  */
 
-  size_t sz = input_blocksize + INPUT_BLOCK_SLOP;
-  real_buf = malloc (sz);
+  real_buf = malloc (input_blocksize + INPUT_BLOCK_SLOP);
   if (!real_buf)
     error (EXIT_FAILURE, 0,
-           _("failed to allocate an input buffer of size %s"),
-           human_size (sz));
+           _("memory exhausted by input buffer of size %zu bytes (%s)"),
+           input_blocksize, human_size (input_blocksize));
 
   ibuf = real_buf;
   ibuf += SWAB_ALIGN_OFFSET;	/* allow space for swab */
@@ -1618,12 +1617,11 @@ dd_copy (void)
   if (conversions_mask & C_TWOBUFS)
     {
       /* Page-align the output buffer, too.  */
-      sz = output_blocksize + OUTPUT_BLOCK_SLOP;
-      real_obuf = malloc (sz);
+      real_obuf = malloc (output_blocksize + OUTPUT_BLOCK_SLOP);
       if (!real_obuf)
         error (EXIT_FAILURE, 0,
-               _("failed to allocate an output buffer of size %s"),
-               human_size (sz));
+               _("memory exhausted by output buffer of size %zu bytes (%s)"),
+               output_blocksize, human_size (output_blocksize));
       obuf = ptr_align (real_obuf, page_size);
     }
   else
-- 
1.7.1






This bug report was last modified 14 years and 319 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.