From owner-freebsd-stable@FreeBSD.ORG Thu Dec 8 23:56:43 2005 Return-Path: X-Original-To: freebsd-stable@freebsd.org Delivered-To: freebsd-stable@freebsd.org Received: from green.homeunix.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 607E216A420; Thu, 8 Dec 2005 23:56:43 +0000 (GMT) (envelope-from green@green.homeunix.org) Received: from green.homeunix.org (green@localhost [127.0.0.1]) by green.homeunix.org (8.13.4/8.13.1) with ESMTP id jB8NugtP038158; Thu, 8 Dec 2005 18:56:42 -0500 (EST) (envelope-from green@green.homeunix.org) Received: (from green@localhost) by green.homeunix.org (8.13.4/8.13.1/Submit) id jB8Nugta038157; Thu, 8 Dec 2005 18:56:42 -0500 (EST) (envelope-from green) Date: Thu, 8 Dec 2005 18:56:42 -0500 From: Brian Fundakowski Feldman To: Dan Nelson Message-ID: <20051208235642.GG98704@green.homeunix.org> References: <00c701c5fc1c$e6db4220$b3db87d4@multiplay.co.uk> <20051208225404.GF98704@green.homeunix.org> <20051208234540.GB95420@dan.emsphone.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20051208234540.GB95420@dan.emsphone.com> User-Agent: Mutt/1.5.11 Cc: Steven Hartland , freebsd-stable@freebsd.org Subject: Re: bsdtar / libarchive bug? X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Dec 2005 23:56:43 -0000 On Thu, Dec 08, 2005 at 05:45:40PM -0600, Dan Nelson wrote: > In the last episode (Dec 08), Brian Fundakowski Feldman said: > > On Thu, Dec 08, 2005 at 05:29:06PM -0000, Steven Hartland wrote: > > > It seems bsdtar can create files it cant read. i.e. it will happily create > > > empty tar.gz files but when it comes to read them the following error > > > is output: > > > tar: Unrecognized archive format: Inappropriate file type or format > > > > > > Having a look at libarchive shows the following code: > > > /* An empty archive is a serious error. */ > > > if (bytes_read == 0) { > > > archive_set_error(a, ARCHIVE_ERRNO_FILE_FORMAT, > > > "Empty input file"); > > > return (ARCHIVE_FATAL); > > > } > > > > > > Which is where I expect the issue is, why would an empty archive > > > be fatal? I can see any reason for this, yes its strange but there's > > > nothing fatal about it imo. > > > > I don't think it will "happily create empty tar.gz files", even where > > by empty you mean the tar itself inside of the gz. > > > > {"/home/green" green@green}$ tar cfv x.tar > > tar: no files or directories specified > > {"/home/green" green@green}$ tar cfvz x.tar.gz > > tar: no files or directories specified > > {"/home/green" green@green}$ ls -l x.ta* > > ls: x.ta*: No such file or directory > > I managed to make it create 0-byte files: > > $ touch a > $ tar cvf b.tar --exclude a a > $ tar zcvf b.tar.gz --exclude a a > $ ls -la b.tar* > -rw-r--r-- 1 dan wheel 0 Dec 8 17:37 b.tar > -rw-r--r-- 1 dan wheel 20 Dec 8 17:37 b.tar.gz > $ gunzip -vl b.tar.gz > method crc date time compressed uncompr. ratio uncompressed_name > defla 00000000 Dec 8 17:37 20 0 0.0% b.tar > > This works because at the time tar creates the output file, it doesn't > know that I have excluded all the listed files. > > I am leaning towards an empty archive being legal, though, since it > makes scripting easier. There may be cases where you are archiving > files generated daily, and you want to distinguish "no data today" from > "the archiver didn't run". At worst it should print a warning. Just don't let it accept a 0-length gzip. -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\