Skip to content

dd: seek should cause a read from named pipe but doesn't #3321

@jfinkels

Description

@jfinkels

Steps to reproduce:

First, create a named pipe:

$ mkfifo tape

In one shell, invoke GNU dd to copy one block of zeros to the named pipe.

$ dd count=1 if=/dev/zero of=tape

This process will wait until another process reads from the named pipe.

In a second shell, invoke GNU dd to copy nothing but seek by one block in the named pipe.

$ dd count=0 seek=1 of=tape

This second command will terminate successfully almost immediately, presenting the following output:

0+0 records in
0+0 records out
0 bytes copied, 0.000242781 s, 0.0 kB/s

And the process in the first shell will also terminate because bytes have now been read from the named pipe. It will print the following:

1+0 records in
1+0 records out
512 bytes copied, 0.000450248 s, 1.1 MB/s

(512 is the default block size.) The logic here is that the second process attempted to simulate a seek by reading from the named pipe.

Now try using uutils dd in the first shell and GNU dd in the second. The first process will terminate with an error

$ ./target/release/dd count=1 if=/dev/zero of=tape
./target/release/dd: failed to seek in output file: Illegal seek

and the second will wait indefinitely.

Finally, try using GNU dd in the first shell and uutils dd in the second. Both processes will wait indefinitely.

This issue comes from the GNU test case tests/dd/no-allocate.sh.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions