GNU bug report logs -
#9157
[PATCH] dd: sparse conv flag
Previous Next
Reported by: Roman Rybalko <devel <at> romanr.info>
Date: Sat, 23 Jul 2011 22:42:04 UTC
Severity: normal
Tags: patch
Done: Pádraig Brady <P <at> draigBrady.com>
Bug is archived. No further changes may be made.
Full log
Message #17 received at 9157 <at> debbugs.gnu.org (full text, mbox):
On 10.12.2011 14:09, Jim Meyering wrote:
> Here are some things we'll have to consider before
> adding a new hole-punching option to dd:
>
> Your patch may create a hole in the destination for each sequence of
> length seek_size or greater of zero bytes in the input.
> As you may have seen in the cp-related discussion, one may
> want different options:
> - preserve a file's hole/non-hole structure
> - efficiently detect existing holes and fill them with explicit zeros in dest
> - efficiently detect existing holes and seek-in-dest for each sequence of
> zeros (longer than some minimum) in non-hole input
Okay, I'll think about that.
That's a clear task.
>> diff --git a/doc/coreutils.texi b/doc/coreutils.texi
>> index 424446c..761c698 100644
>> --- a/doc/coreutils.texi
>> +++ b/doc/coreutils.texi
>> @@ -8127,6 +8127,10 @@ Pad every input block to size of @samp{ibs} with trailing zero bytes.
>> When used with @samp{block} or @samp{unblock}, pad with spaces instead of
>> zero bytes.
>>
>> +@item sparse
>> +@opindex sparse
>> +Make sparse output file.
> Please say a little more here.
> I.e., when might a hole be introduced?
> When is this option useful?
Okay.
>> @@ -985,6 +990,21 @@ iwrite (int fd, char const *buf, size_t size)
>> {
>> ssize_t nwritten;
>> process_signals ();
>> + if (conversions_mask & C_SPARSE)
>> + {
>> + off_t seek_size = 0;
>> + while (total_written + seek_size < size && buf[total_written + seek_size] == 0)
>> + ++seek_size;
>> + if (seek_size)
>> + {
>> + off_t cur_off = 0;
>> + cur_off = lseek(fd, seek_size, SEEK_CUR);
>> + if (cur_off < 0)
>> + break;
> dd must not ignore lseek failure.
That's a problem for me.
How would be suitable to handle lseek failure?
Perhaps with new kernel API this code may be obsoleted.
>> @@ -0,0 +1,70 @@
>> +#!/bin/sh
>> +# Ensure that dd conv=sparse works.
>> +
>> +# Copyright (C) 2003, 2005-2011 Free Software Foundation, Inc.
> Use only 2011 as the copyright year.
Okay.
>> +# sometimes we may read less than 1M
>> +dd if=/dev/zero of=sample0 count=1 bs=1M 2> /dev/null || fail=1
>> +[ "`stat -c %s sample0`" = "1048576" ] || fail=1
> We'd write that like this instead:
> (note use of test, not "[...]", use of $(...), not `...`)
>
> test "$(stat -c %s sample0)" = 1048576 || fail=1
Okay.
--
WBR,
Roman Rybalko
This bug report was last modified 13 years and 182 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.