(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 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.
}
file->data = data;
+ file->not_easly_seekable = 1;
grub_memcpy (file_int, file, sizeof (struct grub_file));
curr_file = file_int;
file->data = bufio;
file->read_hook = 0;
file->fs = &grub_bufio_fs;
+ file->not_easly_seekable = io->not_easly_seekable;
return 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);
file->data = gzio;
file->read_hook = 0;
file->fs = &grub_gzio_fs;
+ file->not_easly_seekable = 1;
if (! test_header (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;
return file->offset;
}
+static inline int
+grub_file_seekable (const grub_file_t file)
+{
+ return !file->not_easly_seekable;
+}
+
#endif /* ! GRUB_FILE_HEADER */