Subject: Re: bug#13391: dd silently ignores lseek error

From: Bernhard Voelker <[email-masked]>
Date: Wed, 09 Jan 2013 08:36:25 +0100

On 01/09/2013 02:14 AM, Pádraig Brady wrote:
> I had a look around for a tool to verify
> that a file/device supports the seek operation
> and couldn't find one.
> So this seems like useful functionality.
> Worth applying the attached?

> * cfg.mk (sc_dd_O_FLAGS): Add O_SEEKABLE to the list of private
> flags with a a single underscore.

s/a a/a/

> @@ -619,6 +628,9 @@ Each FLAG symbol may be:\n\
>        if (O_SEEK_BYTES)
>          fputs (_("  seek_bytes  treat 'seek=N' as a byte count (oflag only)\n\
>  "), stdout);
> +      if (O_SEEKABLE)
> +        fputs (_("  seekable  fail unless seekable\n\
> +"), stdout);

no line break needed here.

> +  offset = lseek (STDOUT_FILENO, 0, SEEK_CUR);
> +  output_seekable = (0 <= offset);
> +  if (! input_seekable && (input_flags & O_SEEKABLE))
> +    {
> +      error (EXIT_FAILURE, input_seek_errno, _("input is not seekable %s"),
> +             quote (input_file));
> +    }

why not check input_seekable where it is set - ~60 lines above?

Have a nice day,
Berny