grub-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] Support for unknown size and not seekable files


From: Szymon Janc
Subject: Re: [PATCH] Support for unknown size and not seekable files
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; ; )

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
address@hidden // GG: 1383435




reply via email to

[Prev in Thread] Current Thread [Next in Thread]