Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Pe52t-0006wB-Fj for mharc-grub-devel@gnu.org; Sat, 15 Jan 2011 07:15:51 -0500 Received: from [140.186.70.92] (port=51875 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pe52r-0006tj-Kh for grub-devel@gnu.org; Sat, 15 Jan 2011 07:15:50 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pe52p-0000o6-Bl for grub-devel@gnu.org; Sat, 15 Jan 2011 07:15:49 -0500 Received: from cox.rootnode.net ([89.248.165.14]:59526) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pe52p-0000nl-75 for grub-devel@gnu.org; Sat, 15 Jan 2011 07:15:47 -0500 Received: from DSPAM-Daemon (localhost [127.0.0.1]) by cox.rootnode.net (Postfix) with SMTP id 6374880A1D60 for ; Sat, 15 Jan 2011 13:15:45 +0100 (CET) Received: from athlon.localnet (89-78-157-238.dynamic.chello.pl [89.78.157.238]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by cox.rootnode.net (Postfix) with ESMTPSA id 2A96A801522C; Sat, 15 Jan 2011 13:15:45 +0100 (CET) From: Szymon Janc To: grub-devel@gnu.org Date: Sat, 15 Jan 2011 13:15:43 +0100 User-Agent: KMail/1.13.5 (Linux/2.6.32-5-686; KDE/4.5.3; i686; ; ) References: <201101150121.59016.szymon@janc.net.pl> In-Reply-To: MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201101151315.43836.szymon@janc.net.pl> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.3.7 (cox.rootnode.net [0.0.0.0]); Sat, 15 Jan 2011 13:15:45 +0100 (CET) X-DSPAM-Result: Whitelisted X-DSPAM-Processed: Sat Jan 15 13:15:45 2011 X-DSPAM-Confidence: 0.9904 X-DSPAM-Probability: 0.0000 X-DSPAM-Signature: 4d318ff1155751804284693 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Seth Goldberg Subject: Re: [PATCH] Support for unknown size and not seekable files X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Jan 2011 12:15:50 -0000 On Saturday 15 January 2011 01:37:13 Seth Goldberg wrote: > Hi, > > Thanks for this. What's the goal of this patch? It seems that it marks > the size and unknown until it gets to the metadata that indicates the > file's size, then updates the size to the correct size, right? Where do > you see this being useful? The biggest problem now is that opening compressed files require seeking to the end to get uncompressed size so on not seekable fs this causes grub_file_open("foo") to read whole file. With this patchset this is no longer a case. So in that use case file = grub_file_open ("foo"); while (grub_file_read (file, buf, sizeof (buf)) > 0) { ... } foo is read only once. > It would seems that even with this patch, one > would still need to read a gzipped file twice to be able to get its size, > then allocate a contiguous buffer large enough to hold the entire thing > (if that is desired (which, in some cases, it is :))). Wouldn't sth like that work? char * ptr = 0; char buf[0x10000]; unsigned size, size_total = 0; grub_file_t file = grub_file_open ("foo"); while ( (size = grub_file_read (file, buf, sizeof (buf))) > 0) { ptr = grub_realloc (ptr, size_total + size); grub_memcpy (ptr+size_total, buf, size); size_total += size; } -- Szymon K. Janc szymon@janc.net.pl // GG: 1383435