svn commit: r214137 - head/usr.bin/unzip

Bruce Evans brde at optusnet.com.au
Fri Oct 22 01:31:26 UTC 2010


On Thu, 21 Oct 2010, Gleb Smirnoff wrote:

> Log:
>  Make it possible to read input from stdin.
>
>  Without this change I don't see a way to
>  unpack a multivolume archive without wasting
>  disk space for a temporary file.

What's wrong with the canonical "cat foo*.zip | unzip /dev/stdin"?  This
is better for light use than engooping utilities with support for "-".

This failed for an old ports version of unzip because it stat'ed
/dev/stdin.zip and /dev/stdin.ZIP and found neither.  Bogus.  Then I
tried foo.zip where foo.zip is a symlink to /dev/stdin.  (This hack
is also useful for broken disk utilities that want disk names in /dev
with special names.)  This failed because unzip first tried to seek
on the pipe (failure ignored), then tried to read 0 bytes from the
pipe (the read succeeded but failure to find the central directory
followed, apparently because it used st_size as the size of the file.
These bugs seem to be missing in the current version.  /dev/stdin
works, and so does a symlink to /dev/stdin although it does some lstats
which probably break in other cases for symlinks.

The not-unused md5 utility is still broken on device files but not on
pipes using similar techniques in its library (MDXFileChunk()).  First
it does an fstat to get st_size.  Then it tries to seek, and if the
seek fails it uses a method that actually works and necessarily doesn't
use st_size.  Old versions used a working method in all cases.  So you
have to use a hack like "cat /dev/ad0 | md5" to checksum a disk device,
else you get the same checksum for all disks as for all devices and
all empty files.

Bruce


More information about the svn-src-head mailing list