bug-coreutils
[Top][All Lists]
Advanced

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

Re: dd skip bug?


From: Jim Meyering
Subject: Re: dd skip bug?
Date: Thu, 17 Apr 2008 11:02:37 +0200

Pádraig Brady <address@hidden> wrote:

> Jim Meyering wrote:
>> Pádraig Brady <address@hidden> wrote:
>>> dd handles skip weirdly
>>>
>>> disk=/dev/sda8
>>> dd if=$disk bs=8M count=1 skip=1000 of=/dev/null  #ok
>>> dd if=$disk bs=8M count=1 skip=1000K of=/dev/null #reads whole disk! as 
>>> seek fails
>>>
>>> I had a 10s look at the source and noticed a comment
>>> saying POSIX doesn't specify what we should do when
>>> skipping past the end of input. For seekable files though,
>>> reading the whole thing is unexpected to me at least.
>>> I would expect it to do:
>>>
>>> if (seekable && !seek(skip_len))
>>>     exit(EXIT_FAILURE);
>>
>> Thanks, but the existing behavior is deliberate, and IMHO, necessary.
>>
>> skip=N is required to try to seek, and failing that, position
>> the read pointer by calling read.  That is so it works on
>> e.g., redirected stdin as well as on regular files.
>
> redirected stdin is seekable.
> Note the logic I presented above.

Hi Pádraig,

Redirected stdin is seekable, as long as it's from a seekable file.
I meant "piped stdin".  Same holds for any other non-seekable input source.
I think if you try the code above, it will cause test failures.




reply via email to

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