* include/grub/file.h (grub_file): New member not_easly_seekable.

(grub_file_seekable): New inline function.
	* grub-core/io/gzio.c (test_header): Don't test end magic if file isn't
	easily seekable.
	(grub_gzio_open): Set not_easly_seekable.
	* grub-core/fs/i386/pc/pxe.c (grub_pxefs_open): Set not_easily_seekable.
	* grub-core/io/bufio.c (grub_bufio_open): Propagate not_easily_seekable.
This commit is contained in:
Szymon Janc 2010-09-04 18:28:42 +02:00 committed by Vladimir 'phcoder' Serbinenko
parent ed8c6dec96
commit 3759a35f75
5 changed files with 28 additions and 4 deletions

View File

@ -1,3 +1,13 @@
2010-09-04 Szymon Janc <szymon@janc.net.pl>
* include/grub/file.h (grub_file): New member not_easly_seekable.
(grub_file_seekable): New inline function.
* grub-core/io/gzio.c (test_header): Don't test end magic if file isn't
easily seekable.
(grub_gzio_open): Set not_easly_seekable.
* grub-core/fs/i386/pc/pxe.c (grub_pxefs_open): Set not_easily_seekable.
* grub-core/io/bufio.c (grub_bufio_open): Propagate not_easily_seekable.
2010-09-04 BVK Chaitanya <bvk.groups@gmail.com>
Support for options to appear multiple times on cmdline.

View File

@ -282,6 +282,7 @@ grub_pxefs_open (struct grub_file *file, const char *name)
}
file->data = data;
file->not_easly_seekable = 1;
grub_memcpy (file_int, file, sizeof (struct grub_file));
curr_file = file_int;

View File

@ -74,6 +74,7 @@ grub_bufio_open (grub_file_t io, int size)
file->data = bufio;
file->read_hook = 0;
file->fs = &grub_bufio_fs;
file->not_easly_seekable = io->not_easly_seekable;
return file;
}

View File

@ -214,12 +214,14 @@ test_header (grub_file_t file)
grub_file_seek (gzio->file, grub_file_size (gzio->file) - 4);
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
if (grub_file_seekable (gzio->file))
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0;
if (grub_file_read (gzio->file, &orig_len, 4) != 4)
{
grub_error (GRUB_ERR_BAD_FILE_TYPE, "unsupported gzip format");
return 0;
}
}
/* FIXME: this does not handle files whose original size is over 4GB.
But how can we know the real original size? */
file->size = grub_le_to_cpu32 (orig_len);
@ -1135,6 +1137,7 @@ grub_gzio_open (grub_file_t io, int transparent)
file->data = gzio;
file->read_hook = 0;
file->fs = &grub_gzio_fs;
file->not_easly_seekable = 1;
if (! test_header (file))
{

View File

@ -39,6 +39,9 @@ struct grub_file
/* The file size. */
grub_off_t size;
/* If file is not easly seekable. Should be set by underlying layer. */
int not_easly_seekable;
/* Filesystem-specific data. */
void *data;
@ -69,4 +72,10 @@ grub_file_tell (const grub_file_t file)
return file->offset;
}
static inline int
grub_file_seekable (const grub_file_t file)
{
return !file->not_easly_seekable;
}
#endif /* ! GRUB_FILE_HEADER */