From owner-svn-src-head@FreeBSD.ORG Fri Oct 22 01:31:26 2010 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id ABADF106566B; Fri, 22 Oct 2010 01:31:26 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail09.syd.optusnet.com.au (mail09.syd.optusnet.com.au [211.29.132.190]) by mx1.freebsd.org (Postfix) with ESMTP id 41AE28FC12; Fri, 22 Oct 2010 01:31:25 +0000 (UTC) Received: from c122-106-146-165.carlnfd1.nsw.optusnet.com.au (c122-106-146-165.carlnfd1.nsw.optusnet.com.au [122.106.146.165]) by mail09.syd.optusnet.com.au (8.13.1/8.13.1) with ESMTP id o9M1VKQ2000495 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Fri, 22 Oct 2010 12:31:22 +1100 Date: Fri, 22 Oct 2010 12:31:20 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Gleb Smirnoff In-Reply-To: <201010211705.o9LH5GH5097260@svn.freebsd.org> Message-ID: <20101022120523.R1230@besplex.bde.org> References: <201010211705.o9LH5GH5097260@svn.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r214137 - head/usr.bin/unzip X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Oct 2010 01:31:26 -0000 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