From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1Pe5m2-0005ys-Am for mharc-grub-devel@gnu.org; Sat, 15 Jan 2011 08:02:30 -0500 Received: from [140.186.70.92] (port=44087 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Pe5lz-0005vr-7M for grub-devel@gnu.org; Sat, 15 Jan 2011 08:02:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Pe5lx-00075p-EP for grub-devel@gnu.org; Sat, 15 Jan 2011 08:02:27 -0500 Received: from mail-ww0-f49.google.com ([74.125.82.49]:46952) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Pe5lw-000756-TJ for grub-devel@gnu.org; Sat, 15 Jan 2011 08:02:25 -0500 Received: by wwb17 with SMTP id 17so3771995wwb.30 for ; Sat, 15 Jan 2011 05:02:23 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:message-id:date:from:user-agent:mime-version:to :subject:references:in-reply-to:x-enigmail-version:content-type; bh=3Kfjuc2w8wmoGpGw+70BRU5Ei3fnQ0jGrLDcqZMugaA=; b=I7ZZyqp6T6Tl5xsuCNs66ejsVSGHdv9XWdHoiXw2SWdDdR79xbW9iag06f1wMK2nEp QpW1weLW8wMSPsgaSkhn5jx6vXK5AY/y0+KpQoQZIQceA+fmoIxRe04/qmb/rBXSgUQ1 /IpaWP7JMb7rwHJNmEslgts0uCAZjOuqHI8uo= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:user-agent:mime-version:to:subject:references :in-reply-to:x-enigmail-version:content-type; b=IuIYzoTam7fo1S/ujLy1y1WeF7SsjR0KF+/dsoEcMuQLJKQYhJiVkt0wDyF4AqRmwv F4l7zo7sdmH/LVvZIver+0Ni19Emm8WiBINDxNCTXD054jO8rraF9OlKD28kUtyGwxz3 AH4R4ppALlm9xgmra+SZFrMg21Dbtx7W0Fn1w= Received: by 10.227.68.201 with SMTP id w9mr1896757wbi.101.1295096543666; Sat, 15 Jan 2011 05:02:23 -0800 (PST) Received: from debian.x201.phnet (83-96.62-81.cust.bluewin.ch [81.62.96.83]) by mx.google.com with ESMTPS id m13sm1697604wbz.15.2011.01.15.05.02.21 (version=TLSv1/SSLv3 cipher=RC4-MD5); Sat, 15 Jan 2011 05:02:22 -0800 (PST) Message-ID: <4D319AD6.9080909@gmail.com> Date: Sat, 15 Jan 2011 14:02:14 +0100 From: =?UTF-8?B?VmxhZGltaXIgJ8+GLWNvZGVyL3BoY29kZXInIFNlcmJpbmVua28=?= User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20101226 Icedove/3.0.11 MIME-Version: 1.0 To: grub-devel@gnu.org References: <201101150121.59016.szymon@janc.net.pl> <201101151315.43836.szymon@janc.net.pl> In-Reply-To: <201101151315.43836.szymon@janc.net.pl> X-Enigmail-Version: 1.0.1 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="------------enig6DD7BE105326B7466CA8DB36" X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) 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 13:02:28 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig6DD7BE105326B7466CA8DB36 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 01/15/2011 01:15 PM, Szymon Janc wrote: > On Saturday 15 January 2011 01:37:13 Seth Goldberg wrote: > =20 >> 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?=20 >> =20 > The biggest problem now is that opening compressed files require seekin= g to the=20 > end to get uncompressed size so on not seekable fs this causes=20 > grub_file_open("foo") to read whole file. With this patchset this is no= longer a=20 > case. So in that use case > > file =3D grub_file_open ("foo"); > while (grub_file_read (file, buf, sizeof (buf)) > 0) { ... } > > foo is read only once. > > > =20 >> It would seems that even with this patch, one >> would still need to read a gzipped file twice to be able to get its si= ze, >> then allocate a contiguous buffer large enough to hold the entire thin= g >> (if that is desired (which, in some cases, it is :))). >> =20 > Wouldn't sth like that work? > > =20 It's O(N^2). You need to always at least double the allocation every time you exceed already allocated buffer in order to get O(N) > char * ptr =3D 0; > char buf[0x10000]; > unsigned size, size_total =3D 0; > > grub_file_t file =3D grub_file_open ("foo"); > while ( (size =3D grub_file_read (file, buf, sizeof (buf))) > 0) > { > ptr =3D grub_realloc (ptr, size_total + size); > grub_memcpy (ptr+size_total, buf, size); > size_total +=3D size; > } > > =20 --=20 Regards Vladimir '=CF=86-coder/phcoder' Serbinenko --------------enig6DD7BE105326B7466CA8DB36 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iF4EAREKAAYFAk0xmtYACgkQNak7dOguQgmrkQD9H+8Z7WsWJwM0TgfezkiDEvlY xisAXXy+x00+bFHrPcwA/RIvoiLUjxaicMnD16OXevhKx7anFVuJwZ8wEWEZOIqp =Jh98 -----END PGP SIGNATURE----- --------------enig6DD7BE105326B7466CA8DB36--