Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
jfinkels opened this issue Mar 27, 2022 · 0 comments · Fixed by #4164
Closed

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

jfinkels opened this issue Mar 27, 2022 · 0 comments · Fixed by #4164
Labels

Comments

@jfinkels
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant