pump – copy asynchronously via a large circular buffer

pump [ –b iando ] [ –d sleepms ] [ –f ofile ] [ –i ireadsize ] [ –k KB–buf ] [ –o owritesize ] [ –s start–KB ] [ –S off ] [ –t minutes ] [ file ... ]

Pump copies files (or standard input if none) to standard output by using two processes, one reading and one writing, sharing a large circular buffer, thus permitting the reading process to get ahead of the writing process if the output device is slow (e.g., an optical disc). This in turn can keep the output device busy. The pipeline dd | dd can approximate this, but pipe buffering is limited to 64K bytes, which is fairly modest.

Options are:
b   sets the size of read and write operations to iando bytes. The default size is 8 kilobytes.
d   causes the output process to sleep for sleepms milliseconds initially, giving the reading process time to accumulate data in the buffer.
f   writes ofile rather than standard output
i   sets the size of read operations to ireadsize bytes.
k   allocates a circular buffer of KB–buf kilobytes rather than the default 5000 kilobytes.
o   sets the size of write operations to owritesize bytes.
s   prevents output until start–KB kilobytes have been read.
S   seeks both input and output files to off before copying.
t   stops output after minutes have passed. This assumes that pump can copy 10,584,000 bytes per minute.

Append a venti(8) arena to a DVD or BD quickly.
venti/rdarena arena0 arena.3 |
pump –b 65536 –k 51200 >/mnt/cd/wd/arena.3


cp(1), dd(1), ecp(1), cdfs(4)

Pump processes spin while waiting for the circular buffer to fill or drain.

Dd, ecp and pump occupy slightly different niches but perhaps some simplification is possible.

Copyright © 2024 Plan 9 Foundation. All rights reserved.