=== modified file 'include/grub/file.h' --- include/grub/file.h 2010-04-06 19:28:26 +0000 +++ include/grub/file.h 2010-03-21 23:45:49 +0000 @@ -39,6 +39,9 @@ /* 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 @@ return file->offset; } +static inline int +grub_file_seekable (const grub_file_t file) +{ + return !file->not_easly_seekable; +} + #endif /* ! GRUB_FILE_HEADER */ === modified file 'io/gzio.c' --- io/gzio.c 2010-04-06 19:28:26 +0000 +++ io/gzio.c 2010-03-31 20:45:40 +0000 @@ -173,6 +173,7 @@ grub_uint8_t extra_flags; grub_uint8_t os_type; } hdr; + grub_uint16_t extra_len; grub_uint32_t orig_len; grub_gzio_t gzio = file->data; @@ -214,12 +215,14 @@ 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); @@ -1140,6 +1143,7 @@ file->data = gzio; file->read_hook = 0; file->fs = &grub_gzio_fs; + file->not_easly_seekable = 1; if (!test_header (file)) { @@ -1241,7 +1245,6 @@ return grub_errno; } - static struct grub_fs grub_gzio_fs = {