Date: Fri, 22 Oct 2010 12:31:20 +1100 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Gleb Smirnoff <glebius@freebsd.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r214137 - head/usr.bin/unzip Message-ID: <20101022120523.R1230@besplex.bde.org> In-Reply-To: <201010211705.o9LH5GH5097260@svn.freebsd.org> References: <201010211705.o9LH5GH5097260@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20101022120523.R1230>